2

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!

justinvf
  • 2,939
  • 2
  • 14
  • 9
  • Are you sure the libraries and object files are ordered correctly? – David G Aug 31 '14 at 03:34
  • Feels like a missing dependency, which could be a result of some of the cmake options... When you say "cross compile" do you mean that you're building OpenCV on your computer (x86) to be transferred to the Pi (ARM)? Or are you just building on the Pi? – tomwhipple Aug 31 '14 at 15:57
  • Also, what version of OpenCV are you using? – tomwhipple Aug 31 '14 at 15:59
  • (Finally) Are you using a demo from OpenCV or one you're working on yourself. If the latter, a GitHub/Gist link might help. ;) – tomwhipple Aug 31 '14 at 16:40
  • Building on x86 for the arm. The missing dependency is present in libvgfont and the library in that linking command is present after the "opencv_demo.cpp.o" object (added it a few times just to be paranoid), so it should definitely be picking it up. Simplified program to just have the one error. Gist: https://gist.github.com/justinvf/2551ea5d6cf824d46af4 – justinvf Aug 31 '14 at 17:00

1 Answers1

1

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

Community
  • 1
  • 1
justinvf
  • 2,939
  • 2
  • 14
  • 9