LNK1181: cannot open input file - visual-studio

I've successfully generated a 64-bit library called "myLibrary.lib" in project A using Visual Studio 2010.
Now I've another project B that uses "myLibrary.lib". I include the header files required to use "myLibrary.lib" in project B. Added the .lib into my project and added an entry for it in Linker>Input>Additional Dependencies.
When I try to build, I get an error "LINK : fatal error LNK1181: cannot open input file myLibrary.lib".
Things I've tried:
Tried to the path of my .lib file in Linker>General>Additional
Library Directories
If I do this, then I get unreferenced function errors for the ones I'm using from .lib
Tried giving my .lib name in quotes along with full path in
Linker>Input>Additional Dependencies
If I do this, then I get unreferenced function errors for the ones I'm using from .lib
Made sure there are no spaces in my lib name
Checked file permissions
Tried building on Visual Studio 2017 and still get same error
Is there anything else that I can try to workaround this error?

Based on the things you have tried, it seems you are going in the right direction. Few months ago, I have faced this problem in my VS 2010. I am getting an error like this
Error 1940 error LNK1181: cannot open input file 'element.lib'
I could not understand, whats going on, The file that the program is search for element.lib is there in that folder, but I do not understand, why it is showing error, then I tried few more things, as listed below
Either disable incremental linking, by going to
-> Project Properties
-> Configuration Properties
-> Linker (General)
-> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"
cvtres.exe, file error in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cvtres.exe and one at C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cvtres.exe, Make sure you are using the latest version in both of these locations.
This one is tricky, another possible cause for LNK1181 is that a long file name with embedded spaces was not enclosed in quotation marks. In that case, the linker will only recognize a file name up to the first space, and then assume a file extension of .obj. Make sure the file name length including the file path is less than the characters specified for windows OS, i.e. 128characters including spaces...

Related

Migrating code from VS 2005 to 2013 causes error LNK1104 error?

I'm attempting to migrate a solution file from VS 2005 to VS 2013. The majority of the projects within the solutions rebuilt just fine.
However, some of the projects are coming up with the error:
error LINK1104: cannot open file 'mfc80.lib'
I have searched for mfc80.lib on my computer and it does not exist.
I cannot follow the solution from here fatal error LNK1104: cannot open file 'gdi32.lib' because the file does not exist, therefore I cannot add its path in "Additional Library Directories".
I have:
Deleted all the .obj and .lib files for the problematic project
Ensured Visual C++ MFC MBCS Library for Visual Studio 2013 is installed
Followed Error LNK1104 cannot open file ';.obj'
What else do I need to check?
Thanks.
It appears your project is attempting to include mfc80.lib explicitly. This is the version that VS2005 used; you need mfc120.lib.
Also, double-check that none of your source has a declaration like the following: #define _MFC_FILENAME_VER

fatal error lnk1104: can't open LNKn.tmp

When I'm trying to build my MSVC2010 project with Bamboo's Visual-Studio task, I get the following error:
LINK : fatal error LNK1181: File "C:\Windows\system32\config\systemprofile\AppData\Local\Temp\lnk7A64.tmp" could not be opened.
msdn hast this to say:
If the given file is named LNKn, which is a filename generated by the linker for a temporary file, the directory specified in the TMP environment variable may not exist, or more than one directory is specified for the TMP environment variable. (Only one directory path should be specified for the TMP environment variable.)
So I checked my TMP variable and it has only one directory, which does exist.
Actually there is even a file generated, just not the right one.
So for example, I start the build, lnk7A64.tmp is created, but the linker looks for lnk7A64.tmp
I only get this error with Bamboo. It works fine with Visual Studio.
Any ideas as to why that happens and how to resolve it?
UPDATE:
I'm beginning to think this may be, because Bamboo can't find the executables needed for creating the right files (ressource compiler maybe). I've described this here before. I thought I could work around that problem, but it seems like it's causing this error too.
I had the same issue (which brought me to your question!). I figured out that by default, the bamboo agent service runs as "SYSTEM" and this did not jive with my build. Follow this guide from Atlassian to change the user that your bamboo agent runs as. I did this and it works now.
https://confluence.atlassian.com/display/BAMBOO/Running+Bamboo+service+on+Windows+as+the+local+user
I was running into a very similar issue:
C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp\lnk{A20CED18-5FC6-4AB0-84C2-B922E8CD543B}.tmp(1): error RC2135: file not found: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp\lnk{E2128AA4-9E0E-48D0-814E-22F9FDD938F9}.tmp [C:\bamboo_home\xml-data\build-dir\Sources\VS2017\Core\Core.vcxproj]
Turns out the build server was using the x86 version of MSBuild at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
Instead of the x64 version at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\MSBuild.exe
Ugh!

