在 Debian 下“调试 cximage”通常分几种情况:
下面按最常见场景给你一套实用流程。
Debian 官方仓库一般没有 cximage 包,通常是源码编译。
检查是否有头文件:
ls /usr/include/cximage.h
ls /usr/local/include/cximage.h
如果没有,需要自己编译(见下)。
sudo apt update
sudo apt install build-essential g++ make cmake
常见来源:
git clone https://github.com/pedro-vicente/cximage.git
cd cximage
关键:加 -g -O0
cmake -DCMAKE_BUILD_TYPE=Debug .
make
或手动 g++:
g++ -g -O0 -I. -c *.cpp
#include <cximage.h>
#include <stdio.h>
int main() {
CxImage img;
if (!img.Load("test.jpg", CXIMAGE_FORMAT_JPG)) {
printf("load failed\n");
return 1;
}
printf("width=%d height=%d\n", img.GetWidth(), img.GetHeight());
return 0;
}
g++ -g -O0 main.cpp -o test \
-I/path/to/cximage \
-L/path/to/cximage -lcximage
gdb ./test
常用命令:
run
bt # 崩溃时看调用栈
break main
step
print img
如果崩溃在 cximage 内部:
bt full
img.Load("a.png", CXIMAGE_FORMAT_PNG);
undefined reference说明没链接库:
-lcximage
或静态链接:
libcximage.a
通常是:
用 gdb 定位:
run
bt
部分版本支持:
img.SetVerbose(true);
或宏:
#define CXIMAGE_DEBUG
cximage 已多年不活跃,在 Debian 上调试成本高。
更推荐:
你可以告诉我:
我可以直接帮你定位。