0

Hi all,

I have been trying to compile some c++ using GNU make. This involves linking with a third party library and it is this that seems to have caused the problem. The error message tells me that there are undefined references in my program to one of my own classes (RandNos) and its member functions. My suspicions are, that this problem arises during the linking stage, even though the error seems to suggest it does not. I have compiled similar code with make many times before without hitch, the only difference with the current code is the inclusion of the third party library. Please take a look at my make file and the subsequent error messages, which follow. I hope you can help

JFLIB =  /home/network/findlay/jfcpplib/

all:SynSurvey_v2

SynSurvey_v2: SynSurvey_v2.o RandNos.o $(JFLIB)Bisection.o
	g++ -std=c+98  -I/usr/include SynSurvey_v2.o -L/usr/lib -lboost_regex RandNos.o $(JFLIB)Bisection.o SynSurvey_v2

SynSurvey_v2.o: SynSurvey_v2.cpp	
	g++ -std=c++98 -I/usr/include SynSurvey_v2.cpp -L/usr/lib -lboost_regex 

RandNos.o: RandNos.cpp RandNos.h
	g++ -c RandNos.cpp

Bisection.o: $(JFLIB)Bisection.cpp $(JFLIB)Bisection.h
	g++ -c $(JFLIB)Bisection.cpp

clean:
	rm -f SynSurvey_v2 SynSurvey_v2.o RandNos.o $(JFLIB)Bisection.o
/tmp/ccFiW4Do.o: In function `main':
SynSurvey_v2.cpp:(.text+0x10ea): undefined reference to `RandNos::RandNos(int)'
SynSurvey_v2.cpp:(.text+0x10f8): undefined reference to `RandNos::generate()'
SynSurvey_v2.cpp:(.text+0x1109): undefined reference to `RandNos::get_err()'
collect2: ld returned 1 exit status
make: *** [SynSurvey_v2.o] Error 1
2
Contributors
2
Replies
5
Views
8 Years
Discussion Span
Last Post by sillyboy
0

No Worries, problem solved:

JFLIB =  /home/network/findlay/jfcpplib/

all:SynSurvey_v2

SynSurvey_v2:  SynSurvey_v2.o RandNos.o $(JFLIB)Bisection.o
	g++ -std=c++98 -I/usr/include/ SynSurvey_v2.o  -L /usr/lib -lboost_regex RandNos.o $(JFLIB)Bisection.o -o SynSurvey_v2

SynSurvey_v2.o:SynSurvey_v2.cpp
	g++ -c SynSurvey_v2.cpp

RandNos.o: RandNos.cpp RandNos.h
	g++ -c RandNos.cpp

Bisection.o: $(JFLIB)Bisection.cpp $(JFLIB)Bisection.h
	g++ -c $(JFLIB)Bisection.cpp

clean:
	rm -f SynSurvey_v2 SynSurvey_v2.o RandNos.o $(JFLIB)Bisection.o

Seems to work now, thought i'd tried this but obsv not.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.