我的项目中需要JPEG处理功能所以我决定使用jpeg-8d库,在下载了我通常使用的包./configure; make and make install
之后。 make test
没有返回任何错误,并且在整个过程中没有报告任何问题,但是当我在代码块10.05中打开example.c
时,编译失败。我已经“搜索”了一些解决方案并添加了
#ifdef __cplusplus
extern "C" {
#endif
...
#ifdef __cplusplus
}
#endif
在jpeglib.h
文件中,重新编译,然后将这些行添加到代码块的链接器部分:
/usr/local/lib/libjpeg.a
/usr/local/lib/libjpeg.so
还根据目录添加到目录部分。
但是编译器仍然无法编译example.c,这里有一些错误:
> /home/raff/CodeBlocks/jpeg-8d/example.c|116|warning: incompatible implicit declaration of built-in function ‘exit’|
> example.c|| undefined reference to 'image_width'
> example.c|| undefined reference to 'image_height'
如果有人成功安装并使用了jpeg库请帮忙,我在切换IDE和/或linux发行版方面没有问题。
答案 0 :(得分:1)
你的库的安装似乎没问题(否则它会抱怨在编译期间遗漏jpeglib.h
)
文件example.c
应该是文档的一部分,而不是您可以编译和使用的代码。请注意,例如,没有main()
。您应该将它用作如何编码压缩和解压缩jpeg文件的方法的参考。
变量image_width
和image_height
(和image_buffer
)声明为extern
,因此假定它们在其他文件中定义。您可以编写定义这些变量的程序并填充缓冲区,然后才能使用提供的方法(write_JPEG_file
和read_JPEG_file
)。
答案 1 :(得分:0)
答案 2 :(得分:0)
我非常确定example.c实际上是使用这个库的一个例子,我没有检查它的内容。此外还有一些问题。 写完正确的程序后,我遇到了一个错误:
error while loading shared libraries libjpeg.so.8: cannot open shared object file: No such file or directory
但这是由这对shell命令修复的:
ranlib /usr/local/lib/libjpeg.a
ldconfig /usr/local/lib
希望这有帮助。