I've created a new C++ project in Visual Studio 2008. No code has been written yet; Only project settings have been changed.
When I compile the project, I receive the following fatal error:
fatal error LNK1104: cannot open file 'C:\Program.obj'
I've created a new C++ project in Visual Studio 2008. No code has been written yet; Only project settings have been changed.
When I compile the project, I receive the following fatal error:
fatal error LNK1104: cannot open file 'C:\Program.obj'
This particular issue is caused by specifying a dependency to a lib file that had spaces in its path. The path needs to be surrounded by quotes for the project to compile correctly.
On the Configuration Properties -> Linker -> Input tab of the project’s properties, there is an Additional Dependencies property. This issue was fixed by adding the quotes. For example, changing this property from:
C:\Program Files\sofware sdk\lib\library.lib
To:
"C:\Program Files\sofware sdk\lib\library.lib"
where I added the quotes.
in my case it was the path lenght (incl. file name).
..\..\..\..\..\..\..\SWX\Binary\VS2008\Output\Win32\Debug\boost_unit_test_framework-vc90-mt-gd-1_57.lib;
as for the release the path was (this has worked correctly):
..\..\..\..\..\..\..\SWX\Binary\VS2008\Output\Win32\Release\boost_unit_test_framework-vc90-mt-1_57.lib;
==> one char shorter.
Linker -> input -> additoinal dependencies
so the problem for me was the total size of the path + filename string was too long!
I had the same error:
fatal error LNK1104: cannot open file 'GTest.lib;'
This was caused by the ; at the end. If you have multiple libraries, they should be separated by empty space (spacebar), no comma or semi-colons!
So don't use ; or any anything else when listing libraries in Project properties >> Configuration Properties >> Linker >> Input
I tried above solution but didnt work for me. So i rename the exe and rebuild the solution. It works for me.
I had this exact error when building a VC++ DLL in Visual Studio 2019:
LNK1104: cannot open file 'C:\Program.obj'
Turned out under project Properties > Linker > Input > Module Definition File, I had specified a def file that had an unmatched double-quote at the end of the filename. Deleting the unmatched double quote resolved the issue.
My issue was caused by other application using the .dll file I was trying to debug.
Closing the application that was using the .dll solved it for me.
Possible solutions:
Check if path contain any white spaces, Go to Properties > Linker > Input > additional path and include "path with white space"
If program are still running, close everything and restart.
Check if .obj file is not created. This happens when you directly build a project while Properties > C++ > Preprocessor > Generate preprocessor file is on. Turn it off and build the project then you can onn Properties > C++ > Preprocessor > Generate preprocessor file.
I had a similar problem. I solved it with the following command to kill the running task:
taskkill /f /im [nameOfExe]
/f: Forces the task to close. /im: The next parameter is a image name aka executable name e.g. Program.exe.
I hit the same problem with "Visual Studio 2013".
LNK1104: cannot open file 'debug\****.exe
It resolved after closing and re-starting Visual studio.