4

I was using Poco library 1.4.5-all, and recently I upgraded my Xcode to 5.0.1. Somehow I had problem linking Poco libraries for iPhone device build so I managed to link properly for iPhone device by using the latest Poco library (poco-1.4.6p2-all)

Because Xcode5.0.1 has no llvm support for command line, I had to build Poco library for iPhone device like this. (changed CXXFLAGS in the 'build/config/iPhone-clang-libc++' file to link with openssl library)

./configure --config=iPhone-clang-libc++  -static --no-tests --no-samples --omit=Data/ODBC,Data/MySQL 
make IPHONE_SDK_VERSION_MIN=5.0 POCO_TARGET_OSARCH=arm64 -s -j4
make IPHONE_SDK_VERSION_MIN=5.0 POCO_TARGET_OSARCH=armv7 -s -j4
make IPHONE_SDK_VERSION_MIN=5.0 POCO_TARGET_OSARCH=armv6 -s -j4

So it worked fine when building for iPhone device.

The problem is for building for iPhone simulator. There are so many 'Undefined symbols for architecture i386' errors.

This is what I did for building Poco library for iPhoneSimulator.

I fired following command.

./configure --config=iPhoneSimulator-clang-libc++  -static --no-tests --no-samples --omit=Data/ODBC,Data/MySQL 
make

And the result was problematic. (There are so many 'Undefined symbols for architecture i386' errors.)

I checked the difference between those 2 libraries. The 'nm' tool results are like follows.

i686 (problematic)

00000050 T __ZN4Poco12DigestEngine11digestToHexERKNSt3__16vectorIhNS1_9allocatorIhEEEE
000001e8 S __ZN4Poco12DigestEngine11digestToHexERKNSt3__16vectorIhNS1_9allocatorIhEEEE.eh
00000198 s __ZZN4Poco12DigestEngine11digestToHexERKNSt3__16vectorIhNS1_9allocatorIhEEEEE6digits

armv7 (ok)

0000001c T __ZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEE
00000280 S __ZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEE.eh
00000228 s __ZZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEEE6digits

can this be a clue for this problem?

Have anybody succeeded building for iPhoneSimulator?

Thanks in advance. Bruce.

Locke
  • 315
  • 1
  • 3
  • 14

2 Answers2

0

I managed to build properly for both iPhone device and iPhoneSimulator.

Eventhough Xcode5.0.1 does not support llvm for commandline, you can download 'CommandLine Tools for Maverick'. If you install it then you can use llvm. So you can use build configurations for 'iPhone' and 'iPhoneSimulator' (no need to use 'iPhone-clang-libc++' and 'iPhone-clang-libc++' configuration)

And the 'nm' tool was showing the problem correctly. There was something wrong when I was building for iPhoneSimulator.

So, I'm gonna show you the quick fix for those.

1) go to your downloaded 'poco-1.4.6p2-all' directory

2) open build/config/iPhone file

vim build/config/iPhone

3) and Change following two lines

CC      = $(shell ls $(TOOL_PREFIX)/llvm-gcc-$(GCC_VER)* | tail -1)
CXX     = $(shell ls $(TOOL_PREFIX)/llvm-g++-$(GCC_VER)* | tail -1)

to this

CC      = /usr/bin/llvm-gcc
CXX     = /usr/bin/llvm-g++

This is because the original script tries to call 'llvm-gxx' in thr wrong place. The 'CommandLine Tools for Maverick' will create symbolic link for 'llvm-gxx' in the '/usr/bin' directory.

Sorry for not beautiful script but hardwired one.

4) and find 'CXXFLAGS', and specify the 'openssl' include & lib directory like this. (Of cource you need to have it built beforehand.)

CXXFLAGS        = $(OSFLAGS) -Wall -Wno-sign-compare -L(Your openssl source directory)/lib/iOS -I(Your openssl source directory)/include

5) Now you're done with that configuration file. Save it and close.

6) Next, open build/config/iPhoneSimulator file

vim build/config/iPhoneSimulator

7) Find the 'OSFLAGS' and comment it out like this

# OSFLAGS            = -arch $(POCO_TARGET_OSARCH) -isysroot $(IPHONE_SDK_BASE) -miphoneos-version-min=$(IPHONE_SDK_VERSION_MIN)

8) Done. save it and close it.

9) Now fire following commands for building libraries for 'iPhone' device.

./configure --config=iPhone  -static --no-tests --no-samples --omit=Data/ODBC,Data/MySQL 
make IPHONE_SDK_VERSION_MIN=5.0 POCO_TARGET_OSARCH=armv7 -s -j4

if you need to build libraries for other architecture, please add it.

10) Done. Now fire following commands to build libraries for 'iPhoneSimulator'

make clean
./configure --config=iPhoneSimulator  -static --no-tests --no-samples --omit=Data/ODBC,Data/MySQL 
make IPHONE_SDK_VERSION_MIN=5.0 POCO_TARGET_OSARCH=i686 -s -j4

The final line above, and changed to build config files are the solution for my problem... I am not that well aware of compiler&linker stuffs so I'm not sure what really is the problem with original scripts..

11) Done. Finally, compare the library contents of those 2 like this.

nm lib/iPhoneOS/armv7/libPocoFoundation.a |  grep digestToHex
nm lib/iPhoneSimulator/i686/libPocoFoundation.a |  grep digestToHex

you should see the signatures of compiled C++ function 'digestToHex' identical like this for example..

brucewang@Bruce-ui-MacBook ~/Downloads/poco-1.4.6p2-all $ nm lib/iPhoneOS/armv7/libPocoFoundation.a |  grep digestToHex                                 [ruby-1.9.3-p125]
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
0000001c T __ZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEE
00000280 S __ZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEE.eh
00000228 s __ZZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEEE6digits
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
brucewang@Bruce-ui-MacBook ~/Downloads/poco-1.4.6p2-all $ nm lib/iPhoneSimulator/i686/libPocoFoundation.a |  grep digestToHex                           [ruby-1.9.3-p125]
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
00000050 T __ZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEE
00000268 S __ZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEE.eh
00000218 s __ZZN4Poco12DigestEngine11digestToHexERKSt6vectorIhSaIhEEE6digits
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
brucewang@Bruce-ui-MacBook ~/Downloads/poco-1.4.6p2-all $                             

12) If you need 'fat library' then call the 'lipo' command from your terminal. For example, you can make a simple shell script firing following command repeatedly for all *.a files.

lipo -create -output "${UNIVERSAL_DIR}/${FILE1}" "${SIMULATOR_DIR}/${FILE1}"  "${ARMV7_DIR}/${FILE1}"                 

That's all.

Locke
  • 315
  • 1
  • 3
  • 14
0

So for people running OSX10.8 + XCode5 , the mavericks solution doesn't really work. I found an alternative solution.

Another option is to use the clang compiler. I haven't tested this yet, to please be cautious. It does seem to compile..beyond that not sure

in in the poco directory open build/config/iPhone and replace the CC and CXX with this:

CC              = $(shell xcrun -find -sdk iphoneos clang)
CXX             = $(shell xcrun -find -sdk iphoneos clang++)

I came across this solution here

Community
  • 1
  • 1
mox1
  • 614
  • 3
  • 10