我正在尝试交叉编译raspberryPi的演示。我使用的是CMake,但下面是linkng命令。重要的是libvgfont.a就在最后:
/home/justinvf/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/armlinux-gnueabihf-g++ CMakeFiles/CamHack.dir/opencv_demo.cpp.o -o CamHack -rdynamic /home/justinvf/raspi/rootfs/lib/libmmal_core.so /home/justinvf/raspi/rootfs/lib/libmmal_util.so /home/justinvf/raspi/rootfs/lib/libmmal_vc_client.so /hom\
e/justinvf/raspi/rootfs/lib/libvcos.so /home/justinvf/raspi/rootfs/lib/libbcm_host.so /home/justinvf/raspi/rootfs/lib/opencv/libopencv_highgui.so /home/justinvf/raspi/rootfs/lib/opencv/libopencv_core.so /home/justinvf/raspi/rootfs/lib/opencv/libopencv_imgproc.so /home/justinvf/raspi/rootfs/lib/opencv/libopencv_objdetect.so /home/justinvf/raspi/rootfs/lib/libo\
penmaxil.so /home/justinvf/raspi/rootfs/lib/libEGL.so -lpthread -lm -lrt /home/justinvf/raspi/rootfs/opt/vc/src/hello_pi/libs/vgfont/libvgfont.a -Wl,-rpath,/home/justinvf/raspi/rootfs/lib:/home/justinvf/raspi/rootfs/lib/opencv
我收到的关于未定义的引用的错误对我来说没有意义:
opencv_demo.cpp:(.text+0xc10): undefined reference to `gx_graphics_init(char const*)'
opencv_demo.cpp:(.text+0xc38): undefined reference to `gx_create_window(unsigned int, unsigned int, unsigned int, GRAPHICS_RESOURCE_TYPE_T, GRAPHICS_RESOURCE_HANDLE_TABLE_T**)'
opencv_demo.cpp:(.text+0xc54): undefined reference to `gx_create_window(unsigned int, unsigned int, unsigned int, GRAPHICS_RESOURCE_TYPE_T, GRAPHICS_RESOURCE_HANDLE_TABLE_T**)'
libvgfont.a肯定有这些引用:
nm -g /home/justinvf/raspi/rootfs/opt/vc/src/hello_pi/libs/vgfont/libvgfont.a | grep gx_graphics_init
000025d8 T gx_graphics_init
这是我的第一个交叉编译项目,所以我猜傻了。非常感谢一些帮助!
答案 0 :(得分:1)
libvgfont.a是一个用cc编译的C库。将extern“C”添加到vffont.h头文件可以解决问题。有关详细信息,请参阅https://stackoverflow.com/a/12994075/1704581