Reputation:
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
Upvotes: 9
Views: 12214
Reputation: 30862
As mentioned by Timbo, you need to ensure that you have an x64 configuration that you're building. However, there are a couple of other gotchas to be aware of:
Debug\Mylib.lib
then you're going to run into problems because the same name is being used for the 32 and 64 bit libraries. I prefer to select all configurations and all platforms and then rename them all to something standard like ..\build\$(ProjectName)\$(ConfigurationName).$(PlatformName)
module machine type 'X86' conflicts with target machine type 'x64'
means that the object file has been built as 32-bit but the link setting of the project is set with the flag /machine:x64
. So this suggests that the project configuration is 32-bit.If in doubt about what you've created, pick one of the object files and type this at a command prompt:
dumpbin /headers myfile.obj | findstr machine
This will show you the architecture you've actually built for.
Upvotes: 3
Reputation: 4089
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.
Upvotes: 8
Reputation: 28060
Did you try to add a new project configuration (x64) to the existing project?
You should usually not have to edit the project properties at all to build in 64bit. You just have to add the configurations and make sure the solution configuration is correct (64 bit solution configuration contains 64bit project configurations).
You can check this by opening Build->Configuration Manager. My Visual Studio sometimes messes with these settings and makes the project uncompilable, so checking it again might help.
Upvotes: 1