From: Brian G. <ge...@ro...> - 2004-04-07 20:47:36
|
On Tue, 6 Apr 2004, Ghulam Mubashar Hassan wrote: > Thanks for the help. i am new with Linux operating system and i do not have > enough help in my lab. the below is my make file. i am adding the player > related files. Some classes and library files like list.c list.h sensor.c > sensor.h sensorcontainer.h and sensorcontainer.cc are there in the same > folder where marhesrobotdriver.cc is placed. i am trying to add libcanlib.so > residing in path given by INCLUDES2. hi Ghulam, The problem is that you're not including all the objects in the .so (see below). > Can anyone please check it out and inform > me. > i have also tried to use KDevelop, but its also not compiling my program. i am > using SuSe Linux. If there is any prefered C++ programs developing software, > please inform me about it too. I've never met a graphical development environment that I didn't hate. Maybe I'm just old-fashioned, but I strongly believe that command lines and Makefiles (whether written manually or automagically generated) are the way to go. > INCLUDES2 = -L$/usr/lib/ > INCLUDES3 = -L$/libcanlib.so > %.o: %.cc > $(CXX) -Wall -g3 $(INCLUDES1) $(INCLUDES2) $(INCLUDES3) -c $< This doesn't really make sense. In addition to Reed's comment about the unnecessary $, the -c flag to gcc tells it *not* to link anything, but rather create an unlinked object file. Even if you get the syntax right, trying to link to a library (i.e., libcanlib) here won't work. See below for more. > %.so: %.o > $(CXX) -shared -nostartfiles -o $@ $< This line is the main problem. What this says is, "to build foo.so, link in ONLY foo.o". So your other code (e.g., sensorcontainer.cc) won't be included. Try something like this instead: OBJECTS = list.o sensor.o sensorcontainer.o %.so: $(OBJECTS) $(CXX) -shared -nostartfiles -o $@ $(OBJECTS) -lcanlib Then the shared object will depend on and include all the object files. Make sure to list all the objects you need (i.e., the .o files). Furthermore, it tells the linker that your shared object also depends on libcanlib.so, which will (I think) cause the loader to load it at runtime. brian. -- Brian P. Gerkey ge...@ro... Stanford Robotics Lab http://robotics.stanford.edu/~gerkey |