问题标签 [lnk2001]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
856 浏览

c++ - C++ 接口抛出未解决的外部符号错误

好吧,我有一个简单的问题,但实际上没有我在网上寻找的示例,只有相同示例的副本,它在一个文件中完成所有操作。我正在尝试制作一个界面和一种使用它的方法,如下例所示,但是当我编译时,我从 Visual Studio 中得到了未解决的外部符号错误。关于我做错了什么的任何想法?

IFoo.h

Foo.h

Foo.cpp

0 投票
2 回答
2311 浏览

c++ - Error LNK2001 while using my static library

I'm having LNK2001 issues while building my solution.

The solution has 3 projects, one of them if just a main that returns 0, so I'll exclude it from the problem.

One project (SerialPort) is a .lib that implements a class (SerialPort), while the other (SerialHost) simply creates an instance of SerialPort.

I'm thinking the problem is somewhere in the project settings of SerialHost. Here goes the SerialHost project code:

And building yields:

main.obj : error LNK2001: unresolved external symbol "public: unsigned long __thiscall SerialPort::init(unsigned long,char const *)" (?init@SerialPort@@QAEKKPBD@Z)

I've searched SO for answers and found no solution that cured my problem.

To set the project settings I followed this msnd walkthrough.

I also tried adding specifically the .lib to the Additional Dependencies in Linker-Input.

Then I read this SO thread, and setting the option "Treat wchar_t as build-in type (Properties->C/C++->Language-> ... ) to No still didn't work. I thought it would work because SerialPort::init is declared as

  • it thought the fault was with the use of the LPCTSTR type.

The SerialPort project builds OK (the init method is implemented in the .cpp).

I'm just beginning to work with my own static libs in VS so I may be doing some basic error here.

Thank you in advance for your help!


Additional Info:

I tried commenting out the init and using another method and it built just fine! This code:

in SerialHost just yields the error in init - if I comment init, no linking errors appear.

Here is the implementation for SerialPort

0 投票
3 回答
1670 浏览

c++ - 包含标头时的 C++ OpenGL LNK2001

我得到 28

错误 LNK2001:未解析的外部符号

消息。例如,我知道一个事实

在 _int_gl_exts.h 中,果然我包含了它。

我不知道这是否是一个问题,但我的错误消息中有三个下划线字符

而在文件中,它前面只有两个下划线。这是包含文件中的确切行

我直接从教程中提取了很多东西,即使我的包含和功能相同,我仍然遇到问题。如有必要,我会发布完整的代码,但是在这里停留了大约 2 天后我没有想法。

编辑:我实际上两者都有

以及我尝试更改链接器中的项目属性以将其添加到其他库中。

我的整个代码如下。我知道还有很多其他的东西需要改变,但这是我首先要克服的。

0 投票
2 回答
150 浏览

c - LNK2001,再次

我寻找了类似的问题,但唯一的主题可能是关于使用库的问题,我会避免这样做......这是我的问题,我收到了这个错误:

我正在使用 Visual Studio Professional 2008 开发 ac 程序。我有一个主文件和另一个包含我编写的所有函数的文件,myFunctions.h/c。问题是当我包含“myFunctions.c”时这些错误不会出现,而当我包含“myFunctions.h”时它们会出现。

我正在做我在大学时记得的事情(我现在更喜欢 matlab),这是

就在包含其他标头(stdlib、数学等)之后

有什么猜测吗?谢谢你

0 投票
1 回答
4273 浏览

visual-studio-2010 - 错误 LNK2019 和 LNK2001 与 VS2010 和 Qt 库

