Visual-studio – compiling C++ static library for 64 bit windows platform using VS2008

64-bitcvisual studio

ith Visual Studio 2008, If the configuration type is a static library, I dont see a linker option in project properties. I need to specify /MACHINE:x64 option for a static library. I tried to specify this in command line option in Librarian. Only then I could build the static library. If I dont specify /MACHINE compiling the static lib fails with
LNK1112: module machine type 'X86' conflicts with target machine type 'x64' ( even if I set the platform to X64 for my solution).

With /MACHINE:X64 specified as command line through Project-Properties-Librarian, the static library was built but other project (of configuration type : DLL) in the same solution has a dependency on the static lib, when the DLL is built and tries to use one of the functions in the lib I again get the same error:

fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

Please suggest, how do I build a 64 bit static library

Best Answer

For what it's worth, I've come across this exact same issue.

I have a project that compiles a static library, and creating an "x64" configuration did NOT get it actually targeting x64. I had to explicitly add "/MACHINE:X64" as an "additional option" under "Librarian -> Command Line" in the project's property pages, just as you did.

I would expect visual studio to expose this setting as a first-class property in the property pages, as it does for dynamic libraries (under "Linker -> Advanced -> Target Machine"). Perhaps I'm missing something.

Related Topic