Eclipse 无法链接到 kernel32.lib
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13135992/
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
Eclipse can't link to kernel32.lib
提问by Itamar
I've installed Eclipse CDT so I'll be able to write and compile C code.
我已经安装了 Eclipse CDT,因此我将能够编写和编译 C 代码。
The compilation progress fails and the following error appears:
编译进度失败,出现如下错误:
LNK1104 : cannot open file kernel32.lib
I've been searching for this file in my computer and found out it appears in some folders,
我一直在我的电脑中搜索这个文件,发现它出现在一些文件夹中,
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
How could I "refer" eclipse to one of this certain paths so the kernel32.lib
file will be found and I'll be able to compile and run C
files?
我怎么能“引用” eclipse 到这些特定路径之一,以便kernel32.lib
找到文件并且我将能够编译和运行C
文件?
EDITThanks to @mux answer the LNK1104 : cannot open file kernel32.lib
is now gone , but a new error appears now : LNK1104 : cannot open file 'C:\Program.lib'
.
Once again, any suggestion will be helpful.
编辑感谢@mux 回答 LNK1104 : cannot open file kernel32.lib
现在已经消失了,但现在出现了一个新错误: LNK1104 : cannot open file 'C:\Program.lib'
。再一次,任何建议都会有所帮助。
回答by Shivendra
i wasted a lot of time on this... this is the answer you are searching for
我在这上面浪费了很多时间......这就是你正在寻找的答案
In Eclipse > Project > Properties > Paths and Symbols > Libraries tab, enclose the path to the library in single quotes:
在 Eclipse > 项目 > 属性 > 路径和符号 > 库选项卡中,将库的路径用单引号括起来:
'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\Kernel32.Lib'
'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\Kernel32.Lib'
There would be a warning that the path does not exist, but it should be gone after you rebuild your project.
会出现路径不存在的警告,但在您重建项目后它应该消失了。
回答by naoufelabs
I've the same problem, I've fixed because of installed Microsoft Visual Studio 2010 on my computer:
我有同样的问题,我已经解决了,因为我的电脑上安装了 Microsoft Visual Studio 2010:
- Right click on your
C/C++ project -> Properties -> C/C++ Build -> Environment
- In
LIB
, click on the ButtonEdit
on the right side - Add
;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
<----;
to separate the first auto detected path"
- 右键单击您的
C/C++ project -> Properties -> C/C++ Build -> Environment
- 在
LIB
,点击Edit
右侧 的按钮 - 添加
;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
<----;
以分隔第一个自动检测到的路径"
* Must be on the both Debug and Release configuration : else you'll get the same error *
* 必须在 Debug 和 Release 配置上:否则你会得到同样的错误 *
回答by iabdalkader
you need to add the path to the library to your project, from the FAQ
您需要从常见问题解答中将库的路径添加到您的项目中
Go to Your Project's Properties by right clicking on project's name and selecting properties. Click on "C/C++ Build". Under Tool Settings Tab, click on Directories. Click on The Add Button and Select FileSystem. Select the folder with C/C++ libraries. Apply and then Ok. The new library is included.
通过右键单击项目名称并选择属性,转到您的项目属性。单击“C/C++ 构建”。在工具设置选项卡下,单击目录。单击添加按钮并选择文件系统。选择包含 C/C++ 库的文件夹。申请然后确定。包括新库。
Edit:
编辑:
The wiki seems outdated, but I did find the options relevant to linking here:
维基似乎已经过时,但我确实在这里找到了与链接相关的选项:
C/C++ Build->Settings->Tool Settings tab
C/C++ 构建->设置->工具设置选项卡
you should add the include paths for headers (if any) to the compilerIncludes
and the libraries to the linkeroptions Libraries(-l)
and the library path to Library Search path (-L)
您应该将头文件(如果有)的包含路径添加到编译器Includes
,将库添加到链接器选项Libraries(-l)
,并将库路径添加到Library Search path (-L)
回答by LucianMLI
Go to:
"Project Properties>c/c++ Build>Settings>c++ Linker>Libraries"
Add library kernel32 and set search path to your library or set LIBRARY_PATH environment variable.
转到:
“Project Properties>c/c++ Build>Settings>c++ Linker>Libraries”
添加库 kernel32 并设置库的搜索路径或设置 LIBRARY_PATH 环境变量。
回答by saha
For "LNK1104 : cannot open file kernel32.lib" error you need to include path to kernel32.lib in Eclipse > Project > Properties > Paths and Symbols > Libraries tab
对于“LNK1104:无法打开文件 kernel32.lib”错误,您需要在 Eclipse > 项目 > 属性 > 路径和符号 > 库选项卡中包含 kernel32.lib 的路径
For LNK1104: cannot open file 'C:\Program.obj' error you need to make sure the path you provided earlier is inside single quote('). Reference
对于 LNK1104:无法打开文件 'C:\Program.obj' 错误,您需要确保您之前提供的路径在单引号 (') 内。参考
Hope this solves your problem.
希望这能解决您的问题。