我正在尝试使用 VS2010((我在 windows7 x64 上工作)重现 Qt 示例“webbrowser”(来自 qt-everywhere-opensource-src-4.8.3/examples/activeqt/webbrwowser)。

所以,我将所有文件(.h 和 .cpp)从 webbrowser 文件夹复制到我的项目中。此外,在项目属性-->链接器-->输入-->附加指令中,我添加了以下库:

现在,当我按下调试按钮时,我得到了这些错误:

这是 main.cpp 文件:

我哪里错了??谢谢你的帮助!

0 投票
1 回答
726 浏览

visual-c++ - 创建犰狳 DLL 时未解决的外部符号错误

我正在尝试在 Win XP 上使用 VC++ 2010 创建Armadillo线性代数库的动态库,该库最初是一个仅包含标头的库。我创建了一个新项目,添加了源文件,并创建了一个 .def 文件,指定仅导出一个 Armadillo 函数(Col 类),但 Col 类出现 LNK2001 错误。我可以创建一个 main 并很好地使用 Col,所以我认为 Col 被正确包含。

我还尝试在函数定义上使用“__declspec(dllexport)”并编译,但由于使用 dumpbin 没有显示任何内容,因此函数未导出,并且我无法成功使用 .dll。我在这里错过了什么吗?

0 投票
1 回答
1001 浏览

c++ - LNK2001:无法解析的外部符号,当试图从另一个 DLL 调用对象的方法时

我有两个模块,每个模块都有自己的类和自己的对象。每个模块都被编译成一个 DLL。我想进行“跨 DLL”方法调用,具有指向另一个类的对象的指针,但链接器不允许这样做(MSVC++ 2008)。

进一步来说:

  • 有calledModule.cpp,有calledClass,以及这个类的对象(calledObject);类有calledMethod,我想调用它;模块被编译为 DLL 并成为(惊喜!)称为 Lib.dll。
  • 有callingModule.cpp,有callingClass;除其他外,该类具有属性,它是指向被调用对象的指针;模块被编译为DLL调用Lib.dll;calledObject 上的指针在构造函数中设置。

我能够编译整个代码。当链接器启动时,麻烦就来了。我得到以下信息:moduleCalling.obj:错误 LNK2001:未解析的外部符号“public:void __thiscall classCalled::methodCalled ...”

我不使用任何 declspec 的东西,所以什么都不会从 calledLib.dll 中导出。

我正在调用的方法(methodCalled)存在于实现中,它的原型在标头中正确声明。classCalled 是一个“基本”类,不是从任何东西继承的。此外,当我将 methodCalled 声明为虚拟...

我很难理解,为什么我不能以“正常”的方式从另一个 DLL 调用对象的方法?为什么将其声明为“虚拟”会有所帮助?有谁知道?我有一些猜测,但专家的回答将有助于理解这些东西。

PS:我使用的是 MSVC++ 2008。

谢谢!

更新:添加代码片段,它反映了代码的外观。

0 投票
1 回答
5278 浏览

c++ - C++/Qt - 从主窗口打开对话框 - 错误 LNK2019 - LNK2001:未解析的外部符号

基本上代码的目标是在单击按钮后打开一个包含 QWebView (带有一些内容)的对话框

这就是我所做的:

主窗口.h:

主窗口.cpp:

在线数据库.h:

在线数据库.cpp:

我有几个链接错误

请问有人可以帮忙吗?

0 投票
1 回答
875 浏览

windows-ce - wince上未解析的外部符号

尝试编译 wince 代码时收到此错误:

我链接到项目必要的文件,如:strmbase.lib。我试图查看 strmbase.lib 是否有 CTransInPlaceFilter 的 c'tor(如 error3),我发现它有,但不同:

我不能将 wchar_t* 转换为 short*。

我的特定“strmbase.lib”有问题还是我做错了什么?

谢谢!

0 投票
1 回答
1306 浏览

visual-studio-2010 - 链接 libtiff - LNK2001:无法解析外部符号 TIFFOpen

我在 64 位机器上使用 MSVS 2010。我使用设置文件安装了 tiff 库版本 3.8.2,更改了项目属性表:include - *\GnuWin32\include; 链接器 - *\GnuWin32\lib,输入 - libtiff.lib。但是 MSVS 2010 仍然给我链接器错误:

LNK2001:未解析的外部符号 TIFFOpen
LNK2001:未解析的外部符号 TIFFGetField
LNK2001:未解析的外部符号 TIFFIsTiled

(因为我的一个源文件中的函数调用)。

我也尝试将包含目录添加到我的环境变量 Path 中,但无济于事。我还下载了 tiff-4.0.3.zip 并按照 libtiff 网站上的说明从命令提示符构建了库。我相应地更新了项目属性表:包括 - *\libtiff; 链接器 - *\libtiff,输入 - libtiff.lib,libtiff_i.lib。我什至将 libtiff.dll 复制到 *\Windows\system 和 *\Windows\system32 目录,并将 *\libtiff 目录添加到我的环境变量 Path 中。但是,MSVS 2010 仍然给我同样的错误。

我在网上搜索过,似乎没有人遇到过这样的问题,或者对于那些在不同库中遇到过类似问题的人,解决方案是我上面尝试过的。我现在已经花了将近两天的时间,并且迫切需要解决方案。请帮忙!