在Visual Studio 2010中使用LibTiff

4

我正在尝试在Visual Studio 2010的C++程序中使用LibTiff。 我从ftp://ftp.remotesensing.org/pub/libtiff下载了tiff-3.9.2.zip。为了测试LibTiff,如果有人能够给我一步一步的说明如何将libtiff导入Visual Studio并构建Fax2Tiff工具,那就太好了。

有这么多文件,我完全被搞糊涂了。

我已经做了什么:

1)创建了一个名为“TiffTest”的新空Win32控制台应用程序项目。

2)将tiff-3.9.2.zip中的“libtiff”文件夹复制到项目文件夹中。

3)将文件“fax2tiff.c”复制到项目文件夹中。

4)将这些文件添加到项目中。

alt textalt text

5)将“libtiff”文件夹添加到附加包含文件夹中。

6)将文件“tif_config.vc.h”和“tiffconf.vc.h”重命名为“tif_config.h”和“tiffconf.h”。

7)尝试编译。

这并不真正起作用。 我所做的一切都是为了摆脱错误消息,却引起了新的错误消息。 有人能告诉我如何让libtiff起作用吗?

我真的需要帮助……

非常感谢!


你最好下载二进制文件。你试过这个链接吗?它还有一些安装说明:http://gnuwin32.sourceforge.net/packages/tiff.htm - BeeBand
1
下次请截取错误列表的屏幕截图。 - Hans Passant
如果你只需要libtiff的基础知识,你可以使用nuget中的软件包!这会让入门变得更加容易。 - HEvTH
1个回答

3

我认为以下做法会更好:

  • 将libtiff构建为静态库。
  • 将fax2tiff构建为控制台应用程序,并链接到该库。

此外,您需要决定要在库的版本中使用哪个与文件和内存相关的文件。有适用于文件和内存相关文件的Unix、DOS 和 Windows 风格版本。

对于fax2tiff,您可能需要使用 Windows 版本的 getopt.cgetopt.h 文件。您可以使用在 koders.com 上找到的 wingetopt.hwingetopt.c

我成功地使用了 libtiff-3.9.4 和使用这种方法构建的 tiff2pdf。

顺便提一下,libtiff 版本 3.9.4 是 3.x 分支中最新的版本。

下面是我的 LibTiff.vcxproj 的一部分。它显示了在使用 Visual Studio 2010 在 Windows 上构建 libtiff 所需的文件。

<ItemGroup>
    <ClInclude Include="t4.h" />
    <ClInclude Include="tiff.h" />
    <ClInclude Include="tiffconf.h" />
    <ClInclude Include="tiffio.h" />
    <ClInclude Include="tiffiop.h" />
    <ClInclude Include="tiffvers.h" />
    <ClInclude Include="tif_config.h" />
    <ClInclude Include="tif_dir.h" />
    <ClInclude Include="tif_fax3.h" />
    <ClInclude Include="tif_predict.h" />
    <ClInclude Include="uvcode.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="tif_aux.c" />
    <ClCompile Include="tif_close.c" />
    <ClCompile Include="tif_codec.c" />
    <ClCompile Include="tif_color.c" />
    <ClCompile Include="tif_compress.c" />
    <ClCompile Include="tif_dir.c" />
    <ClCompile Include="tif_dirinfo.c" />
    <ClCompile Include="tif_dirread.c" />
    <ClCompile Include="tif_dirwrite.c" />
    <ClCompile Include="tif_dumpmode.c" />
    <ClCompile Include="tif_error.c" />
    <ClCompile Include="tif_extension.c" />
    <ClCompile Include="tif_fax3.c" />
    <ClCompile Include="tif_fax3sm.c" />
    <ClCompile Include="tif_flush.c" />
    <ClCompile Include="tif_getimage.c" />
    <ClCompile Include="tif_jbig.c" />
    <ClCompile Include="tif_jpeg.c" />
    <ClCompile Include="tif_luv.c" />
    <ClCompile Include="tif_lzw.c" />
    <ClCompile Include="tif_next.c" />
    <ClCompile Include="tif_ojpeg.c" />
    <ClCompile Include="tif_open.c" />
    <ClCompile Include="tif_packbits.c" />
    <ClCompile Include="tif_pixarlog.c" />
    <ClCompile Include="tif_predict.c" />
    <ClCompile Include="tif_print.c" />
    <ClCompile Include="tif_read.c" />
    <ClCompile Include="tif_strip.c" />
    <ClCompile Include="tif_swab.c" />
    <ClCompile Include="tif_thunder.c" />
    <ClCompile Include="tif_tile.c" />
    <ClCompile Include="tif_unix.c" />
    <ClCompile Include="tif_version.c" />
    <ClCompile Include="tif_warning.c" />
    <ClCompile Include="tif_write.c" />
    <ClCompile Include="tif_zip.c" />

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接