Visual Studio 2008 c++链接器拒绝链接?
我在这里用头撞墙。
我想要的只是在 cpp Windows 窗体应用程序中链接静态 .lib 文件!因此,我的项目文件夹中有一个包含文件夹,其中包含该 .lib 的头文件(如果有人想知道,lib 是 Yaml-cpp)。我有一个 lib 文件夹,其中包含该库的 .lib 文件。
我在一个空白项目
1上测试了它。我在VS2008中用C++创建了一个新的Windows窗体项目。
2.我转到项目属性 - c/c++ 常规和附加包含目录,其中包含 yaml-cpp 头文件
3.我转到链接器并添加我的 lib 目录的路径
4.我转到链接器 - 输入并添加我的 .lib 文件
5.我检查链接器命令行,它包含我的 .lib 文件,因此它必须已全部设置。
6.然后我在onbutton函数体中编写示例代码(出现在form1.h fie中)。
示例代码来自此处 http://code.google.com/p/yaml- cpp/wiki/HowToParseADocument 和它一样简单:
#include <fstream>
#include "yaml.h"
然后:
std::ifstream fin("test.yaml");
YAML::Parser parser(fin);
YAML::Node doc;
while(parser.GetNextDocument(doc)) {
//do nothing yet
}
7.然后我编译并有 10 个“未解析的外部”。
我研究了另一个使用相同库的项目,它具有完全相同的目录结构,在链接器 - 输入 - 附加依赖项中添加了相同的 .lib 名称,相同的 .lib 和 .h 文件。它适用于该项目 - 但它不适用于我。
世界上到底有什么问题呢?
编辑:我尝试制作新的 Windows 32 控制台应用程序,它工作正常。然后我尝试制作另一个新的 Windows 窗体应用程序,但失败了。
现在已经确认了。链接库的相同步骤在控制台应用程序中有效,但在 Windows 窗体应用程序中失败。为什么?
I am banging my head against a wall here.
All i want is to link a static .lib file in a cpp windows forms application! So, i have an include folder in my project folder that holds header files for that .lib (lib is Yaml-cpp if someone wonders). And i have a lib folder that has the .lib files for that library.
I tested it on a blank project
1.I make a new windows forms project in VS2008, in C++.
2.I go to project properties - c/c++ general and additional include directories that have yaml-cpp header files
3.I go to linker and add path to my lib directory
4.I go to linker - input and add my .lib file
5.I check linker command line and it contains my .lib file so it must be all set.
6.Then i write the sample code in an onbutton function body (which appears in form1.h fie).
Sample code is from here http://code.google.com/p/yaml-cpp/wiki/HowToParseADocument and its just as simple as:
#include <fstream>
#include "yaml.h"
and then:
std::ifstream fin("test.yaml");
YAML::Parser parser(fin);
YAML::Node doc;
while(parser.GetNextDocument(doc)) {
//do nothing yet
}
7.And then i compile and have 10 "unresolved externals".
I have looked into another project that uses same library, and it has exactly same directory structure, same name of .lib added in linker - input - additional dependencies, same .lib and .h files. And it works for that project- but it doesnt work for me.
What in the world is wrong?
EDIT: I tried making new windows 32 console application and it worked correctly. I then tried to make another fresh windows forms application and it failed.
It is confirmed now. Same steps for linking a library work in console application and fail in windows forms application. WHY?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的解释来看,您所做的似乎是正确的,让我们进行一些盲目的故障排除。
请阅读这篇有关解决无法解析的外部符号错误的 Microsoft 文章。
希望有帮助!
What you've done seems correct from your explanation, let's do some blind troubleshooting.
libyaml-cppmdd.lib
and its include file, check whether the header file that gets included is of the same version as the lib.Please read this Microsoft article on Troubleshooting UnResolved External Symbol error.
Hope it helps!