Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Khor on August 05, 2009, 09:31:53 pm

Title: Custom Makefile: Different behaviour on Windows and Linux
Post by: Khor on August 05, 2009, 09:31:53 pm
Hi everyone,
I am trying to get C::B running with a custom Makefile on both, Windows and Linux.

I created a simple project with just one cpp file and the following Makefile:

Code
DEFINES =
LIBS = OGRE OIS
CXX = g++
CXXFLAGS = $(shell pkg-config --cflags $(LIBS)) $(DEFINES)
LD = g++
LDFLAGS = $(shell pkg-config --libs $(LIBS))

Release:
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o bin/Debug/ogreapp src/main.cpp

Debug:
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o bin/Release/ogreapp src/main.cpp

clean.Release:
rm -f bin/Release/ogreapp

clean.Debug:
rm -f bin/Debug/ogreapp

The interesting thing happens when compiling the project. On Linux the compiler gets called like this:
Code
g++ -DOGRE_GUI_GLX -DOGRE_CONFIG_LITTLE_ENDIAN -I/usr/local/include -I/usr/local/include/OGRE -I/usr//include/OIS -I/usr//include    -L/usr/local/lib -L/usr//lib -lOgreMain -lOIS   -o bin/Debug/ogreapp src/main.cpp

On Windows the call looks a little different:
Code
g++    -o bin/Release/ogreapp src/main.cpp

Okay, this is basically what one expect from the Makefile given (except that the libs are missing). However, I do like what he does on my Linux machine. But why does C::B does behave different on both platforms with the same setup? Not to mention the configuration flags for OGRE (where does he get them?), why does he know and add the include pathes for the OGRE headers on Linux? In fact, I do like this behaviour, since pathes are highly dependent on the user setup on Windows. Therefore I would like to not have them in the Makefile. But since I do not know, how C::B knows about them on Linux, I cannot reproduce that on Windows.

I kindly ask for any hint that could explain the different pointed out above. If you need extra information and will be more then happy to provide it, if possible.

Regards,
Oliver
Title: Re: Custom Makefile: Different behaviour on Windows and Linux
Post by: Jenna on August 06, 2009, 02:11:00 am
It looks like you have pkg-config in the system-path and *.pc-files for ogre and ois  on your linux-system, but not on windows (they don't exist here or they are not in path).

The problem is not C::B related, you should search for documentation on how makefiles work (especially expanding of variables, call of the system-shell ...) and what pkg-config is and what you can do with it.
man pkg-config on linux and the gnu make manual (http://www.gnu.org/software/make/manual/make.html) might be starting-points.