xCode 6 arm64 link errors cocos2d-x 3.1[SOLVED]

When I am trying to build my cocos2d-x 3.1 game with xCode 6 and getting the following errors:

Undefined symbols for architecture arm64:
  "_png_get_io_ptr", referenced from:
      cocos2d::(anonymous namespace)::pngReadCallback(png_struct_def*, unsigned char*, unsigned long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_error", referenced from:
      cocos2d::(anonymous namespace)::pngReadCallback(png_struct_def*, unsigned char*, unsigned long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_WebPInitDecoderConfigInternal", referenced from:
      cocos2d::Image::initWithWebpData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_WebPGetFeaturesInternal", referenced from:
      cocos2d::Image::initWithWebpData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_WebPDecode", referenced from:
      cocos2d::Image::initWithWebpData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_TIFFGetField", referenced from:
      cocos2d::Image::initWithTiffData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "__TIFFmalloc", referenced from:
      cocos2d::Image::initWithTiffData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_TIFFReadRGBAImageOriented", referenced from:
      cocos2d::Image::initWithTiffData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_TIFFClose", referenced from:
      cocos2d::Image::initWithTiffData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_jpeg_read_header", referenced from:
      cocos2d::Image::initWithJpgData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_read_end", referenced from:
      cocos2d::Image::initWithPngData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_jpeg_read_scanlines", referenced from:
      cocos2d::Image::initWithJpgData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_get_valid", referenced from:
      cocos2d::Image::initWithPngData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_set_strip_16", referenced from:
      cocos2d::Image::initWithPngData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_create_read_struct", referenced from:
      cocos2d::Image::initWithPngData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_get_image_height", referenced from:
      cocos2d::Image::initWithPngData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)
  "_png_set_packing", referenced from:
      cocos2d::Image::initWithPngData(unsigned char const*, long) in libcocos2dx iOS.a(CCImage-480BC5818CB61150.o)

I guess this is related to libpng_arm64.a kind of libraries that I have in the project (cocos2d/external/$libname/prebuild) and I have the appropriate setting in link flags for arm64 -lpng_arm64.
Also the warning:

ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _jinit_arith_decoder from /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/evolution2048/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos/libcocos2dx iOS.a(jdarith.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

When I build the same project with xCode 5 - all working fine, I do not see this link errors and that warning.

Do you guys see this kind of problem before?

Please provide the output from the linker to see the paths and settings used.
It seems it cannot locate your lib.

Regarding the warning:
Look for the following build setting Dont create position independent executables.
The default setting was change througoutt different Xcode versions.

You mean this thing:
Ld DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/IntermediateBuildFilesPath/coolGame.build/Release-iphoneos/coolGame.build/Objects-normal/arm64/coolGame normal arm64
cd /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk -L/Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos -L/Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac -L/Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/ios/Chartboost -L/Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/ios/GA -F/Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos -F/Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/ios -filelist /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/IntermediateBuildFilesPath/coolGame.build/Release-iphoneos/coolGame.build/Objects-normal/arm64/coolGame.LinkFileList -dead_strip -ObjC -stdlib=libc++ -fobjc-link-runtime -miphoneos-version-min=7.0 -framework CoreImage -framework ImageIO -lsqlite3 -framework MediaPlayer -framework UIKit -framework OpenGLES -framework CoreMotion -lz -framework CoreData -framework AdSupport -framework SystemConfiguration -framework Social -framework CoreGraphics -framework StoreKit -framework CoreMedia -framework Security /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos/libbox2d\ iOS.a /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos/libchipmunk\ iOS.a -lGoogleAnalyticsServices /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos/libcocos2dx\ iOS.a -framework Chartboost /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos/libcocos2dx-extensions\ iOS.a /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/BuildProductsPath/Release-iphoneos/libCocosDenshion\ iOS.a -framework Foundation -framework CoreGraphics -lz -framework QuartzCore -framework OpenAL -framework AVFoundation -framework AudioToolbox -Xlinker -dependency_info -Xlinker /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/IntermediateBuildFilesPath/coolGame.build/Release-iphoneos/coolGame.build/Objects-normal/arm64/coolGame_dependency_info.dat -o /Users/fredgolm/Projects/helloWCocos/helloWorld/proj.ios_mac/DerivedData/coolGame/Build/Intermediates/ArchiveIntermediates/releaseBuild/IntermediateBuildFilesPath/coolGame.build/Release-iphoneos/coolGame.build/Objects-normal/arm64/coolGame

Yes. But it seems it’s not the full log. Look out for the paths given to -L and the setting -lpng_arm64 in the log.
If it’s not there and/or the path is missing, where libpng_arm64.a resides in, you have to include that path.

Also check if you added -lpng_arm64 to all your targets, and you are not building for a target you missed to set the flag by accident.

2 Likes

You were right, I added -lpng_arm64 flags to target and added path to libraries and it worked well.
So I basically duplicated these settings from libcocos2dx project and I think this is a bit wierd, because libpng should be part of cocos2d library.
Anyway, solved, thank you!

hello,

can you please help me with a step by step tutorial about that. where do i have to set this flag?

thank you!

Sorry for late reply. Normally you would have this flags set for cocos2d iOS subproject. With latest xCode 6.0 I had to set them for the each iOS target, otherwise it was linking error as you can see above. Below is the screenshot:

2 Likes

omg… many flags there. ok i will try this out! :slight_smile: thank you for you reply!

ok i found it!

all you have to do is add the libs again to the cocos2dx_iOS target!

no other flags needed to set. In my case this helped

iQD mentioned right, but not to all targets. only the cocos2dx_iOS target

4 Likes

what is wrong with hand drawn selection? i’m not good in photoshop… :S

1 Like

Thanks for the solution. I wrote a more step-by-step tutorial in my blog based on the hints posted here: http://becomingindiedev.blogspot.com.es

1 Like

Thanks a lot for the step by step tutorial man. It was so helpful.

thx! good to know! :slight_smile: