openFrameworks 0.8.4 iOS + Xcode6でエラー
iPhoneでofのプログラムを動かしたいと思って導入してみたんですが、エラーが出ました。が、解決しました。ので一連の流れを備忘録として残しておきます。
まず openFramworks_v.0.8.4_ios内のemptyExampleを実行してみたところ、
ld: -pie can only be used when targeting iOS 4.2 or later clang: error: linker command failed with exit code 1 (use -v to see invocation)
というエラーが出ました。これはDeployment Targetを4.2以降にすれば良いみたいです。
xcode - openFrameworks for iOS become Apple mach-O Linker Error - Stack Overflow
次にこの設定で実行したところ、
ld: warning: ignoring file ../../../libs/FreeImage/lib/ios/freeimage.a, missing required architecture i386 in file ../../../libs/FreeImage/lib/ios/freeimage.a (2 slices) ld: warning: ignoring file ../../../libs/glu/lib/ios/glu-ios.a, missing required architecture i386 in file ../../../libs/glu/lib/ios/glu-ios.a (2 slices) Undefined symbols for architecture i386: "_fwrite$UNIX2003", referenced from: _WriteProc(void*, unsigned int, unsigned int, void*) in freeimage.a(FreeImageIO.o-i386) LibRaw::dcraw_thumb_writer(char const*) in freeimage.a(libraw_cxx.o-i386) _opj_image_create in freeimage.a(image.o-i386) _png_default_write_data in freeimage.a(pngwio.o-i386) LibRaw::ppm_thumb() in freeimage.a(dcraw_common.o-i386) LibRaw::jpeg_thumb_writer(__sFILE*, char*, int) in freeimage.a(dcraw_common.o-i386) LibRaw::write_ppm_tiff() in freeimage.a(dcraw_common.o-i386) ... "_mktime$UNIX2003", referenced from: LibRaw::get_timestamp(int) in freeimage.a(dcraw_common.o-i386) LibRaw::parse_rollei() in freeimage.a(dcraw_common.o-i386) LibRaw::parse_riff() in freeimage.a(dcraw_common.o-i386) "_strerror$UNIX2003", referenced from: Iex::throwErrnoExc(std::string const&, int) in freeimage.a(IexThrowErrnoExc.o-i386) "_strtod$UNIX2003", referenced from: _png_handle_sCAL in freeimage.a(pngrutil.o-i386) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
というエラーが出ました。
これは、
openFrameworks 0.8.4 iOS + Xcode6でビルド出来ない - Shut the fuck up and write some code
こちらのページにあるように、main.mmに下記のコードを追加すればいいようです。
extern "C"{ size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d ) { return fwrite(a, b, c, d); } char* strerror$UNIX2003( int errnum ) { return strerror(errnum); } time_t mktime$UNIX2003(struct tm * a) { return mktime(a); } double strtod$UNIX2003(const char * a, char ** b) { return strtod(a, b); } }
実は少し前にエラーでなえて放置してたので、解決して嬉しい!