1

I'm using Cygwin32 on Win7 64. I have g++ and libstdc++ installed. The C++ includes are located at /usr/lib/gcc/i686-pc-cygwin/4.8.2/include/c++/tr1/ - but nowhere under /usr/include.

Is it reasonable to place them, by symlink, under /usr/include? If not, why? And if so, why isn't this done by default And what should the symlink be? /usr/include/c++/ ? Something else?

Note: Yes, I know I can add them to the compiler flags; I'm asking whether it's reasonable to do more than that.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

2 Answers2

1

There shouldn't be any need, if you are talking about standard C++ includes. The g++ version destined to use them should know about that location, and since you might have different gcc versions around (for example, MinGW's one), it is better to leave it as it is just to not confuse other compilers.

If your compiler is having troubles finding its own includes, well, that's entirely another matter.

If you are curious about how and why this location is determined, read here, specifically under the option --enable-version-specific-runtime-libs ... it says something about "using several gcc versions in parallel". You can also check the actual configure script under libstdc++-v3 source code directory...

In my personal experience, when you are creating a single library for a bunch of platforms, you simply want (cross-) compilers as independent as possible. If every compiler puts its includes in /usr/include/c++ ... well, that can end bad. In fact, under that particular scenario, it could be reasonable for each compiler to hide its specific header and library files as well as possible...

dsign
  • 12,340
  • 6
  • 59
  • 82
  • Eclipse CDT is "peculiar" in its own way... There are ways to query g++ for include paths, and CDT seems to know about them... but the whole thing is very fragile, and my guess is that getting it to work can be specially difficult in Windows. – dsign Nov 11 '13 at 15:19
  • Still, why am I seeing include files under `/usr/lib` rather than `/usr/include` ? – einpoklum Nov 11 '13 at 15:25
  • Excellent question! All I can tell you is that that is "by design". The real reason might have something to do with some dark corner of the unix filesystem hierarchy standard: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard and http://www.linuxfoundation.org/collaborate/workgroups/lsb/fhs ... but it is just a guess. – dsign Nov 11 '13 at 15:28
  • Welp, the Wikipedia page says `/usr/include` should have standard include files (and the standard C++ library is pretty standard by my standards), which `/usr/lib` should have libraries (not include files) for the binaries in `/usr/bin`. The FHS says `/usr/lib` contains "object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts." So... what gives? – einpoklum Nov 11 '13 at 22:20
  • STL is standard to C++, AFAIK, not to Unix... I agree that perhaps would be more sensible to have them under /usr/include/platform_name/binary_architecture/compiler_version/c++, but I don't see how would that make a difference to Eclipse CDT... – dsign Nov 12 '13 at 08:20
0

Just add them to your environment variable CPPFLAGS (or in your makefile):

CPPFLAGS='-I/usr/lib/gcc/i686-pc-cygwin/4.8.2/include/c++/tr1 -I/whatev' 
Paul Evans
  • 27,315
  • 3
  • 37
  • 54