Mac OS X cross-compiler not finding system include files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a question regarding cross-compilation for Mac OS X targets from a Linux host. I'm not sure of this is the forum to ask this question, as the Mac OS X gcc is somewhat proprietary. Please let me know if there's a better forum to raise this question.

My basic problem is that the Mac OS X gcc cross-compiler does not find its own system include files.


I've set up the cross-compiler according to these steps: http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt

all seems to work fine an initial sight:

s$ /opt/i686-apple-darwin9/bin/i686-apple-darwin9-g++ --version
i686-apple-darwin9-g++ (GCC) 4.0.1 (Apple Inc. build 5490)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


but even if I try to compile the simplest of codes:

$ cat hello.cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;

    return 0;
}


the compiler is not finding the system C++ headers:

$ /opt/i686-apple-darwin9/bin/i686-apple-darwin9-g++ -o hello hello.cpp
hello.cpp:1:20: error: iostream: No such file or directory
hello.cpp: In function 'int main()':
hello.cpp:4: error: 'cout' is not a member of 'std'
hello.cpp:4: error: 'endl' is not a member of 'std'


I tried to work with the -isysroot parameter (which is not documented anywhere, but references can be found in forums / mailing lists), for example:

$ /opt/i686-apple-darwin9/bin/i686-apple-darwin9-g++ -isysroot /opt/i686-apple-darwin9 -Wl,-syslibroot,/opt/i686-apple-darwin9 -o hello hello.cpp
hello.cpp:1:20: error: iostream: No such file or directory
hello.cpp: In function 'int main()':
hello.cpp:4: error: 'cout' is not a member of 'std'
hello.cpp:4: error: 'endl' is not a member of 'std'


but as visible, the effect is the same. Of course, one can set a range of -I options so that compilation is successful:

$ opt/i686-apple-darwin9/bin/i686-apple-darwin9-g++ -isysroot /opt/i686-apple-darwin9 -isystem /opt/i686-apple-darwin9/include/c++/4.0.1 -isystem /opt/i686-apple-darwin9/usr/include/c++/4.0.0/i686-apple-darwin8 -isystem /opt/i686-apple-darwin9/usr/include -isystem /opt/i686-apple-darwin9/lib/gcc/i686-apple-darwin9/4.0.1/include -isysroot /opt/i686-apple-darwin9 -Wl,-syslibroot,/opt/i686-apple-darwin9 -o hello hello.cpp
$ file hello
hello: Mach-O executable i386


but I'm not sure this is the right solution :)

usually when I use cross-compile toolchains, the compiler automagically know where to look for its own system header files. is this information lost on the Mac OS X gcc compiler somehow?

is there a 'nice' solution to this?


Akos

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux