6

I had the same problem as here fatal error C1034: windows.h: no include path set

I typed vcvars32.bat and that solved my problem but I want to link some 64-bit .lib files and when I do:

cl main.cpp xxxlib.lib

I get:

warning LNK4272: library machine type 'x64' conflict with target machine type 'x86'

Is it because I use the vcvars32.bat is 32 bits? Where can I find the 64 bit version?

Thanks

Community
  • 1
  • 1
sspp
  • 65
  • 1
  • 6
  • use the 64-bit command line. Basically its just setting the path so the 64-bit compiler is used. Alternatively you could call it with the full path. Remember you might need the other environment variables to set the include and lib paths correctly too. – gbjbaanb Aug 05 '16 at 13:46
  • @gbjbaanb I have the .lib files in the same folder as my project so that is not a problem. Sorry I know is a bit stupid question but where can I find the 64'bit cmd line ? – sspp Aug 05 '16 at 13:58
  • Press "Start" and type "VS", you should see a bunch of "*VS20xx Native Tools Command Prompt*" shortcuts (one for x86 and one x64). – rustyx Aug 05 '16 at 14:01
  • Also try using `/MACHINE:X64` linker flag. – rustyx Aug 05 '16 at 14:03

1 Answers1

3

In order to make sure you have the proper environment variables set, the simplest way is to launch the respective command shell in the start menu.

For 64bit, this would be Visual Studio x64 Win64 Command Prompt (2010), then cl.exe is automatically correct. If you show the properties of this entry in the start menu, you'll also find more infos:

  • Start in: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\"
  • Target : %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" amd64

From this, you see that the working directory is set, and vcvarsall.bat is called with the amd64 parameter. This is probably what you missed.

dhaumann
  • 1,590
  • 13
  • 25
  • Amazing, thanks a lot. But do you know how can I make that a default configuration.The reason why I'm asking this is because I'm going to execute this command from Python using `os.system()`. – sspp Aug 05 '16 at 14:24
  • I think you are trying to accomplish the same as here: http://stackoverflow.com/questions/14697629 Maybe the replies there already help? – dhaumann Aug 05 '16 at 14:30
  • That's it. You are saving my life today :) – sspp Aug 05 '16 at 14:33
  • Glad I could help. – dhaumann Aug 05 '16 at 14:37