[英]Linker error LNK2019 when using DCMTK with Visual Studio
This is not a new question but the solutions haven't worked for me. 这不是一个新问题,但解决方案对我没有用。 I want to read dicom files using C++.
我想用C ++阅读dicom文件。 I have 32-bit Windows PC with VS 2013 community edition.
我有32位Windows PC与VS 2013社区版。
This post and other answers therein suggested using DCMTK. 其中的帖子和其他答案建议使用DCMTK。 I installed DCMTK (using CMake followed by VS) and configured it for use with VS using guidelines and links provided in this post .
我安装DCMTK(使用CMake的后面VS),并将其配置为使用中提供指导和链接VS利用这个职位 。 Then I wrote a simple test program and tried to compile it:
然后我写了一个简单的测试程序并尝试编译它:
#include "stdafx.h"
#include "dcmtk\dcmdata\dctk.h"
#include "dcmtk\config\osconfig.h"
#include "dcmtk\dcmimgle\dcmimage.h"
#include <iostream>
using namespace std;
int main()
{
DicomImage *image = new DicomImage("test.dcm");
if (image != NULL)
{
if (image->getStatus() == EIS_Normal)
{
if (image->isMonochrome())
{
image->setMinMaxWindow();
Uint8 *pixelData = (Uint8 *)(image->getOutputData(8 /* bits */));
if (pixelData != NULL)
{
/* do something useful with the pixel data */
}
}
}
else
cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << endl;
}
delete image;
return 0;
}
Upon compilation, it gives the following error: 编译时,它会出现以下错误:
dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z)
This error seems to be common but none of the following solutions work for me: 此错误似乎很常见,但以下解决方案均不适合我:
FAQ#27 and another post of DCMTK forum: It suggests using particular order of lib files to be included. FAQ#27以及DCMTK论坛的另一篇文章 :它建议使用特定的lib文件顺序。 My order of including files is as follows (I tried the reverse order as well but it didn't work):
我的包含文件的顺序如下(我也尝试了相反的顺序,但它不起作用):
All of this doesn't work. 所有这一切都行不通。 In fact, I'm not sure which lib files are supposed to be included?
事实上,我不确定应该包含哪些lib文件? How to decide that?
怎么决定?
I've also included "C:\\Program Files\\DCMTK\\lib" under additional library directories and "C:\\Program Files\\DCMTK\\include" under additional include directories in project properties. 我还在其他库目录下包含“C:\\ Program Files \\ DCMTK \\ lib”,在项目属性中包含其他包含目录下的“C:\\ Program Files \\ DCMTK \\ include”。
Can someone please guide? 有人可以指导吗?
NetBios函数驻留在NETAPI32.LIB中,因此您可以尝试将NetAPI32.lib(位于列表中)移动到该列表的顶部。
Not sure which version of the DCMTK you use, but for the current development snapshot you need the following standard libraries (on Windows): "ws2_32 netapi32 wsock32". 不确定您使用的是哪个版本的DCMTK,但对于当前的开发快照,您需要以下标准库(在Windows上):“ws2_32 netapi32 wsock32”。 This information can be found in DCMTK's CMake files.
此信息可在DCMTK的CMake文件中找到。 By the way, you don't seem to use CMake for your project, right?
顺便说一句,你似乎没有为你的项目使用CMake,对吗?
I think you misspelled dcmsign.lib as dcmsig.lib. 我认为你将dcmsign.lib拼错为dcmsig.lib。
If changing that doesn't fix it, I would suggest the following order based on the support page that you linked to: NetAPI32.lib WSock32.lib ofstd.lib oflog.lib dcmdata.lib dcmsign.lib dcmnet.lib dcmsr.lib dcmqrdb.lib dcmtls.lib dcmwlm.lib dcmimgle.lib dcmpstat.lib dcmjpls.lib dcmjpeg.lib dcmimage.lib ijg16.lib ijg12.lib ijg8.lib 如果更改不能解决问题,我建议根据您链接到的支持页面建议以下顺序:NetAPI32.lib oflog.lib的stock.lib的WSock32.lib dcmdata.lib dcmsign.lib dcmnet.lib dcmsr.lib dcmqrdb .lib dcmtls.lib dcmwlm.lib dcmimgle.lib dcmpstat.lib dcmjpls.lib dcmjpeg.lib dcmimage.lib ijg16.lib ijg12.lib ijg8.lib
I think that in this list, each library has to come after all the libraries that it depends on. 我认为在这个列表中,每个库都必须在它依赖的所有库之后。
检查你的.lib和vs平台是否相同,例如x64的lib,那么你的vs平台必须是x64。
I had the same error. 我有同样的错误。 You can go to project properties-> linker -> input -> Additional Dependencies-> Edit -> add these two libraries-( netapi32.lib,wsock32.lib) before all other libraries .
您可以转到项目属性 - >链接器 - >输入 - >其他依赖项 - >编辑 - >在所有其他库之前添加这两个库 - (netapi32.lib,wsock32.lib)。 This solved the error for me .
这解决了我的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.