as I had a free weekend without appointments I thought I could play around with some developing for Haiku. Since I like cmake and clang/llvm I installed both using HaikuDepot.
Looking around the system I found zillions of places where headers and libraries are placed:
since most of the entries seem to be symlinks to whatever lib or folder, I am confused.
So, what folder should be used primary for searching/finding system libs?
Is there any specified order which should be used?
Same goes for header files. Which are the primary locations? Where are the includes/lib of gcc and clang located?
Also is something like a template available for compiler flags, which should always be used? At the moment I use
For clang you need to use the headers in: /boot/system/develop/headers/x86
And the libs in: /boot/system/develop/lib/x86
Things outside the "x86" folder are for gcc2 apps (it's this way for compatibility reasons with BeOS). Things outside "develop" are for runtime execution, inside "develop" for linking and compiling. The folders in /boot are just symlinks to the ones in system/ for convenience and, again, BeOS compatibility.
thanks for the explanation. I now use /boot/system/develop/lib/x86 as base for searching for libs in my cmake setup.
Compiling now works flawlessly, but clang produces a gcc2 shared library (I checked that with objdump).
Is there any magic to create a non-gcc2 lib with clang? It seems that clang under Haiku uses gcc for linking. Maybe I need to use the gcc-x86 linker?
This should work out of the box, but maybe we missed something. I suggest running: “setarch x86” and trying again (be sure to clean all cmake generated files, because it caches a lot of information).
Using “setarch x86” in a shell gives fine results: ~/Desktop/source/test> gcc test.cc -o test.gcc -lstdc++
~/Desktop/source/test> objdump -D test.gcc | grep -A2 -B2 ABI
…
Without “setarch x86” I need a different std lib, but otherwise it compiles fine: ~/Desktop/source/test> gcc test.cc -o test.gcc2 -lstdc++.r4
~/Desktop/source/test> objdump -D test.gcc2 | grep -A2 -B2 ABI
…
Yes, this most likely won’t work. I suggest opening a bug report at haikuports (github.com/haikuports/haikuports) about this, as it is a problem with clang and the way the haikuports team compiled it, not haiku itself.