出错内容:
videomonitor.cpp:(.text+0x2704): undefined reference to `jpeg_std_error(jpeg_error_mgr*)'
videomonitor.cpp:(.text+0x271c): undefined reference to `jpeg_CreateCompress(jpeg_compress_struct*, int, unsigned int)'
videomonitor.cpp:(.text+0x274c): undefined reference to `jpeg_set_defaults(jpeg_compress_struct*)'
videomonitor.cpp:(.text+0x275c): undefined reference to `jpeg_set_quality(jpeg_compress_struct*, int, int)'
videomonitor.cpp:(.text+0x2768): undefined reference to `jpeg_start_compress(jpeg_compress_struct*, int)'
videomonitor.cpp:(.text+0x279c): undefined reference to `jpeg_write_scanlines(jpeg_compress_struct*, unsigned char**, unsigned int)'
videomonitor.cpp:(.text+0x27b4): undefined reference to `jpeg_finish_compress(jpeg_compress_struct*)'
videomonitor.cpp:(.text+0x27bc): undefined reference to `jpeg_destroy_compress(jpeg_compress_struct*)'
单独把这些函数写在一个.c的文件里用gcc(arm-linux-gcc)编译是没有问题的,用Qt creator编译x86版本也没错,但用qmake命令交叉编译arm版本就出现上面的错误(库和头文件都已经放进编译器的相关目录里)。请问是什么原因呢?
------解决方案--------------------
extern "C" {
#include <jpeglib.h>
}
用extern "c" 把 jpeg 有关的头文件包含进来
Some users feel that it's easier to call the library from C++ code if you
force VC++ to treat the library as C++ code, which you can do by renaming
all the *.c files to *.cpp (and adjusting the makefile to match). This
avoids the need to put extern "C" { ... } around #include "jpeglib.h" in
your C++ application.
------解决方案--------------------
-ljpeg
------解决方案--------------------
应该是你连接的库是X86上的库,但是你交叉编译需要连接ARM上的库,所以你需要先得到ARM上的libjpeg
库,就是先交叉编译得到libjpeg,然后再交叉编译你的程序连接时就不会有问题了。