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

Linker problem: file was built for archive which is not the architecture being linked #11

Closed
paresy opened this Issue Apr 8, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@paresy
Copy link

paresy commented Apr 8, 2014

I have a problem with the linker, which i was unable to resolve in the last days. It might be a bug within the linker or my configuration, but i am stuck and digging in the linker source code is the least favorite thing i'd like to do...

At first: The same test works on OSX when using clang++ instead of o64-clang++

Building the library is fine. Compiling and linking the example fails with the following errors:

ld: warning: ignoring file ../build/libJsonBox.a, file was built for archive which is not the architecture being linked (x86_64): ../build/libJsonBox.a
... lots of undefined reference errors
ld: symbol(s) not found for architecture x86_64

I have used ranlib on the library. I have checked the architecture with otool/lipo and everything looks just right. It is definitly X86_64.

You can use this small test to verify the problem. (Same happens if you statically compile Boost and then want to link to it)

git clone https://github.com/paresy/JsonBox -b test jsonbox
cd jsonbox
make CXX=o64-clang++
cd examples
o64-clang++ main.cpp -I../include -L../build -lJsonBox

Any hints would be really appreciated.

Michael

@tpoechtrager

This comment has been minimized.

Copy link
Owner

tpoechtrager commented Apr 8, 2014

You must use the correct ar (archiver), e.g.:

make CXX=o64-clang++ AR=x86_64-apple-darwin1X-ar

Otherwises it uses the system ar and won't work.

@paresy

This comment has been minimized.

Copy link

paresy commented Apr 8, 2014

Thanks! That fixes the problem. I should have thought about that...

And thank you for this great project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment