libtiff x64 visual studio 2017:链接器问题
libtiff x64 visual studio 2017 : Linker Issue
我尝试将 nuget 包用于 libtiff : => 包 <=
我写了一小段代码来读取多帧图像tif文件。
vector<Mat> LibTiffReader::ReadMultiframeTiff(std::string FilePath)
{
vector<Mat> Result;
TIFF* tif = TIFFOpen(FilePath.c_str(), "r");
if (tif)
{
//Si le tif est ouvert, on itère sur ce qu'il y'a dedans...
do
{
Mat Image;
unsigned int width, height;
uint32* raster;
// On récupère la taille du tiff..
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
uint npixels = width*height; // get the total number of pixels
raster = (uint32*)_TIFFmalloc(npixels * sizeof(uint32)); // allocate temp memory (must use the tiff library malloc)
if (raster == NULL) // check the raster's memory was allocaed
{
TIFFClose(tif);
cerr << "Could not allocate memory for raster of TIFF image" << endl;
return vector<Mat>();
}
if (!TIFFReadRGBAImage(tif, width, height, raster, 0))
{
TIFFClose(tif);
cerr << "Could not read raster of TIFF image" << endl;
return vector<Mat>();
}
Image = Mat(width, height, CV_8UC3); // create a new matrix of w x h with 8 bits per channel and 3 channels (RGBA)
// itterate through all the pixels of the tif
for (uint x = 0; x < width; x++)
for (uint y = 0; y < height; y++)
{
uint32& TiffPixel = raster[y*width + x]; // read the current pixel of the TIF
Vec3b& pixel = Image.at<Vec3b>(Point(y, x)); // read the current pixel of the matrix
pixel[0] = TIFFGetB(TiffPixel); // Set the pixel values as BGR
pixel[1] = TIFFGetG(TiffPixel);
pixel[2] = TIFFGetR(TiffPixel);
}
_TIFFfree(raster);
Result.push_back(Image);
} while (TIFFReadDirectory(tif));
}
return Result;
}
我需要使用 libtiff,因为我需要用我的图像的 exif 数据做一些 OpenCV 不允许我做的事情。
问题是当我想编译时,我有链接器错误:
Error LNK2001 unresolved external symbol inflateInit_ SIA <Path>tiff.lib(tif_zip.obj) 1
Error LNK2001 LNK2001 unresolved external symbol inflateInit_ SIA <Path>tiff.lib(tif_pixarlog.obj) 1
我的package.config文件是这样的:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="libtiff-msvc-x64" version="4.0.7.8808" targetFramework="native" />
</packages>
当我进入我的项目属性时,我没有看到任何包参数。我尝试将手动链接器选项添加到 .lib 文件,但我有同样的问题。
就像@ReturnVoid所说的那样,使用 nuget 包下载的库没有为我的系统正确编译。
要解决问题:
- 继续 libtiff 索引并下载最新版本。
-
进入下载目录并使用以下命令使用 cmake 生成它:
cmake -G "Visual Studio 15 2017 Win64"
-
完成后,使用Visual Studio 2017打开项目
-
构建调试和发布库(你可以在 libtiff 子目录中找到它)。
-
添加 \libtiff 作为包含目录。添加 \libtiff\Release 作为链接者的目录 将 tiff.lib 添加为链接库 添加要复制的预生成查询tiff.dll 和 tiffxx.dll 到输出目录。
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="libjpeg" version="9.0.1.4" targetFramework="native" />
<package id="libjpeg.redist" version="9.0.1.4" targetFramework="native" />
<package id="libtiff" version="4.0.6.2" targetFramework="native" />
<package id="libtiff.redist" version="4.0.6.2" targetFramework="native" />
<package id="libtiff-msvc14-x64" version="4.0.7.7799" targetFramework="native" />
<package id="zlib" version="1.2.8.8" targetFramework="native" />
<package id="zlib.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" targetFramework="native" />
<package id="zlib.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" targetFramework="native" />
</packages>
也许是依赖问题。我的 nuget 包配置在上面。
相关文章:
- 使用jsoncpp库时出现链接问题
- Cmake 链接问题:未定义对 Button::mousePressEvent(QGraphicsSceneMouseE
- 如何将GTest与CMake一起使用?遵循谷歌指南时的链接问题
- 未解决的外部链接问题
- 'make check' GLIBC 运行时的链接问题
- 在树莓派上用libtorch构建程序时的链接问题
- 野牛弹性链接问题
- 与 AWS 开发工具包的链接问题
- Qt & Firebase C++ SDK 在 iOS 上的链接问题
- 链接问题 boost::p ython::numpy.
- 与 32 位共享对象的链接问题
- 在单元测试项目中包括 .c 文件,并从多个 cpp 文件访问它而不会出现链接问题
- 安卓链接问题
- LLVM 传递链接问题:未定义的符号
- Cmake Mac OSX库链接问题:在Linux上进行编译,但在Mac上进行了编译
- 用libclang解析源文件 - 链接问题包括文件
- C / C++链接问题与非常简单的设置
- Zbar 在 vs2015 链接问题
- Vulkan + GLFW + Cmake在Linux环境下的链接问题
- TFS构建由于链接问题而失败