I've applied Compile boost C++11 clang mac cannot find cstddef
and invoked build as follows
./b2 variant=debug,release --layout=versioned toolset=clang cxxflags="-fPIC -std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-stdlib=libc++ -arch i386 -arch x86_64" threading=multi link=shared --stagedir=stage_darwin_intel_shared_mt stage
And everything builds, except for a log of warnings and except for Boost.Wave fails:
http://pastebin.com/ZHkmTWaq
P.S. Static flavor of boost builds Wave fine.
Correct compilation
./b2 variant=debug,release --layout=versioned toolset=clang cxxflags="-fPIC -std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" threading=multi link=shared --stagedir=stage_darwin_intel_shared_mt stage
Related
I'm trying to update the ncurses-5.4 to ncurses-5.9 on Mac OS X 10.7.
I've built ncurses-5.9
./configure --prefix=/usr/local/ncurses-5.9 --with-shared
To do the update:
sudo mv /usr/lib/libncurses.5.4.dylib /usr/lib/libncurses.5.4.dylib_BACKUP
sudo ln -s =/usr/local/ncurses-5.9/lib/libncurses.5.dylib /usr/lib/libncurses.5.4.dylib
But after I do it, I get this sort of errors:
Dyld Error Message:
Library not loaded: /usr/lib/libncurses.5.4.dylib
Referenced from: /Applications/iTerm.app/Contents/MacOS/iTerm
Reason: Incompatible library version: iTerm requires version 5.4.0 or later,
but libncurses.5.4.dylib provides version 5.0.0
How to update it to ncurses-5.9? Thank you.
Take a look at Apple's configuration. The config.status file happens to tell you what configure-options were used:
with options \"--prefix=/usr --disable-dependency-tracking --disable-mixed-case --with-shared --without-normal --without-debug --enable-termcap --enable-widec --with-abi-version=5.4 --without-cxx-binding --without-cxx --mandir=/usr/share/man 'CFLAGS=-arch i386 -arch x86_64 -arch ppc -g -Os -pipe -isysroot /' 'CXXFLAGS=-arch i386 -arch x86_64 -arch ppc -g -Os -pipe ' 'LDFLAGS=-arch i386 -arch x86_64 -arch ppc '\"
You should read the INSTALL description for each option, to understand what's done, but the pertinent one for your question is this:
--with-abi-version=5.4
I use "xcrun -sdk iphonesimulator clang" for CC when configuring ffmpeg.
xcrun -sdk iphonesimulator clang is unable to create an executable file.
If xcrun -sdk iphonesimulator clang is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.
xcode5 is ok.
=========== Update ========
I added a test, it seems clang not link _start for simulator.
AGSPC98:pwd fluke$ cat> ~/tmp/ios.c
int main(void){ return 0; }
AGSPC98:pwd fluke$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fasm -fno-short-enums -fno-strict-aliasing -arch i386 -miphoneos-version-min=5.0 -g -fno-inline-functions -O0 -falign-functions=4 -DDEBUG=1 -DVPLAYER_IOS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -c -o ~/tmp/ios.o ~/tmp/ios.c
AGSPC98:pwd fluke$
AGSPC98:pwd fluke$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -arch i386 -miphoneos-version-min=5.0 -o ~/tmp/ios ~/tmp/ios.o
Undefined symbols for architecture i386:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
AGSPC98:pwd fluke$ nm ~/tmp/ios.o
00000000 T _main
Changing -miphoneos-version-min=5.0 to -miphoneos-version-min=6.0 makes everything right.
As is asked and answered in this post, I needed to give -arch i386 option for SWIG/C# integration.
Do I need to give the option for both compilation/link?
g++ -c -arch i386 example.cxx example_wrap.cxx
g++ -arch i386 -bundle -undefined suppress -flat_namespace example.o example_wrap.o -o libexample.dylib
Have you tried it? A simple test with a C program on OS X 10.6 with a 64-bit capable machine suggests that, in general, you do need to specify -arch for both.
$ gcc -arch i386 -o x.o x.c
$ gcc x.o -o x.dylib
ld: warning: in x.o, file was built for i386 which is not the architecture being linked (x86_64)
Intuitively, the linker does need to know which set of architecture-specific libraries to link with.
I want to compile jpeg-8b in universal binary (ppc,i386). It should be supported in 10.4 and later OSs. I could do it in 10.5 and 10.6, but the binary is not compatible with 10.4. Thus I tried to compile it in 10.4, but it fails.
This is my code
cd jpeg-8b
sudo ./configure CC="gcc -arch i386 -arch ppc" CXX="g++ -arch i386 -arch ppc" CPP="gcc -E" CXXCPP="g++ -E" -enable-static=yes -enable-shared=no
It fails with the error configure: error: C compiler cannot create executables
How can I compile jpeg-8b in MacOS 10.4?
Can you try compiling it on 10.5/10.6 with 10.4 SDK installed
and using:
export MACOSX_DEPLOYMENT_TARGET="10.4"
export OSX_SDK="/Developer/SDKs/MacOSX10.4.sdk"
export OSX_CFLAGS="-isysroot $OSX_SDK -arch ppc -arch i386"
export OSX_LDFLAGS="-Wl,-syslibroot,$OSX_SDK -arch ppc -arch i386"
export CFLAGS="$CFLAGS $OSX_CFLAGS"
export CXXFLAGS="$CXXFLAGS $OSX_CFLAGS"
export LDFLAGS="$LDFLAGS $OSX_LDFLAGS"
export ARCHFLAGS="-arch ppc -arch i386"
and try adding --disable-dependency-tracking to ./configure
It worked for me after adding export CFLAGS="-arch x86_64 -arch arm64" before calling config. See GitHub gist
I am trying to build a Universal binary on MacOSX with g++. However, it doesn't really work. I have tried with this simple dummy code:
#include <iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
}
This works fine:
% g++ test.cpp -arch i386 -arch ppc -arch x86_64 -o test
% file test
test: Mach-O universal binary with 3 architectures
test (for architecture i386): Mach-O executable i386
test (for architecture ppc7400): Mach-O executable ppc
test (for architecture x86_64): Mach-O 64-bit executable x86_64
However, this does not:
% g++ test.cpp -arch i386 -arch ppc -arch x86_64 -arch ppc64 -o test
In file included from test.cpp:1:
/usr/include/c++/4.2.1/iostream:44:28: error: bits/c++config.h: No such file or directory
In file included from /usr/include/c++/4.2.1/ios:43,
from /usr/include/c++/4.2.1/ostream:45,
from /usr/include/c++/4.2.1/iostream:45,
from test.cpp:1:
/usr/include/c++/4.2.1/iosfwd:45:29: error: bits/c++locale.h: No such file or directory
/usr/include/c++/4.2.1/iosfwd:46:25: error: bits/c++io.h: No such file or directory
In file included from /usr/include/c++/4.2.1/bits/ios_base.h:45,
from /usr/include/c++/4.2.1/ios:48,
from /usr/include/c++/4.2.1/ostream:45,
from /usr/include/c++/4.2.1/iostream:45,
from test.cpp:1:
/usr/include/c++/4.2.1/ext/atomicity.h:39:23: error: bits/gthr.h: No such file or directory
/usr/include/c++/4.2.1/ext/atomicity.h:40:30: error: bits/atomic_word.h: No such file or directory
...
Any idea why that is?
I am on MacOSX 10.6. I have installed Xcode 3.2.2 with all SDKs it comes with. GCC 4.2 is the default. GCC 4.0 produces some different errors, though behaves similar.
ppc64 support was dropped in Snow Leopard. You can still use ppc64 if you build and link against the Mac OS X 10.5 SDK.
Try the following command at the command line:
g++ test.cpp -arch i386 -arch ppc -arch x86_64 -arch ppc64 -mmacosx-version-min=10.5 -isysroot/Developer/SDKs/MacOSX10.5.sdk -DMACOSX_DEPLOYMENT_TARGET=10.5 -o test
Or for the 10.4 SDK use:
g++-4.0 test.cpp -arch i386 -arch ppc -arch x86_64 -arch ppc64 -mmacosx-version-min=10.4 -isysroot/Developer/SDKs/MacOSX10.4u.sdk -DMACOSX_DEPLOYMENT_TARGET=10.4 -o test
Note, if you want to use the 10.4 SDK, you will have to use gcc 4.0 (or g++4.0 ). Apple's GCC 4.2 doesn't support the 10.4 SDK.