Reputation: 34416
Coming from a .Net background, and being pretty new to C and C++, I'm unsure about the implications of linking static third-party libraries when some of them are 64 bit and others are only targeting x86.
In my case, I'm doing some experiments with FreeGLUT, Glew and FreeType. Glew appears to only come in a 32 bit flavour. FreeGLUT comes with both 64 bit and a 32 bit lib builds, and FreeType only has a 32 bit build. I want to build my application targeting x64 because I'll be doing a lot of work with 8 byte numeric values, but overall I'm not too savvy with the differences in coding for x86 vs x64, or what it means to mix libraries from the two. I know that if I build my application targeting x86 then I clearly can't use x64 libs, but I have a feeling that the inverse is not true. Am I right? Are there any traps to avoid? Given that the Glew build I have is 32 bit but the FreeGLUT build is x64, can I expect them to work together at all?
Edit: I found this page to be useful: https://msdn.microsoft.com/en-us/library/ew5tede7.aspx - given that the active architecture affects how memory is allocated on the stack, it makes sense that trying to work with two different memory models in the same stack frame would not work.
Upvotes: 1
Views: 2512
Reputation: 489
This is not possible. When you link against a library the platform and architecture must match. Mainly the issue is how memory laid out in x86 vs x64
This thread explains further LNK2001 and LNK1120 when compiling a x64 dynamic library linking a x86 static library
Upvotes: 2