C++ Visual Studio 2010 - 链接:致命错误 LNK1181:无法打开输入文件“■/.obj”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4000772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2010 - LINK : fatal error LNK1181: cannot open input file " ■/.obj"
提问by Les
I have VS 2010 on Windows 7. I create a new project, chose c++ language, Win32 project, DLL, Export symbols, then finish. Now when I compile the project without any changes to what VS generates, I get...
我在 Windows 7 上安装了 VS 2010。我创建了一个新项目,选择了 c++ 语言、Win32 项目、DLL、导出符号,然后完成。现在,当我编译项目而不对 VS 生成的内容进行任何更改时,我得到...
LINK : fatal error LNK1181: cannot open input file "?■/.obj"
链接:致命错误 LNK1181:无法打开输入文件“?■/.obj”
I also have VS 2008 install on the same machine. I follow the same steps and it compiles. What am I doing wrong?
我也在同一台机器上安装了 VS 2008。我按照相同的步骤进行编译。我究竟做错了什么?
EditOkay, I've discovered that this error is due to an old version of the linker being used. I am not sure why. In VS2010, the project directories are set differently than in VS2008. Once I figure that out, maybe I can solve my own problem.
编辑好的,我发现这个错误是由于使用了旧版本的链接器。我不知道为什么。在 VS2010 中,项目目录的设置与 VS2008 不同。一旦我弄清楚了,也许我可以解决我自己的问题。
采纳答案by Les
Well it has been a while since posting this questions. I figured out a workaround awhile ago, so now I am going to answer it myself. But if you have any better ideas or additional info others could benefit from, please post.
好吧,自从发布这个问题以来已经有一段时间了。我前一段时间想出了一个解决方法,所以现在我要自己回答。但是,如果您有更好的想法或其他人可以从中受益的其他信息,请发布。
I found that after creating my C++ project, I need to remove the "Microsoft.Cpp.Win32.User" property sheets. If I don't, then I get the strange error above, but if I delete them, the simple project compiles fine. To delete them...
我发现在创建我的 C++ 项目后,我需要删除“Microsoft.Cpp.Win32.User”属性表。如果我不这样做,那么我会收到上面的奇怪错误,但是如果我删除它们,那么简单的项目就可以正常编译。要删除它们...
- Select View->Other Windows->Propery Manager
- Expand the property group (the name of your project)
- Expand all configurations (mine are "Debug|Win32" and "Release|Win32")
- Multi-select all "Microsoft.Cpp.Win32.User" property sheets (one under each configuration)
- Delete
- 选择查看->其他窗口->属性管理器
- 展开属性组(您的项目名称)
- 展开所有配置(我的是“Debug|Win32”和“Release|Win32”)
- 多选所有“Microsoft.Cpp.Win32.User”属性表(每个配置下一个)
- 删除
回答by Mark
Visual Studio 2012 - LINK : fatal error LNK1181: cannot open input file “ ■/.obj” I'm using VS 2012!!!!
Visual Studio 2012 - 链接:致命错误 LNK1181:无法打开输入文件“■/.obj” 我正在使用 VS 2012!!!!
I have tracked this down a bit more. For me, this does NOT happen when I try to build the x64 bit version of my application. I have found that my project .vcxproj has an 'ImportGroup Condition' that looks like this:
我已经追踪了更多。对我来说,当我尝试构建应用程序的 x64 位版本时不会发生这种情况。我发现我的项目 .vcxproj 有一个“ImportGroup Condition”,如下所示:
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
I also have one for my x64 build that looks like this:
我的 x64 版本也有一个如下所示:
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
So I took a look at the files:
于是我查看了文件:
Users\??????????\AppData\Local\Microsoft\MSBuild\v4.0
Microsoft.Cpp.Win32.user.props
Microsoft.Cpp.x64.user.props
The difference is that the of each is different. x64 is basically empty while Win32 has three paths in it.
不同之处在于每个的不同。x64 基本上是空的,而 Win32 中有三个路径。
The section of the Win32 version, contains three paths, <ExecutablePath>
, <IncludePath>
, and <LibraryPath>
.
Win32 版本的部分包含三个路径<ExecutablePath>
,<IncludePath>
、 和<LibraryPath>
。
I HAVE FOUND that removing the <ExecutablePath>
path causes this problem to go away. I am looking deeper into that path to see if anything pops out at me, but I thought I'd pass it along in case any others can find what is wrong with that path.
我发现删除<ExecutablePath>
路径会导致这个问题消失。我正在更深入地研究那条路径,看看是否有什么东西突然出现在我身上,但我想我会传递它,以防其他人发现这条路径有什么问题。
回答by MNS
Me too came across the same problem while compiling a VC++ project in Visual Studio 2017. The compiler complained the following.
我在 Visual Studio 2017 中编译 VC++ 项目时也遇到了同样的问题。编译器抱怨如下。
LINK : fatal error LNK1181: cannot open input file "?■/.obj"
LINK : fatal error LNK1181: cannot open input file "?■/.obj"
Up on analyzing the issue, it is found that project "Configuration Properties - VC++ Directories - Executable Directories" as shown below contained a path to Microsoft Visual Basic folder C:\Program Files (x86)\Microsoft Visual Studio\VB98
which has its own link.exe
.
在分析该问题时,发现如下所示的项目“配置属性 - VC++ 目录 - 可执行目录”包含指向 Microsoft Visual Basic 文件夹的路径,C:\Program Files (x86)\Microsoft Visual Studio\VB98
该文件夹具有自己的link.exe
.
The linker error occurred due to the fact that Visual Studio was invoking Visual Basic linker rather than Visual C++ linker!
由于 Visual Studio 正在调用 Visual Basic 链接器而不是 Visual C++ 链接器,因此发生链接器错误!
This happened because path to Visual Basic linker is listed firstin the above dialog and hence Visual Studio encountered Visual Basic linker.exe first while going through path to Executable Directories.
发生这种情况是因为在上面的对话框中首先列出了 Visual Basic 链接器的路径,因此 Visual Studio 在遍历可执行目录的路径时首先遇到了 Visual Basic linker.exe。
One of the solution is to update order of inclusion of path in Executable Directories by moving path to VB98 folder from firstto last. It can be achieved by editing required property file(s) such as Microsoft.Cpp.Win32.user.props
present in $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0
directory.
其中一个解决办法是在可执行文件目录包含路径的更新以便通过移动路径VB98文件夹第一到最后。它可以通过编辑所需的属性文件(例如目录中的Microsoft.Cpp.Win32.user.props
现有文件)来实现$(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0
。
回答by Pierre
In my case (VS 2017), I had to delete the following entries in Linker -> Additional dependencies:
就我而言(VS 2017),我必须删除 Linker -> Additional dependencies 中的以下条目:
\
$(INHERIT)\
Possibly added by Qt pre-processor.
可能由 Qt 预处理器添加。