Advertisement

Makefile Help

Started by March 25, 2005 09:54 AM
0 comments, last by hh10k 19 years, 7 months ago
I'm trying to get my project to compile on Linux. The code all works on Windows, my problem is with getting Make to successfully build my code. I'm new to Linux development but I managed to write a makefile that compiles a few shared objects a static library and an executable, which make up my project. The section of the makefile that I'm having a problem with is here:

CPP  = g++
INCS =  -I"include" -I"../../Engine" -I"../../Engine/Core" -I"../../Engine/Foundation" -I"../../Engine/Kernel"  -I"../../Engine/Platform"
LIBS =  -L"lib" -L"/usr/X11R6/lib" -ldl

LIB = ../../Bin/Linux/lib-gcc.a
LIB_OBJECTS = linux_platform.o linux_main.o log.o
TEST = ../../Test/Linux/Test


all: $(LIB) $(TEST)

$(TEST): $(LIB) test.o
	$(CPP) $(INCS) -o $(TEST) test.o $(LIB)

$(LIB): $(LIB_OBJECTS)
	ar r $(LIB)  /usr/lib/libdl.a $(LIB_OBJECTS)
	ranlib $(LIB)

clean:
	rm -f *.o $(LIB) $(TEST)


linux_main.o: ../../Engine/Platform/linux_main.cpp
	$(CPP) -c ../../Engine/Platform/linux_main.cpp -o linux_main.o $(INCS)

log.o: ../../Engine/Foundation/log.cpp
	$(CPP) -c ../../Engine/Foundation/log.cpp -o log.o $(INCS)

linux_platform.o: ../../Engine/Platform/linux_platform.cpp
	$(CPP) -c ../../Engine/Platform/linux_platform.cpp -o linux_platform.o $(INCS)

test.o: ../../Test/Linux/test.cpp
	$(CPP) -c  ../../Test/Linux/test.cpp -o test.o $(INCS)
I get errors when my test executable compiles, about unresolved references to the dlopen() functions, which are contained in libdl.a. It seems even though my static library is linking to libdl.a, the excutable cannot find the functions inside my static library. Can anyone help solve my problem? How can I make sure libdl is linked into my static library correctly? Thanks for any help.
From a quick look, I don't see where $(LIBS) is being supplied to link $(TEST).

This topic is closed to new replies.

Advertisement