libtiff x64 Visual Studio 2017:链接器问题 [英] libtiff x64 visual studio 2017 : Linker Issue

查看:25
本文介绍了libtiff x64 Visual Studio 2017:链接器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试为 libtiff 使用 nuget 包:=> Package <=

I tried to use nuget package for libtiff : => Package <=

我写了一小段代码来读取多帧图像 tif 文件.

I wrote a little piece of code in order to read a multiframe image tif file.

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 不允许我做的事情.

I need to use libtiff, because i need to do some stuff with exif data of my image what OpenCV don't allow me to do.

问题是当我想编译时,我有链接器错误:

The problem is that when i want to compile, i have linker errors :

Error   LNK2001 unresolved external symbol inflateInit_ SIA <Path>	iff.lib(tif_zip.obj)    1   
Error   LNK2001 LNK2001 unresolved external symbol inflateInit_ SIA <Path>	iff.lib(tif_pixarlog.obj)   1   

我的 package.config 文件是这样的:

My package.config file is like that :

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="libtiff-msvc-x64" version="4.0.7.8808" targetFramework="native" />
</packages>

当我继续我的项目属性时,我没有看到任何包参数.我尝试将手动链接器选项添加到 .lib 文件,但我遇到了同样的问题.

When i go on my project properties, i don't see any packages parameters. I tried to add manualy linker options to .lib files, but i have the same issues.

推荐答案

<?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 包配置在上面.

Maybe dependency problems. My nuget packages config is above.

这篇关于libtiff x64 Visual Studio 2017:链接器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