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

Crash using static library #5

Open
vbergae opened this issue Apr 27, 2011 · 2 comments
Open

Crash using static library #5

vbergae opened this issue Apr 27, 2011 · 2 comments

Comments

@vbergae
Copy link

vbergae commented Apr 27, 2011

Hi, if I use FontLabel inside a static library the class FontLabel crashes on line 156:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ZAttributedString sizeConstrainedToSize:lineBreakMode:numberOfLines:]: unrecognized selector sent to instance 0x633e670'

In another hand if I use FontLabel without static library, inside the main project, works great.

Any ideas?

@lilyball
Copy link
Owner

You're running into object file stripping. The simplest way to fix this is to tack -all_load onto your linker flags. You could also try -ObjC, but last I checked that flag didn't work correctly. You can try it yourself, they may have fixed it. You can also try -force_load path_to_archive if you don't want to use -all_load, but I'm not sure what the exact path needs to be. It may be something you can't easily figure out before building.

The basic problem here is ld omits object files from archives that don't appear to be used at link-time. This doesn't work with Obj-C, because of its dynamism. The -ObjC flag is supposed to instruct ld to always load object files that contain Obj-C data, but as I said before, it seems to be broken. -all_load tells ld to load all object files (note, dead code stripping can still strip out unused functions so it's not as bad as it sounds), and -force_load path_to_archive can tell ld to load all object files from the specified archive.

@lilyball lilyball reopened this Apr 27, 2011
@lilyball
Copy link
Owner

This StackOverflow answer might be interesting as well.

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

2 participants