How to strip from object code generated by g++ the strings representing absolute paths to source headers
c++, gcc
Solution
The file names and paths are usually from the command line, so if you compile the file with an absolute path, it will show up in the binary. You need to modify how you compile your source files, probably changing the build system. Change:
g++ -I/home/frey/mylib/include /home/frey/foo.cpp -o foo
to
cd /home/frey
g++ -Imylib/include foo.cpp -o foo
Problem
By running `strings` I have noticed that the object code generated by my `g++ 4.7.3`compiler (without turning on the debug flag) contains the absolute paths to all the headers used in the source code units. Doing a `strip -s` on the object code does not remove those strings. Why are they included in an object code in the first place? Secondly, how can I remove them from the object code?