sonatabar bar wrote:
Hi,
Newbee here, Linux box.
I am trying to compile a program into an executable by
linking libraries of 5 packages.
I have, main.cpp , second.cpp, thrid.cpp, fourth.cpp,
fifth.cpp, and
4 header files, second.h, thrid.h, fourth.h, fifth.h.
I first compile all the files into respective object
files. Using Makefile,
.cpp.o:
echo Compiling $<...
$(CPP_COMPILER) $(INCLUDE_DIRS) $(FLAGS) -c $<
$(INCLUDE_DIRS)
At this point I checked each of the object files by
doing, for example, ld main.o, to find many undefined
references. Which I suppose is OKAY untill i finish
linking ???
Then, I try to generate executable.
I fail doing so, if I do the following
g++ -o executable_name main.o $(INCLUDE_LIBS)
second.o $(INCLUDE_LIBS) third.o $(INCLUDE_LIBS)
fourth.o $(INCLUDE_LIBS) fifth.o $(INCLUDE_LIBS)
If $INCLUDE_LIBS contains stuff like
/path/to/library/directory/libname.so and
/path/to/library/directory/libname.a, it will only work for
the static libraries.
Try using "-L /path/to/library/directory -lname" to specify
the libraries to link to, where "name" is derived from
"libname.so".
I get those undefined reference errors present in the
'ld objectfile.o'.
I have all the paths to required libraried specified
in $(INCLUDE_LIBS). The only difference is that all
except one set of libraries are shared libraries(.so).
Others all static libraries(.a).
I could get the executable generated if use the
following option
g++ -static -r executable_name ......................
But then I get an error:
Exec format error. Wrong Architecture.
Can anyone suggest me if, I am doing something wrong.
if not How do I go about resolving it.
Also to mention, I have few archived static libraries
created from obectfiles.o, which in turn has undefined
references. And the path of these libraries are
specified in $(INCLUDE_LIBS).
Any feedback is appreciated. Thanks,
Sonata
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com