Building two libs on OS X Mavericks - Dependent lib wants x86_64 when dependency is i386, and i386 when dependency is x86_64
Hi folks,
I'm currently trying to get libRocket working on my OS X machine. libRocket has a dependency on Freetype2, so I'll need that as well. As far as I can tell, Freetype is not packaged as part of the OS X 10.9 SDK, but please correct me if I'm wrong.
I grabbed the latest version of Freetype (2.5.3) and built it (using CMake to generate a Unix Makefile). I ran "make install" after building and everything went smoothly. When I went to the libRocket source, I ran CMake (configuring it to point at /usr/local/include/freetype2 as necessary) and generated another Makefile. Running 'make', I ran into this issue:
ld: warning: ignoring file /usr/local/lib/libfreetype.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/libfreetype.a
Undefined symbols for architecture i386:
"_FT_Done_Face", referenced from:
Rocket::Core::FontDatabase::LoadFace(unsigned char const*, int, Rocket::Core::StringBase<char> const&, bool) in FontDatabase.cpp.o
Rocket::Core::FontFace::~FontFace() in FontFace.cpp.o
Rocket::Core::FontFace::ReleaseFace() in FontFace.cpp.old: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So, obviously Freetype built for x86_64, right? So I went back to my Freetype directory, set CMake to build for i386, generated a Makefile, make, make install, and back to libRocket.
After building clean, libRocket's build gave me the same linker errors, but now it was complaining about freetype not providing x86_64 bits. It seems like no matter what architecture I target for Freetype, libRocket's build complains about the opposite architecture.
Has anyone run into an issue like this when building libraries? I don't think it's specific to how these two libraries interact, but it's really hard to craft a search query for this issue without getting standard linker error help instead.
Thanks in advance for any help!
EDIT: This has been fixed. The issue, and the reason the architecture keeps swapping, is because libRocket was building as a universal binary. This means that if I built Freetype for one library, libRocket naturally complained about missing the other. The fix is to have both! See this issue thread for more detail.
Posted Mar 9, 2014, 11:27 PM UTC · edited
From the error you posted to me it seems like you are linking i386 and the library is built for another architecture.
Are you building both architectures into separate paths? Also make sure you don't have some preprocessor define overriding the architecture you are trying to build. Perhaps putting your make files on paste bin might offer some insight.
That's the oddity about this whole thing. If I build the library for i386 instead (by changing the architectures property in the CMake configuration), then the error will be the same, but complaining about x86_64 instead. I would expect that if it tries to link to an architecture, then I could solve the problem by building the dependency for that architecture, but that's not what happens.
I'm building one architecture at a time and installing it to the same place (/usr/local), overwriting the previous library.
Putting the Makefiles on PasteBin wouldn't be all that helpful since they're generated using CMake (or autotools for Freetype). If you grab Freetype 2.5.3 then the CMakeLists.txt (and the Makefile that it drops) will be available to you. If you prefer that I put the CMakeLists.txt on PasteBin then I'd be happy to do so.
The CMake file for libRocket is available in its build folder.
Is there anything else I could provide to help debug the issue? This is blocking me from any development on my project that depends on libRocket, so if there's anything that I can do, please let me know.
Long time since I've posted this question, but I wanted to follow up with you about the solution. The target library (libRocket) was built for both i386 and x86_64. That's why one would always be missing. I needed to build Freetype for both architectures simultaneously in order to fix the issue.
Thank you for taking a stab at this issue. :)