Dll project doesn't build as Linker not able to find the same named .lib file

I am a newbie in the Visual Studio 2010 environment. I got a source base which was developed using Visual Studio 2008. I am trying to build it in VS 2010; but the build fails as the Linker says the error - LINK : fatal error LNK1181: cannot open input file X.lib'.
Here X is the name of the lib file created from the same project and X.dll is the output dll. In fact the X.lib is not present in the project. Without succesfully building the project, it won't come at all for the Dll to build succesfully. How can I resolve this "Deadlock" kind of situation?
Thanks in advance,
Shiju
I had this problem also. When converting a working VS2008 project to VS2010, the Link phase breaks in the VS2010 project with the same error. It is trying to link the .lib that the project is supposed to be building!
I found the source of my problem: The project has a custom build step that occurs at the end of the build, before the PostBuildEvent. This custom build step copies the .dll, .lib and .pdb from $(OutDir) to an external location.
The Outputs List for the custom build step is set to the full path to the copied .dll, .lib and .pdb, e.g.:
C:/a_new_location/myproject.dll;
C:/a_new_location/myproject.lib;
C:/a_new_location/myproject.pdb.
I found that whenever this Outputs List includes the .lib, that .lib gets added to list of files to link in the link phase. So with the above Outputs List, the link phase will have a file list of:
myprojectfile1.obj
myprojectfile2.obj
C:/a_new_location/myproject.lib
And that causes the link to fail:
LINK : fatal error LNK1181: cannot open input file 'C:\a_new_location\G4SrcCfgLib.lib'
It does not matter if the copy in the custom build step actually copies the file or not. All that matters is that the Outputs List includes the .lib. So, I resolved the problem by removing the .lib from the Outputs List, of course. The downside to this is that doing a Clean build will not clean C:/a_new_location/lib. But at least it builds.

Cannot open include file "d3dx9.h"

Edit: Of course, immediately after working on it for an hour then posting here, I found the stupid mistake...
I'm getting compiler errors when trying to #include <d3dx9.h> in a project. I'm receiving "fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory".
I do have the DirectX SDK installed (I also just tried reinstalling it to no avail).
In the Project Properties:
VC++ Directories are set to "$(DXSDK_DIR)Include;$(IncludePath)" and "$(DXSDK_DIR)Lib\x86;$(LibraryPath)" for Include and Library directories respectively for all configurations—and the environment variable %DXSDK_DIR% points to C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\ as expected.
C/C++ > General settings has $(DXSDK_DIR)include listed in the Additional Include Directories
Linker > Input > Additional Dependencies has d3dx9d.lib included for Debug and d3dx9.lib included for Release configuration.
I am able to successfully compile and run tutorial projects from the DirectX Sample Browser.
Visual Studio's Intellisense/autocomplete will find d3dx9.h and suggest type and function names that are within the file (and not included through anything else I'm #includeing) so it seems that Intellisense can find it.
Any suggestions on what I'm forgetting or what else to try?
Thanks
you forgot one thing:
Go to VC++ Directories -> Library Directories
add $(DXSDK_DIR)LIB\x86
apply.
Done. Hope this helps
You should make sure you have ALL paths sorounded by quotes (").
Instead of $(DXSDK_DIR)include you should have "$(DXSDK_DIR)include"
I didn't realize that one of the other projects in the solution was #includeing a file that was #includeing a file that was #includeing d3dx9.h and I hadn't added those paths to that project.
/facepalm
Find the file on your computer, and add it's folder to the properties of your project.
Assuming you have visual studio: Properties/C/C++/General/Additional Include Libraries.
I tried all of these suggestions and none worked.
Turns out the $(DXSDK_DIR) variable doesn't work if you install DirectX while Visual Studio is still running. The solution for me was to restart Visual Studio (+ adding the paths in the solutions listed above, of course).

fatal error LNK1104 cannot open file C:\users\user\documents\visual.obj

I get a "fatal error LNK1104 cannot open file C:\users\user\documents\visual.obj" whenever I want to compile my project on Visual Studio 2008.
my project uses a .lib file that I created.
can anyone help me out ?
Thanks , guyz. I've found the solution to my problem. I had to add quotes around the path to my .lib file in Project->Properties->Configuration Properties->Linker->Input->Additional Dependencies .
Make sure that the directory C:\users\user\documents\ exists and that you have read/write access to it.
With this http://www.google.de/search?q=visual+studio+2008+LNK1104 I found this answer by http://social.msdn.microsoft.com/Forums/en-US/user?user=einaros.
You need to add the DirectX library folder to Visual Studio's search path. See the "Directories" settings under Tools -> Options -> Projects and Solutions. Otherwise the linker will not know where to find d3dx9.lib.

Resources