Skip to content
Advertisement

Avoiding header collisions when cross compiling

I have a linux project I want to port to windows. Under Linux I did set up my makefile to run x86_64-w64-mingw32-g++ when I do call make ARCH=win

The problem is that some headers I need (tcl.h and friends) are located under '/usr/include' and if I pass that directory with the -I flag I will get a header collision for headers like stdlib.h which obviously are different for windows.

Is there a way around this besides copying the needed tcl headers into another location?

Advertisement

Answer

There is a sequentially order the compiler will look for header files. But no you cannot cherry pick the header file location.

A solution that you can try with this problem is using -I/usr and patch your project with the sed utility to convert the required headers like <tcl.h> to <include/tcl.h>. On top of that you can use the preprocessor to avoid patching every time your project.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement