justinvf
justinvf

Reputation: 3109

Cross Compile not finding references

I'm trying to cross compile a demo for the raspberryPi. I'm using CMake, but below is the linkng command. The important part is that libvgfont.a is at the very end:

/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

I'm getting an error about undefined references that is not making sense to me:

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 definitely has those references:

nm -g /home/justinvf/raspi/rootfs/opt/vc/src/hello_pi/libs/vgfont/libvgfont.a | grep gx_graphics_init
000025d8 T gx_graphics_init

This is my first cross-compiling project, so I'm guessing something silly. Would very much appreciate some help though!

Upvotes: 2

Views: 266

Answers (1)

justinvf
justinvf

Reputation: 3109

libvgfont.a is a C library, compiled with cc. Adding extern "C" to the vffont.h header fixes the problem. For more details, see https://stackoverflow.com/a/12994075/1704581

Upvotes: 1

Related Questions