Visual Studio: LINK : fatal error LNK1181: cannot open input file

后端 未结 17 2748
盖世英雄少女心
盖世英雄少女心 2020-12-05 03:47

I\'ve been encountering a strange bug in Visual Studio 2010 for some time now.

I have a solution consisting of a project which compiles to a static library, and anot

相关标签:
17条回答
  • 2020-12-05 04:09

    You can also fix the spaces-in-path problem by specifying the library path in DOS "8.3" format.

    To get the 8.3 form, do (at the command line):

    DIR /AD /X
    

    recursively through every level of the directories.

    0 讨论(0)
  • 2020-12-05 04:10

    I found a different solution for this...

    Actually, I missed comma separator between two library paths. After adding common it worked for me.

    Go to: Project properties -> Linker -> General -> Link Library Dependencies At this path make sure the path of the library is correct.

    Previous Code (With Bug - because I forgot to separate two lib paths with comma):

    <Link><AdditionalLibraryDirectories>..\..\Build\lib\$(Configuration)**..\..\Build\Release;**%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
    

    Code after fix (Just separate libraries with comma):

    <Link><AdditionalLibraryDirectories>..\..\Build\lib\$(Configuration)**;..\..\Build\Release;**%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
    

    Hope this will help you.

    0 讨论(0)
  • 2020-12-05 04:11

    I had a similar problem in that I was getting LINK1181 errors on the .OBJ file that was part of the project itself (and there were only 2 .cxx files in the entire project).

    Initially I had setup the project to generate an .EXE in Visual Studio, and then in the Property Pages -> Configuration Properties -> General -> Project Defaults -> Configuration Type, I changed the .EXE to .DLL. Suspecting that somehow Visual Studio 2008 was getting confused, I recreated the entire solution from scratch using .DLL mode right from the start. Problem went away after that. I imagine if you manually picked your way through the .vcproj and other related files you could figure out how to fix things without starting from scratch (but my program consisted of two .cpp files so it was easier to start over).

    0 讨论(0)
  • 2020-12-05 04:12

    In my case I had the library installed using NuGet package (cpprestsdk) AND I falsely added the lib to the Additional Dependancies in the Linker settings. It turns out, the package does it all for you.

    The linker then tried to find the library in the library path and of course could not find it.

    After removing the library from the Additional Dependencies everything compiled and linked fine.

    0 讨论(0)
  • 2020-12-05 04:13

    I had the same issue in both VS 2010 and VS 2012. On my system the first static lib was built and then got immediately deleted when the main project started building.

    The problem is the common intermediate folder for several projects. Just assign separate intermediate folder for each project.

    Read more on this here

    0 讨论(0)
  • 2020-12-05 04:16

    In Linker, general, additional library directories, add the directory to the .dll or .libs you have included in Linker, Input. It does not work if you put this in VC++ Directories, Library Directories.

    0 讨论(0)
提交回复
热议问题