Lu, Lianhao wrote: > Richard Purdie wrote on 2010-12-08: >> Hi Lianhao, >> >> On Tue, 2010-12-07 at 00:02 -0800, Lu, Lianhao wrote: >>> I'm wondering whether"-sysroot" is enough for our current design >>> that the rootfs used by toolchain can be copied by the user to >>> various locations? I just bumped into a problem when the >>> cross-canadian g++ complaining: fatal error: iostream: No such file >>> or direcotory. >>> >>> I tried to compile the following hello.cpp with with >>> "mips-poky-linux-g++ --sysroot=<mysysroot> hello.cpp". >>> >>> #include <iostream> >>> >>> using namespace std; >>> >>> void main() >>> >>> { >>> >>> cout << "Hello World!" << endl; >>> } >>> >>> >>> >>> I straced the mips-poky-linux-g++ and found that it >>> searched"<mysysroot>/usr/include" for file iostream while that file >>> is actually located at"<mysysroot>/usr/include/c++". The >>> cross-canadian g ++ seems to be configured with"- >>> with-gxx-include-dir=/opt/poky/sysroots/mips-poky-linux/usr/include/ >>> c ++", but it seems"-sysroot" option has no effect on the gxx >>> include search path. >> >> So I'm confused as these two sentences appear to contradict each >> other. >> >> """ >> it searched "<mysysroot>/usr/include" for file iostream while that >> file is actually located at"<mysysroot>/usr/include/c++" """ >> >> means it did use <mysysroot> and the --with-sysroot option did >> something but dropped the c++ part at the end of the path? >> > > Exactly. It only searched the /usr/include under the sysroot > specified by "--sysroot" options, but did not search the > /usr/include/c++.
Reading gcc manual, it seems --sysroot will only look at <sysroot>/usr/include and <sysroot>/usr/lib. I've also played with -isysroot, which pretty much the same effect as sysroot. I can only get the compilation going by explicitly using -I <mysysroot>/usr/include/c++ -I <mysysroot>/usr/include/c++/i586-poky-linux options. And by using strace, I found the command line options won't override the default header/library searching sequence of gcc (set by with-gxx-include-dir), which still trying to search under /opt/poky/i586-poky-linux/usr/include/c++, etc first...
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto