Compiling C++ Program Causes "Fatal Error LNK1104" - c++

I am trying to compile a c++ application using the following command in command prompt:
cl -I"c:\Program files\Java\jdk1.5.0_07\include" -I"c:\program files\java\jdk1.5.0_07\include\win32" -MD -LD HelloWorld.cpp -FeHelloWorld.dll
However, this produces the following error:
LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib'
Have you any ideas of what is causing this and how to fix it?
I have visual studio 2005 installed on windows.
Thanks,
-Pete

LINK : fatal error LNK1104: cannot open file 'MSVCRT.lib'
Any ideas of what is causing this and how to fix it?
The linker needs to be pointed to the location of MSVCRT.lib, as it doesn't seem to be in your LIBPATH.
It should be here: C:\Program Files\Microsoft Visual Studio 7\VC\lib
Add -link -LIBPATH:"C:\Program Files\Microsoft Visual Studio 8\VC\lib"

To Solve this Problem in MS Visual studio 2008.
Goto Menu Project->Properties (Alt+F7)
Configuration Properties
Linker -> General -> additional Library Directories -> C:\Program Files\Microsoft Visual Studio 9.0\VC\lib
....do the above steps and enjoy

In the command prompt run the following command
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
Then work in the same command prompt.

Related

LNK1181 cannot open input file

I have these errors on visual studio 2017 whenever i try to build/debug the project:
LNK1181 cannot open input file 'C:\Program Files\libuv\Release\lib\libuv.lib
And this warning dialog:
Unable to start program
xmrig-2.3.1\build\Debug\xmrig.exe
The project is here : https://github.com/xmrig/xmrig
How i can solve it? Thank you!
Update:
The path is like:
it's like C:\Program Files\libuv\libuv.lib in my computer not C:\Program Files\libuv\Release\lib\libuv.lib
How i can edit it in visual studio?

MPI microsoft command line compile x86 conflict link error

From the Developer Comand Prompt for VS 2013, I try to compile and link
a simple test MPI program.
Using the two batch files copied below, I type:
mpicc mpi
mpicl mpi
From the link step I get the following error message:
mpi.obj : fatal error LNK1112: module machine type 'X86' conflicts with target m
achine type 'x64'
I have been following the note on "How to compile and run a simple MS-MPI
program:" at:
http://blogs.technet.com/b/windowshpc/archive/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program.aspx
I see the (x86) which seems to conflict with the fact that I am compiling
sixty-four bits but I don't know what else to specify as that is where
MPI install put the files in question.
Here is the mpicc.bat batch file
cl /I"c:\Program Files (x86)\Microsoft SDKs\MPI\Include" /I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include\x64" /I /I"c:\program Files(x86)\Microsoft SDKs\windows\v8.1A\Include" /I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Include" /c %1.cpp
Here is the mpicl.bat batch file
link /machine:x64 /out:%1.exe /dynamicbase "msmpi.lib" /libpath:"c:\program Files (x86)\Microsoft SDKs\MPI\Lib\x64" /libpath:"c:\program files (x86)\Microsoft\Visual Studio 12.0\VC\LIB\amd64" /libpath:"c:\program files (x86)\Microsoft SDKs\Windows\v8.1A\x64" %1%.obj
I asked this question on askmpi#microsoft.com. They responded that I should
use a different command prompt in the Visual Studio Tools folder.
When I used the x64 Native Tools Command Prompt, the link step now works fine.

Visual Studio 2015 doesn't have cl.exe

