I have a C++ project which uses multiple external static libraries and a huge code base.
If I put it all together like this:
g++ (ALL INCLUDE PATHS) (FLAGS) (ALL LIBRARIES) (ALL SOURCES) -o FILE
All at once in the same command, it works.
However I want to use a Makefile to generate file objects and speed up the compiling process.
I am able to generate a object file for each individual source file, but when trying to put them all together like this:
g++ -o FILE (ALL OBJECT FILES FOUND RECURSIVELY IN THE PATH)
I get the following errors, as if they had not been compiled with the static libraries
Linux_Release/.compilation_libs/linux.o: In function `WndProc(int, int, int)':
main_Linux.cpp:(.text+0xc6): undefined reference to `XRefreshKeyboardMapping'
main_Linux.cpp:(.text+0x18c): undefined reference to `XLookupKeysym'
main_Linux.cpp:(.text+0x20b): undefined reference to `Xutf8LookupString'
...
I've tried to put the includes/flags/libraries back into the command once again, but it doesn't make a difference.
Here are the flags I'm using for compiling each source file individually:
CFLAGS := -fmessage-length=0 -std=c++11 -Wno-sign-compare -Wno-unused-local-typedefs -Wno-reorder -Wno-switch -fpermissive -static-libstdc++ -static-libgc c -Wl,-rpath=.
And here are some of the libs included in the command above
LIBS := -lcurl -lz -lX11 -lXi -lGL -lGLU -lGLEW -lfreetype -lbass -lbass_fx -lOpenCL (and more...)
And the target for building each file object looks like this:
$(COMPILATION_LIBS_FOLDER)/%.o: %.cpp
mkdir -p '$(@D)'
g++ $(CFLAGS) $(FIXED_INCLUDES) $(LIBPATH) $(LIBS) -c $< -o $@