Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

g++ linking issues 1

Status
Not open for further replies.

UmmmOk

Programmer
Aug 1, 2001
3
TR
I am fairly new to C++, have done a fair bit of C coding though. I am
having issues compiling...a little unsure of how I am supposed to
compile and link classes.

I have a class defined in Image.h and implemented in Image.cpp. I
compiled that with the following

g++ -c -o obj/Image.o Image.cpp -I../include

I did this because I was unable to link since there is no main function
in this file, so I used the -c option to just create an object file.
Then I have a file test_circle.cpp that I am try to link as follows
(after having created an object file earlier in my makefile)

g++ -o ../bin/test_circle obj/test_circle.o obj/Image.o obj/Circle.o
-L../lib -lm -lmygraphics -ltiff

Image.cpp uses a function tiff_raster2file that is in libmygraphics and
test_circle.cpp has an instance of the Image class. When I try to
compile test_circle.cpp though I get the following error messages

******************************************************
Undefined first referenced
symbol in file
tiff_raster2file(char*, unsigned long*, unsigned long, unsigned
long)obj/Image.o
ld: fatal: Symbol referencing errors. No output written to
../bin/test_circle
collect2: ld returned 1 exit status
make: *** [test_circle] Error 1

*******************************************************

What am I doing wrong here? It appears that Image.o is not finding the
functions in libmygraphics, but I do not know how to link them to it.


Any help would be greatly appreciated.

Thank you in advance,

J.
 
try with a declaration
extern tiff_raster2file(char*, unsigned long*, unsigned long, unsigned long)
in your image.h file which i hope you must have includedin your test_circle.cpp
i hope it works
 
You should be able to compile them with
Code:
g++ -o dice dice.o client.o
//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top