1
votes

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?

1
Did you actually STW for the keywords "ios error: Unsupported architecture" yet? I'm not a Mac expert but it looks to me as if some of those links might prove to be helpful to you.dirkbaechle
Did you read this bit from the Readme .. "Using JsonCpp in your project The recommended approach to integrating JsonCpp in your project is to include the amalgamated source (a single .cpp file and two .h files) in your project, and compile and build as you would any other source file. This ensures consistency of compilation flags and ABI compatibility, issues which arise when building shared or static libraries. See the next section for instructions."bdbaddog

1 Answers

0
votes

The problem was Xcode command line tolls that I had to update manually. The reason for the update is the new Xcode (7) update that I made. After the update compilation worked perfectly.