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.
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.