mgrebenets / boost-xcode5-iosx

Build boost framework for iOS and OSX with Xcode 5 (armv7, armv7s, arm64, i386, x86_64)
43 stars 29 forks source link

Building for boost locale only #7

Open s-lee-kwong opened 10 years ago

s-lee-kwong commented 10 years ago

So I modified the script to only build the boost locale module.

I replaced

: ${BOOST_LIBS:="chrono context filesystem graph_parallel iostreams locale mpi program_options python regex serialization signals system thread timer wave"}
BOOST_LIBS="$BOOST_LIBS date_time graph math random test exception"

to ${BOOST_LIBS:="locale"} BOOST_LIBS="$BOOST_LIBS"

then ran ./boost.sh clean -v 1.55.0, having the boost_1_55_0.tar.bz2 in the same folder

and it completed successfully but when I use it as a framework in iOS, I would get undefined symbol errors for arm7, i386 etc

Undefined symbols for architecture i386:
"boost::locale::base_message_format<char>::id", referenced from:
  boost::locale::basic_message<char>::write(std::__1::locale const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const in 

I looked at the framework and got this:

file boost.framework/boost
boost.framework/boost: Mach-O universal binary with 5 architectures
boost.framework/boost (for architecture armv7): current ar archive random library
boost.framework/boost (for architecture armv7s):    current ar archive random library
boost.framework/boost (for architecture i386):  current ar archive random library
boost.framework/boost (for architecture x86_64):    current ar archive random library
boost.framework/boost (for architecture cputype (16777228) cpusubtype (0)): current ar archive

so I looked more closely to the log and found this

/Users/shawnlee-kwong/work/code/boost-xcode5-iosx/osx/build/x86_64: libboost_locale.a   obj
rm: /Users/shawnlee-kwong/work/code/boost-xcode5-iosx/osx/build/*/libboost.a: No such file or directory
...armv7
ar: obj/libboost_locale/*.o: No such file or directory
...armv7s 
ar: obj/libboost_locale/*.o: No such file or directory
...arm64
ar: obj/libboost_locale/*.o: No such file or directory
...i386
...x86_64
...osx-i386
...osx-x86_64
Completed successfully

so I investigated the stack trace and found this when trying to bjam the iphone build

Performing configuration checks

- iconv (libc)             : no
- iconv (separate)         : no
- icu                      : no
- icu (lib64)              : no
- Boost.Locale needs either iconv or ICU library to be built.
- Boost.Locale needs either iconv or ICU library to be built.
- Boost.Locale needs either iconv or ICU library to be built.
- Boost.Locale needs either iconv or ICU library to be built.
- Boost.Locale needs either iconv or ICU library to be built.
- Boost.Locale needs either iconv or ICU library to be built.

For the other builds like simulator and osx it did find iconv, as an example

Performing configuration checks

- iconv (libc)             : no
- iconv (separate)         : yes
- icu                      : no
- icu (lib64)              : no

So I was wondering if anyone had an idea about iconv or ICU for the iphone build.

mgrebenets commented 10 years ago

Hi. I am trying to look into that and trying to build and test the same way you do. I know for sure the build is ok up until 1.54.0. 1.55.0 is relatively new and I see more warnings when building it, so I would recommend to stick with some version from 1.51.0 to 1.54.0 for a while.

The "No such file or directory" messages that you see are for OSX, not iOS. It needs to be looked at, but in your case you're trying to run it on iOS so this should be irrelevant.

And I have one wild guess. Could it be that you link your iOS project agains OSX framework? I have no idea how it could happen, so pardon me for trying really crazy guesses :) But I'd recommend to remove osx framework directory and make sure it is not included into Xcode project, then give it another try. Since iOS Simulator is running on OSX you may not notice the mix up until you try to run on actual device. Btw, do you have boost library installed on your Mac? For example installed with homebrew or something else?

s-lee-kwong commented 10 years ago

Hey,

Thanks for the reply. I will try what you are suggesting and come back with my results. But I was only using the ios build for ios and didn't include the osx one at all.

mgrebenets commented 10 years ago

Also, have a look at your C++ dialect settings. As I understand you don't use --with-c++11 flag when building, right? Then make sure that your Xcode project build settings match. https://github.com/mgrebenets/boost-xcode5-iosx#undefined-symbols-link-error

s-lee-kwong commented 10 years ago

Ya I made sure all those settings were there as well, even if I don't use the --with-c++11

I also tried doing it with that flag plus the xcode project settings, still no good

Shawn

mgrebenets commented 10 years ago

When I add locale to list of libs I have the same issue with iconv. Apparently for locale either iconv or icu is required. Both are not part of boost and should be available as external libraries.

- iconv (separate) : yes means that's it's using iconv library installed on the OSX system, thus the build is OK for iOS simulator and OSX.

It looks like iconv is available for iOS (http://stackoverflow.com/questions/4242914/which-libiconv-should-we-use-on-ios), but it's path must be specified when building boost framework. http://www.boost.org/doc/libs/1_48_0/libs/locale/doc/html/building_boost_locale.html Here's the quote from that page.

If iconv library is not found on Darwin/Mac OS X builds 
make sure there is no multiple iconv installations 
and provide -sICONV_PATH build option to point to correct location of iconv library.

There should be a way to lookup iconv library in IPHONE_OS_PLATFORM_PATH and modify writeBjamUserConfig to include -sICONV_PATH option for iOS platform. I will try to do that when I have some time. Feel free to open PR if you find a solution.

s-lee-kwong commented 10 years ago

Hey,

Ya I have tried a bunch of ways to include that option and have had no luck, maybe you know more than I do when it comes to including that flag.

s-lee-kwong commented 10 years ago

Hey, I also just used 1.51.0 of boost with only chrono lib and still was getting the unidentified symbols for architecture when i integrated the framework into my iOS project

s-lee-kwong commented 10 years ago

Hey, have you been able to figure out the locale stuff at all, I've been trying to pick away at it here and there but I still have no luck with it.

I still get the same problems as I stated above even with the new script you put out there. Still cannot find iconv and I have tried everything you suggested and have come empty so far.

Any help would be greatly appreciated.

Thanks

mgrebenets commented 10 years ago

I couldn't get iconv located either. I know for sure that there is iconv library in iOS, here's how you can find it's path

ICONV_IOS_PATH=$(dirname $(find $(xcrun --sdk iphoneos --show-sdk-platform-path) -name "libiconv*" | tail -1 ) | rev | cut -d/ -f2- | rev)

Then I'm using it when calling bjam but it doesn't work anyway. bjam is supposed to understand -sICONV_PATH option

-sICONV_PATH=${ICONV_IOS_PATH}

I was following instructions on this page http://www.boost.org/doc/libs/1_48_0/libs/locale/doc/html/building_boost_locale.html There is some information about building for OS X, should be similar with iOS.

mgrebenets commented 10 years ago

I couldn't get anything working. But I found some really great example of building Boost. Have a look at this one: https://github.com/PaulWagener/mapnik-ios-framework/blob/master/Makefile#L120-L137 It doesn't build locale, but it builds regex with unicode icu. The example also does not include arm64 and x86_64 architecture, but it has lots of useful hints.

I don't have much time right now to try to reuse some useful code from that script.

In general, it looks like I will have to refactor the whole build script and use Makefile with proper dependencies instead of bash script.

s-lee-kwong commented 10 years ago

OK, I will check those out and see if I can get anywhere to.

Thanks a lot for the effort and hope we can get something done in the future to get this working!

gsrivastava411 commented 10 years ago

Did either of you guys had any luck with this? Am struggling to get boost locale working but getting the same linker error on Xcode. Undefined architecture for armv7. Any help will be appreciated. Thanks.

s-lee-kwong commented 10 years ago

Unfortunately I have not had the time to look into the problem anymore. So no fix for me over here.

Sorry.

cjenkins-mersive commented 9 years ago

In case anyone else ends up on this page looking to build boost_locale for iOS I did find that cloning https://github.com/PaulWagener/mapnik-ios-framework/ and adding locale to the list of boost libraries in the makefile successfully built the boost_locale.a for ios/armv7 (entire project did not build, but got far enough to compile boost). Successfully linked against an iOS project I was working on but never actually tried using it at runtime.

shz2050 commented 7 years ago

I found a new solution described in http://metashapes.com/blog/building-boost-locale-ios/

But it doesn't work.

But the author said 》 The path may very well get down to the compilation statement, but the test simply does not compile at all.

So I try to modify the fount-iconv method in the location: boost_1_62_0/libs/locale/build

Directly to modify the file "Jamfile.v2" on the line 229, set found-iconv variable always true, like: found-iconv = true ;

It seems work for me.