![]() |
|
Compile Allegro for IOS |
muhkuh
Member #14,826
January 2013
|
Hi, I'm desperately trying to compile Allegro for IOS. I follow the instruction in the Readme but it fails quite early. I'm using: This is what I do: 1. Use allegro 5.0.8, 5.1.4, svn version of 5.1, doesn't matter The configure process termiates with this error: 1The C compiler identification is Clang 4.1.0
2The CXX compiler identification is Clang 4.1.0
3Check for working C compiler using: Xcode
4Check for working C compiler using: Xcode -- broken
5CMake Error at /Applications/CMake 2.8-10.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
6 The C compiler
7 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
8 is not able to compile a simple test program.
9
10 It fails with the following output:
11
12 Change Dir: /Users/vegazz/5.1/build-ios/CMakeFiles/CMakeTmp
13
14
15
16 Run Build Command:/Applications/CMake\ 2.8-10.app/Contents/bin/cmakexbuild
17 -project CMAKE_TRY_COMPILE.xcodeproj build -target
18 cmTryCompileExec2932570827 -configuration Debug
19
20 === BUILD NATIVE TARGET cmTryCompileExec2932570827 OF PROJECT
21 CMAKE_TRY_COMPILE WITH CONFIGURATION Debug ===
22
23 Check dependencies
24
25 target specifies product type 'com.apple.product-type.tool', but there's no
26 such product type for the 'iphoneos' platform
27
28
29
30
31
32 ** BUILD FAILED **
33
34
35
36
37
38 The following build commands failed:
39
40 Check dependencies
41
42 (1 failure)
43
44
45
46
47
48 CMake will not be able to correctly generate this project.
49Call Stack (most recent call first):
50 CMakeLists.txt:37 (project)
51
52
53Configuring incomplete, errors occurred!
The error seems kind of reasonable to me. CMake is trying to create a console program to check if the compiler works but the IOS target doesn't support this. What am I doing wrong? Edit: When I comment out the line in Toolchain-iphone.cmake that sets CMAKE_OSX_SYSROOT it seems to work: SET (IPHONE 1) SET (SDKROOT "iphoneos") #SET (CMAKE_OSX_SYSROOT "${SDKROOT}")
|
ted_gress
Member #14,404
June 2012
|
I'm having problems compiling for iOS too....but my issue I think is TwilightRaven Games |
Elias
Member #358
May 2000
|
So when you leave out CMAKE_OSX_SYSROOT, does everything work and you can run the examples on an ios device? For me cmake chooses gcc instead of clang to do the tests so they all work. (It still uses clang in XCode later.) -- |
muhkuh
Member #14,826
January 2013
|
I commented out CMAKE_OSX_SYSROOT in the toolchain file but you have to set it at some point. Otherwise you will build for OSX as you already noticed. So this is what I did: 1. comment out CMAKE_OSX_SYSROOT in the toolchain file The iOS support also seems to be work in progress at the moment. Not every release works. For me the svn of the 5.1 channel did compile cleanly as well as the recent git version of the same branch but they are not the same. The subversion repository seems to contain some state before the 5.1.4 release and the git repository something after that. I definitely got the iPhone example running.
|
Elias
Member #358
May 2000
|
We don't use SVN anymore. The historic repository still exists as some people have stuff in there but don't use it for Allegro. What would be interesting of course is whether the 5.1.5 release works. -- |
muhkuh
Member #14,826
January 2013
|
I checked the 5.1.5 release and it does work (at least the stuff I'm using). But I had to make these modifications: 1. comment out the line "SET (CMAKE_OSX_SYSROOT "${SDKROOT}")" in cmake/Toolchain-iphone.cmake 2. Add these two entries to cmake/FileList.cmake in the ALLEGRO_INCLUDE_ALLEGRO_PLATFORM_FILES section: This step can be avoided if you don't use the install functionality of cmake. What's also notable is that the install target doesn't copy the libraries to the install directory but I didn't have the time to check why. 3. Perform these steps inside the allegro source tree to get a working project instead of what the README_iphone.txt states: I thought about how this process could be made more comfortable for the user. Even if all this works you get a project that either builds i386 binaries for the iOS simulator or arm binaries for the iOS device. But it is possible to build universal binaries that contain both. So I wrote a script that creates the ALLEGRO xcode project and builds binaries for all required architectures. After that the *.o files from all libraries get extracted and merged together into a large super library for every platform. In a final step all these super libraries are merged together into one universal static library. This way you just need to link to this library and everything will work no matter for what iOS target you build. It's possible to make this even more convenient by creating a Framework. It's just a matter of taking the universal binaries, the headers and adding some symlinks and a xml description. I guess all that stuff could also be done in cmake if this is desired. In the end it would even be possible to create a ready to use binary version of the framework for iOS. I attached the script as it is now. May be it will help someone.
|
billyquith
Member #13,534
September 2011
|
When I was building from git I had similar issues to muhkuh. Using cmake 2.8.10 and Xcode 4.5.2. I changed my Toolchain-iphone.cmake to: 1SET (IPHONE 1)
2SET (ALLEGRO_CFG_OPENGLES 1)
3SET (SDKROOT iphone)
4
5include(CMakeForceCompiler)
6CMAKE_FORCE_C_COMPILER(clang GNU)
7CMAKE_FORCE_CXX_COMPILER(clang++ GNU)
8SET(CMAKE_SIZEOF_VOID_P 4)
9set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
10
11set(CMAKE_OSX_SYSROOT iphoneos)
12set(CMAKE_OSX_DEPLOYMENT_TARGET "")
13set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework CoreGraphics -framework QuartzCore -framework UIKit")
14set(XCODE_ATTRIBUTE_SDKROOT iphoneos)
15set(XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
16"com.yourcompany.\${PRODUCT_NAME:rfc1034identifier}")
17set(CMAKE_OSX_ARCHITECTURES ${ARCHS_STANDARD_32_BIT})
I got most of this from the Ogre cmake build files. They have quite a slick process. Also had issue 2, where aliphone.h and aliphonecfg.h missing. My solution was more hacky: copied allegro/include and the build include dir over this. muhkuh solution looks better. I think the cmake install method should definitely be made to work for all platforms. It is almost there. I also use lipo to generate universal libraries. |
|