0
votes

Whats wrong with my command? I want to compile x64 ld_preload on x86 g++, command:

g++ -fPIC -m64 -shared -Wl,-soname,test.so -ldl -o test.so test.cpp

error

In file included from /usr/include/c++/4.4/bits/stl_tree.h:62, from /usr/include/c++/4.4/set:60, from test.cpp:17: /usr/include/c++/4.4/bits/stl_algobase.h:60: fatal error: bits/c++config.h: No such file or directory compilation terminated. make: * [test.so] Error 1

17 line test.cpp

#include <set>

Package g++-multilib installed.

upd

File search:

#include <...> search starts here:
 /usr/include/c++/4.4
 /usr/include/c++/4.4/backward
 /usr/local/include
 /usr/lib/gcc/i686-linux-gnu/4.4.5/include
 /usr/lib/gcc/i686-linux-gnu/4.4.5/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include

Thanks!

1

1 Answers

1
votes

The file bits/c++config.h in GNU C++ library is architecture dependent.

The 32 bit version is in

 /usr/include/c++/4.4/i486-linux-gnu/bits/c++config.h

or similar depending on the distribution.

On 32 bit platform the 64bit version is in

 /usr/include/c++/4.4/i486-linux-gnu/64/bits/c++config.h

Edit

To check which directories are searched type:

$ g++ -m64 -c -v test.cpp

It should report something like

Using built-in specs.
Target: i486-linux-gnu
...
#include <...> search starts here:
 /usr/include/c++/4.4
 /usr/include/c++/4.4/i486-linux-gnu/64
 /usr/include/c++/4.4/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.4.1/include
 /usr/lib/gcc/i486-linux-gnu/4.4.1/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include

You need to check if

 /usr/include/c++/4.4/i486-linux-gnu/64

is on the list.

Also check that the file

/usr/include/c++/4.4/i486-linux-gnu/64/bits/c++config.h

exists.