Building libopc for armv7 with clang

Apr 27, 2013 at 4:27 PM
Hi,

Fist of all, thank you for this great lib. I'm trying to build it for armv7 but it seems it's not supported out of the box. I've tried to set the os/ver/toolchain/arch to ios4-debug-clang-armv7 with no luck. Also, it seems the config file only accepts debug for the clang toolchain. Is there a easy way to do it?
Coordinator
Apr 27, 2013 at 5:04 PM
Hi,

you need to define the platform in the Makefile.platform.xml. I use

<platform name="ios4-debug-gcc-i386" family="ios-debug-gcc-x86"
cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2"
ld="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ld"
ar="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar"
cflags="-g -O0 -arch i386 -fno-exceptions -fvisibility=hidden -fstack-protector"
cflags_c="-std=c99" cflags_cpp="-fno-rtti"
cppflags="-D__IPHONE_OS_VERSION_MIN_REQUIRED=40300 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/"
ldflags="-framework Foundation -framework UIKit -framework CoreText -framework CoreGraphics -framework OpenGLES -framework QuartzCore -lstdc++"/>


<platform name="ios4-release-gcc-i386" family="ios-release-gcc-x86"
cc="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
ld="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
ar="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
cflags="-g -Os -arch i386 -fno-exceptions -fvisibility=hidden"
cflags_c="-std=c99" cflags_cpp="-fno-rtti"
cppflags="-DNDEBUG -D_NDEBUG -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/"
ldflags="-framework Foundation -framework UIKit -framework CoreText -framework CoreGraphics -framework OpenGLES -framework QuartzCore -lstdc++"/>


<platform name="ios4-debug-gcc-armv7" family="ios-debug-gcc-arm"
cc="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
ld="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
ar="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
cflags="-g -O0 -arch armv7 -fno-exceptions -fvisibility=hidden -mthumb"
cflags_c="-std=c99" cflags_cpp="-fno-rtti"
cppflags="-miphoneos-version-min=4.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
ldflags="-framework Foundation -framework UIKit -framework CoreText -framework CoreGraphics -framework OpenGLES -framework QuartzCore -lstdc++"/>


<platform name="ios4-release-gcc-armv7" family="ios-release-gcc-arm"
cc="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
ld="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
ar="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
cflags="-g -Os -arch armv7 -fno-exceptions -fvisibility=hidden -mthumb"
cflags_c="-std=c99" cflags_cpp="-fno-rtti"
cppflags="-DNDEBUG -D_NDEBUG -miphoneos-version-min=4.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
ldflags="-framework Foundation -framework UIKit -framework CoreText -framework CoreGraphics -framework OpenGLES -framework QuartzCore -lstdc++""/>

on my machine.

Let me know whether this works,

Florian


Apr 27, 2013 at 6:23 PM
Hey Florian,


Thanks for the input, works like a charm. Just one thing, you can't set the host in your config file so I had to hack it a little to get it to work (set it manually), I don't know if this is intended (or if there is a nicer way to do it) or not, but I though I should write it here if anybody has this problem in the future.
May 14, 2014 at 1:26 PM
Edited May 14, 2014 at 1:28 PM
Hi

I'm trying to build the libs for armv7 or armv7s and I'm stuck in the same place.

I'm on a OS X 10.9.2 with XCode 5.1.1, iOS SDK 7.1

With the platforms defined as in your example (except I put a 7 instead of 4 - ios7-debug-gcc-armv7 and ios7-release-gcc-armv7) the configure script stops pretty quick with
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/Users/florin/Docs/libopc/libopc-20526/build/copy/plib':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
*** error running "./configure --host=arm-apple-darwin10 " in "build/plib"
And in the logs I see errors like these:
In file included from conftest.c:10:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include/limits.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/limits.h:64:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/machine/limits.h:8:2: error: architecture not supported
#error architecture not supported
Apparently no __arm__ directive is defined. This is the machine/limits.h file.
#if   defined (__arm__) || defined (__arm64__)
#include <arm/limits.h>
#else
#error architecture not supported
#endif
I tried setting the CPP value to clang but that also fails in the same places, failing to include the limits header.
In file included from conftest.c:10:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include/limits.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/limits.h:63:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/sys/cdefs.h:655:2: error: Unsupported architecture
#error Unsupported architecture
 ^
In file included from conftest.c:10:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include/limits.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/limits.h:64:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/machine/limits.h:8:2: error: architecture not supported
#error architecture not supported
 ^
conftest.c:14:8: error: unknown type name 'Syntax'
                     Syntax error
                     ^
conftest.c:14:20: error: expected ';' after top level declarator
                     Syntax error
                                 ^
                                 ;
4 errors generated.

configure:2824: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|                    Syntax error
I've tried unsetting the CPPFLAGS to see if the script would define __arm__ but that didn't help.

Any idea why the configure script fails with these errors?

Thank you