【问题标题】:Process terminated with status 1进程以状态 1 终止
【发布时间】:2012-05-29 21:38:46
【问题描述】:

我正在处理 code::blocks 10.05,我想用 c/c++ 读取 TIFF 图像文件。为此,我使用的是 LibTiff 库,因此我将 tiffio.h 作为头文件包含在内。现在当我编译时,我收到一个错误“进程以状态 1 终止。我还给出了链接器的库的完整路径。

整个构建日志显示:

链接控制台可执行文件:bin\Release\tifff.exe

mingw32-g++.exe: E:\Image: 没有那个文件或目录

mingw32-g++.exe: Transforms\Libraries\tifflib\libs\libtiff: 没有那个文件或目录

进程以状态 1 终止(0 分 8 秒) 0 个错误,0 个警告

【问题讨论】:

  • 链接器没有找到库。您的目录树中的文件“tifflib\libs\libtiff”在哪里?
  • 感谢回复我的查询,我的文件在 E:\Image_Transforms\Libraries\tifflib\libs\libtiff 中......它是一个包含头文件的库......请帮助我...... .

标签: c++ c codeblocks


【解决方案1】:

鉴于您提供的输出,正如@gcbenison 所说,链接器似乎没有找到 libtiff。

此外,鉴于它显示了两行输出,我假设您的 libtiff 库位于“E:\Image Transforms\Libraries\tifflib\libs\libtiff”内,对吧?

好吧,Code::Blocks doesn't seem to like 带有空格的路径。因此尝试将“Image Transforms”重命名为“Image_Transforms”,更正 Code::Blocks 中的库路径,然后重试。

编辑:详细说明答案

另外,请确保您可以拥有已编译的 libtiff 库。我从GNUwin32 项目中下载了libtiff 3.8.2-1.exe 进行测试,它运行良好。尝试执行以下操作来构建使用 libtiff 的最小工作程序:

  • 在 C:\GnuWin32 中安装上述 libtiff 库。安装后,里面会有很多目录,包括bin、contrib、doc、include、lib等;
  • 在 Code::Blocks 中创建一个新的控制台应用程序项目;
  • 告诉 Code::Blocks 它是一个 C 程序;
  • 创建项目后,通过单击您的项目,然后单击“构建选项...”访问“构建选项”对话框;
  • 在“链接器设置”选项卡的“链接库”框架中,单击“添加”并添加 libtiff.dll.a。如果你在 C:\GnuWin32 中安装了 libtiff,你想要的库是 C:\GnuWin32\lib\libtiff.dll.a;
  • 在“搜索目录”选项卡中,您将:
    • 选择“编译器”选项卡并在其中添加“C:\GnuWin32\include”;
    • 选择“链接器”选项卡并在其中添加“C:\GnuWin32\lib”;
  • 在“构建选项”对话框中单击“确定”,现在一切都应该没问题了。

您现在可以尝试构建您的程序,看看构建是否成功。我用Graphics programming with libtiff, Part 2中的第一个例子作为测试程序:

#include <stdio.h>
#include <stdlib.h>
#include <tiffio.h>
int main()
{
  TIFF *output;
  uint32 width, height;
  char *raster;
  printf("Trying to write TIFF...\n");
  if((output = TIFFOpen("output.tif", "w")) == NULL){
    fprintf(stderr, "Could not open outgoing image\n");
    exit(42);
  }
  width = 42;
  height = 42;
  if((raster = (char *) malloc(sizeof(char) * width * height * 3)) == NULL){
    fprintf(stderr, "Could not allocate enough memory\n");
    exit(42);
  }
  TIFFSetField(output, TIFFTAG_IMAGEWIDTH, width);
  TIFFSetField(output, TIFFTAG_IMAGELENGTH, height);
  TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);
  TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
  TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, 8);
  TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, 3);
  if(TIFFWriteEncodedStrip(output, 0, raster, width * height * 3) == 0){
    fprintf(stderr, "Could not write image\n");
    exit(42);
  }
  TIFFClose(output);
  printf("TIFF written successfully.\n");
  return 0;
}

现在尝试构建 (Ctrl+F9) 并运行您的程序。我按照上面提到的步骤,编译并运行了我的程序。

对于构建,Code::Blocks 的输出是(我将我的程序命名为 libtiff):

-------------- Build: Debug in libtiff ---------------

Compiling: main.c
Linking console executable: bin\Debug\libtiff.exe
Output size is 27,93 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

为了运行,它输出:

Trying to write TIFF...
TIFF written successfully.

Process returned 0 (0x0)   execution time : 0.125 s
Press any key to continue.

【讨论】:

  • Thxx 先生.. 我已将其更改为 image_transforms 但仍然显示相同的错误。同样在为未知库设置上述路径后,在 project\properties\libraries 中,当我编译它时会出现 libfinder 错误,提示“没有找到库的配置并要求我进入检测对话框。现在当我去对话框显示上述路径缺少定义,并提供下载此缺少定义的选项,但是当我尝试下载此代码时::block 没有响应..:(:( 请帮帮我...有人请回复查询...提前谢谢..
  • Thxx 先生,它是一个 gr8 帮助。按照你提到的所有步骤并实施你的示例代码之后。它的构建是成功的,但我运行它,它给出了一个错误,说“程序无法启动bcoz libtiff3.dll 丢失”和构建日志显示“检查是否存在:E:\CBoutput\Tiffs\bin\Debug\Tiffs.exe 正在执行:“C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe”“E :\CBoutput\Tiffs\bin\Debug\Tiffs.exe" (在 E:\CBoutput\Tiffs\.) 进程以状态 -1073741510 (2 分 20 秒) 终止" & 再次感谢帮助我。上次请帮我解决这个问题。
  • 复制 E:\CBoutput\Tiffs\bin\Debug\Tiffs.exe 到 C:\GnuWin32\bin 来测试呢?这就是 libtiff3.dll 所在的位置,假设您将 libtiff 安装在 C:\GnuWin32 中。
  • 您好,先生。抱歉,由于某些技术故障,我的互联网中断了,所以很抱歉。正如您所说,我搬到了 C:\GnuWin32。当我尝试运行时,它再次被正确编译它给出了一个错误“应用程序无法正确启动”和构建日志说:检查存在:C:\ Program Files(x86)\ GnuWin32 \ bin \ CBoutput \ png1 \ bin \ Debug \ png1.exe Executing:“C :\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "C:\Program Files (x86)\GnuWin32\bin\CBoutput\png1\bin\Debug\png1.exe" (在 C:\Program Files (x86) \GnuWin32\bin\CBoutput\png1\.) 进程终止,状态为 -1073741510(3 分 28 秒)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-06
  • 2012-10-05
  • 1970-01-01
  • 2013-09-26
相关资源
最近更新 更多