I downloaded Visual C++ and Visual Studio, but I cannot find cl.exe to compile my C++ file. The path to the install is `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin.
Where can I find the compiler to compile C++ code?
Visual Studio 2015 doesn't install C++ by default. You have to rerun the setup, select Modify and then check Programming Language -> C++
In Visual Studio 2019 you can find cl.exe inside
32-BIT : C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\Hostx86\x86
64-BIT : C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\Hostx64\x64
Before trying to compile either run vcvars32 for 32-Bit compilation or vcvars64 for 64-Bit.
32-BIT : "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
64-BIT : "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
If you can't find the file or the directory, try going to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC and see if you can find a folder with a version number. If you can't, then you probably haven't installed C++ through the Visual Studio Installation yet.
For me that have Visual Studio 2015 this works:
Search this in the start menu: Developer Command Prompt for VS2015 and run the program in the search result.
You can now execute your command in it, for example: cl /?
For first need check is installed cl.exe,
open Developer Command Prompt for VS2015 and type "where cl"
When its founded on the PC need add $(VC_LibraryPath_x64), $(WindowsSDK_LibraryPath_x64) and $(NETFXKitsDir)Lib\um\x64 to Project->Properties->VC++ Directories

MSVC can't find its libs

For some purpose that is not really important I used MSVC 2012 in console mode (Windows 8x64) and when I tried to compile "Hello, World!" it didn't find its stabdard library and linker couldn't find some of its lib-files. So in the end I managed to configure both compile and link commands to make them work properly:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe" -c main.cpp /I
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include"
and for link:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe"
main.obj
/LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib"
/LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86"
To sum up I want to know, how can they be configured so that cl found its headers and link found those libs. Please consider that I'm going to use them in Qt Creator, where they don't work and I've just found a way of getting them to work but from outside of Creator and I need to do it by Creators' means (nmake or jom options that is).
You need to call
call %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
in your command line window. This sets up a usable environment.

Error "fatal error C1034: windows.h: no include path set"

OS Windows Vista Ultimate
I am trying to run a program called minimal.c. When I type at the command line:
C:\Users\nathan\Desktop>cl minimal.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
minimal.c
minimal.c(5) : fatal error C1034: windows.h: no include path set
I have set all the paths:
C:\Users\nathan\Desktop>path
PATH=C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin;C:\Windows\system3
;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\ATI Technologies\AT
.ACE\Core-Static;C:\Program Files\Intel\DMIX;c:\Program Files (x86)\Microsoft S
L Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Bi
n\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Java\jdk1.
.0_13\bin;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files (x86)\Co
mon Files\Autodesk Shared\;C:\Program Files (x86)\Microsoft DirectX SDK (March
009)\Include;C:\Users\nathan\Desktop\glut-3.7.6-bin\glut-3.7.6-bin;C:\Program F
les (x86)\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files (x86)\Microsof
Visual Studio 8\VC\PlatformSDK\Include;C:\Program Files (x86)\Microsoft Visual
Studio 8\VC\PlatformSDK\Include\gl
I have gone and made sure windows.h is in the directory. I'm setting the path too. It's
in C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Include.
I have Visual Studio 2005.
I have exhausted all possibilities. Any ideas?
You could also run the vcvars32.bat file from the directory C:\Program Files\Microsoft Visual Studio 8\VC\bin (this is in your path) prior to your cl command.
Like this:
C:\Users\nathan\Desktop>vcvars32
C:\Users\nathan\Desktop>cl minimal.c
vcvars32 calls C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat which sets up the required environment for compiling and linking.
The environment variables are INCLUDE, LIB, and PATH.
The compiler looks for header files in the INCLUDE path during compile, and libraries are fetched from the LIB path during link.
For me, with Visual Studio 2017,
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd.bat"
is the command to use before compiling with cl.
Here is the documentation.
When you started the command line, did you run the included command line shortcut that comes with the Visual Studio setup? This will set the correct environment variables for you so that the compilation will work correctly.
In your project folder, open a PowerShell window and run:
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && cl minimal.c '
You've added your INCLUDE paths to your PATH environment variable. Use vcvars32.bat as the others have suggested.
Your path variable might be too long. Windows can’t take more than 1023 characters in the PATH environment variable.
I had the same issue getting the
fatal error C1034: stdio.h: no include path set
and after running the C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build>vcvars64.bat cmd/batch script would get the
fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
error message. From here, and other posts on that page, I suspected that the Windows 10 SDK package must be installed. After installation and running the vcvars64.bat script from the path mentioned above, the problem was solved.
P.S. As explained here, an alternative to manually finding and running the above cmd/batch script, you may just do +Q and search for Developer Command Prompt for ..., in my case it is Developer Command Prompt for VS 2022.
if you have version 2017 of the compiler cl.exe (you installed Visual Studio 2017), in the command prompt you need go to "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build" and run 'vcvars32.bat' for x86 compilation or vcvars64.bat for x64 compilation.