Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when building for iOS #35

Closed
pyrosphere opened this issue Sep 22, 2014 · 22 comments
Closed

Warning when building for iOS #35

pyrosphere opened this issue Sep 22, 2014 · 22 comments

Comments

@pyrosphere
Copy link
Contributor

Hello, when building my cocos2d-x game project for iOS I get the following 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/user/Library/Developer/Xcode/DerivedData/Project/Build/Products/Debug-iphoneos/libcocos2dx iOS.a(jdarith.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

From the _jinit_arith_decoder and jdarith.o in the warning I'm deducing it originates from libjpeg (hence posting this issue in this repository). Also this error only occurs when building for a device and not the simulator, so maybe not all slices of libjpeg cause this.

I'm not really sure what is happening but it might be important - the app no longer builds as PIE which Apple doesn't like according to their documentation: https://developer.apple.com/library/ios/qa/qa1788/_index.html#/apple_ref/doc/uid/DTS40013354

@pyrosphere
Copy link
Contributor Author

I replaced jpeg/prebuilt/ios/libjpeg.a to a binary from libjpeg-turbo and this warning disappeared. This binary however doesn't include a slice for arm64.

After fixing the warning for libjpeg, the same warning appeared for libtiff:

ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in __TIFFMultiply32 from /Users/user/Library/Developer/Xcode/DerivedData/Project/Build/Products/Debug-iphoneos/libcocos2dx iOS.a(tif_aux.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

Replacing tiff/prebuilt/ios/libtiff.a also fixed the warning. There were no more warnings concerning PIE and now running "otool -hv" on the .app shows the PIE flag (it didn't before).

I don't know how libjpeg and libtiff are being compiled but it might be worth looking into it. Thanks.

@Zambiorix
Copy link

where did you get the libtiff.a library to replace the one in "tiff/prebuilt/ios/" ?

thanks!

@pyrosphere
Copy link
Contributor Author

I don't remember, sorry - I vaguely remember trying to compile it but not sure if I was successful or if I ended up grabbing a binary online.

@Zambiorix
Copy link

For those interested, grab the libs package from Imagemagick:
http://www.imagemagick.org/download/iOS/

And replace for cocos2d-x/external/jpeg and cocos2d-x/external/tiff both the include files and the prebuilt libs for ios with the ones from Imagemagick. Clean and rebuild and all should be fine. "otool -hv" shows PIE flag.

Don't forget, if you run "download-deps.py", those files are overwritten again ...

@pyrosphere
Copy link
Contributor Author

Those are great, thanks! They include armv64 and starting on February 1st 2015, new apps will require 64-bit support: https://developer.apple.com/news/?id=10202014a

lipo -info libtiff.a 
Architectures in the fat file: libtiff.a are: armv7 armv7s i386 x86_64 arm64 

lipo -info libpng.a 
Architectures in the fat file: libpng.a are: armv7 armv7s i386 x86_64 arm64

Edit: Actually I just tried them out in my project (which is using cocos2d-x 3.2) and I get the following error:

cocos2d: jpeg error: JPEG parameter struct mismatch: library thinks size is 488, caller expects 452

@Zambiorix
Copy link

did you copy all the headers ? (i think there is one additional header for jpeg)

@pyrosphere
Copy link
Contributor Author

I didn't, might have been that. Thanks.

@Zambiorix
Copy link

no worries

all works in my projects

@Zambiorix
Copy link

I thought non-PIE apps are not allowed on the appstore? I wonder why nobody of the regular cocos2d-x maintainers have noticed this problem.

I just moved to the latest 3.3rc0 and the problem still persists

@pyrosphere
Copy link
Contributor Author

Apple prefers PIE apps, but you can still submit a non-PIE app and it will probably be accepted - they might give you a warning about that though.

@Zambiorix
Copy link

Noticed the warning a long time ago, didn't submit a non-pie app for a while. Thought they would have forced it by now...

@Pstoppani
Copy link

I'm on cocos2d-x 3.3 and still get this warning. I tried the suggest libraries above and this did not fix it.

@zilongshanren
Copy link
Member

@Pstoppani
Hi, how could I reproduce this warning? Should I upload the app to AppStore or just compile it ?

@Pstoppani
Copy link

I created a simple project in 3.3 and ran it on my iPhone.

Pete

On Feb 4, 2015, at 5:49 PM, 子龙山人 notifications@github.com wrote:

@Pstoppani
Hi, how could I reproduce this warning? Should I upload the app to AppStore or just compile it ?


Reply to this email directly or view it on GitHub.

@Leandros
Copy link

Still persists in cocos2d-x 3.4.

PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _jinit_arith_decoder from /Applications/Cocos/frameworks/cocos2d-x-3.4rc1/prebuilt/ios/libcocos2d iOS.a(jdarith.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

@zilongshanren
Copy link
Member

@minggo
I found in our cpp-test project, the *Generate Position-Dependent Code" is disabled. Should we turn it on?

@minggo
Copy link
Contributor

minggo commented Apr 10, 2015

Yes please if it doesn't have any side-effect.

@stevetranby
Copy link

Shouldn't cpp-test be setup for best practice? Not working around this issue by setting it to YES, but rather keeping it as NO and fixing the issue with the core and 3rd party libraries?

@minggo
Copy link
Contributor

minggo commented Apr 10, 2015

@stevetranby
Yep, we should fix it in correct way.
Did you mean it is caused by the libraries?
If so, i think we should re-build them.

@zilongshanren
Copy link
Member

@stevetranby I will consider to compile all the 3rd party libraries with PIE flag. But now it doesn't has such a high priority.

@jonnyijapan
Copy link

Still seeing this in Cocos2dX 3.5. What do I do??

@zilongshanren
Copy link
Member

@jonnyijapan Fixed at #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants