当我指定 dll 时找不到 lib 文件
我是 Visual C++ 的新手,对 C++ 很生疏。
我按照 Visual C++ 指示创建了一个 dll 项目。现在我想测试我的 dll 以确保它正常工作。我创建了一个空项目并放入 tester.cpp。我将 dll 添加到项目引用和路径中。然后我尝试运行它。
在我包含 dll 中的内容(“Hello world!”)之前,它是有效的。现在我已经放入了我的东西来引用 dll,但它失败了。消息是:
1>LINK : fatal error LNK1104: 无法打开文件 'C:\Users\thom\Documents\cworkspace\barnaby\Debug\barnaby.lib'
我不明白的是 dll 的参考链接存在于上面的路径中。这是我的代码:
#include <iostream>
#include <string>
#include <vector>
#include "barnaby.h"
int main(int argc, char *argv[]){
std::vector<std::string> tzNames = Barnaby::TimeZoneFunctions::getTimezoneList();
for(std::vector<std::string>::iterator iter = tzNames.begin(); iter != tzNames.end(); iter++){
std::cout << *iter << std::endl;
}
}
想法?
I'm new to visual c++ and rusty with c++.
I created a dll project following the visual C++ directions. Now I want to test my dll to make sure it's working. I created an empty project and put in tester.cpp. I added the dll to the project references and to the path. Then I try to run it.
Before I included stuff from my dll ("Hello world!") it worked. Now that I've put in my stuff to reference the dll, it fails. The message is:
1>LINK : fatal error LNK1104: cannot open file 'C:\Users\thom\Documents\cworkspace\barnaby\Debug\barnaby.lib'
The thing I don't understand is the reference links to the dll which exists at the path above. Here's my code:
#include <iostream>
#include <string>
#include <vector>
#include "barnaby.h"
int main(int argc, char *argv[]){
std::vector<std::string> tzNames = Barnaby::TimeZoneFunctions::getTimezoneList();
for(std::vector<std::string>::iterator iter = tzNames.begin(); iter != tzNames.end(); iter++){
std::cout << *iter << std::endl;
}
}
ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以我从 http://binglongx.wordpress.com/2009/01/26/visual-c-does-not-generate-lib-file-for-a-dll-project/哪个告诉我在 DLL 的标头中包含以下代码:
然后,我导出的每个函数只需在其前面添加:
通过单击新项目 DLL 向导上的“导出符号”框或对以下选项投票“是”,可以阻止所有这些情况应用程序员的脑白质切除术。
感谢您的帮助。
OK, so I found the answer from http://binglongx.wordpress.com/2009/01/26/visual-c-does-not-generate-lib-file-for-a-dll-project/ which told me to include the following code in my header for the DLL:
Then, each function I export you simply precede by:
All of this would have been prevented either by click the Export Symbols box on the new project DLL Wizard or by voting yes for lobotomies for application programmers.
Thanks for the help.