I'm trying to build jsoncpp (C++ code) as static lib for iPhone simulator & device. Simulator compilation success but device compilation failed. I think the reason is the linker that search for includes in MacOSX10.11.sdk instead iPhoneOS9.1.sdk. It is not clear for me why the linker is not searching in iPhoneOS9.1.sdk and why on the simulator compilation this problem doesn't exists.
I'm using scons with next configuration:
env = Environment(CXX = 'clang++', TARGET_OS = 'ios', toolpath = ['scons-tools'], tools=[] )
if platform == "ios_phone":
env['CXXFLAGS'] = '-std=c++11 -stdlib=libc++ -arch armv7 --sysroot %s' %(IOSROOT)
env['LINKFLAGS'] = '-stdlib=libc++ -arch armv7 -isysroot %s' %(IOSROOT)
env['TARGET_ARCH'] = 'armv7'
print env.Dump()
#IOS SIMULATOR COMPILATION
if platform == "ios_simulator":
env['CXXFLAGS'] = '-std=c++11 -stdlib=libc++ -arch i386 -arch x86_64 --sysroot %s' %(IOS_SIMULATOR_ROOT)
env['LINKFLAGS'] = '-stdlib=libc++ -arch i386 -arch x86_64 -isysroot %s' %(IOS_SIMULATOR_ROOT)
env['TARGET_ARCH'] = 'i386, x86_64'
print env.Dump()
And getting the next error:
scons: Building targets ... clang++ -o buildscons/ios_phone/src/lib_json/json_reader.o -c -std=c++11 -stdlib=libc++ -arch armv7 --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk -Iinclude src/lib_json/json_reader.cpp In file included from src/lib_json/json_reader.cpp:7: In file included from include/json/reader.h:11: In file included from include/json/value.h:12: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:434: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:23: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/unistd.h:71: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/_types.h:27: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_types.h:32: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/cdefs.h:707:2: error: Unsupported architecture
error Unsupported architecture
I didn't found MacOSX in the env params.
Do you know how to force linker to use the right platform? Or what is the root cause?