Undefined Reference while trying to run "Example use of the ArvCamera API"

Im trying to run the example given in the documentation “Example use of the ArvCamera API”.

(i wanted to upload logs with more images, but i cant since im new)

I just cant fix the “Undefined Reference” errors…
Here is the log:

/usr/bin/ld: /tmp/ccgYRBbr.o: in function `ARV_IS_STREAM':
main.c:(.text+0x15): undefined reference to `arv_stream_get_type'
/usr/bin/ld: main.c:(.text+0x61): undefined reference to `g_type_check_instance_is_a'
/usr/bin/ld: /tmp/ccgYRBbr.o: in function `ARV_IS_CAMERA':
main.c:(.text+0x82): undefined reference to `arv_camera_get_type'
/usr/bin/ld: main.c:(.text+0xce): undefined reference to `g_type_check_instance_is_a'
/usr/bin/ld: /tmp/ccgYRBbr.o: in function `new_buffer_cb':
main.c:(.text+0x10e): undefined reference to `arv_stream_try_pop_buffer'
/usr/bin/ld: main.c:(.text+0x125): undefined reference to `arv_buffer_get_status'
/usr/bin/ld: main.c:(.text+0x14d): undefined reference to `arv_stream_push_buffer'
/usr/bin/ld: /tmp/ccgYRBbr.o: in function `periodic_task_cb':
main.c:(.text+0x1a6): undefined reference to `g_main_loop_quit'
/usr/bin/ld: /tmp/ccgYRBbr.o: in function `main':
main.c:(.text+0x21f): undefined reference to `arv_camera_new'
/usr/bin/ld: main.c:(.text+0x25e): undefined reference to `arv_camera_set_region'
/usr/bin/ld: main.c:(.text+0x27b): undefined reference to `arv_camera_set_frame_rate'
/usr/bin/ld: main.c:(.text+0x28c): undefined reference to `arv_camera_get_payload'
/usr/bin/ld: main.c:(.text+0x2ac): undefined reference to `arv_camera_create_stream'
/usr/bin/ld: main.c:(.text+0x2df): undefined reference to `arv_buffer_new'
/usr/bin/ld: main.c:(.text+0x2f1): undefined reference to `arv_stream_push_buffer'
/usr/bin/ld: main.c:(.text+0x30c): undefined reference to `arv_camera_start_acquisition'
/usr/bin/ld: main.c:(.text+0x339): undefined reference to `g_signal_connect_data'
/usr/bin/ld: main.c:(.text+0x34a): undefined reference to `arv_stream_set_emit_signals'
/usr/bin/ld: main.c:(.text+0x356): undefined reference to `arv_camera_get_device'
/usr/bin/ld: main.c:(.text+0x37d): undefined reference to `g_signal_connect_data'
/usr/bin/ld: main.c:(.text+0x395): undefined reference to `g_timeout_add_seconds'
/usr/bin/ld: main.c:(.text+0x3a4): undefined reference to `g_main_loop_new'
/usr/bin/ld: main.c:(.text+0x3c9): undefined reference to `g_main_loop_run'
/usr/bin/ld: main.c:(.text+0x3e6): undefined reference to `g_main_loop_unref'
/usr/bin/ld: main.c:(.text+0x3f7): undefined reference to `arv_camera_stop_acquisition'
/usr/bin/ld: main.c:(.text+0x408): undefined reference to `arv_stream_set_emit_signals'
/usr/bin/ld: main.c:(.text+0x414): undefined reference to `g_object_unref'
/usr/bin/ld: main.c:(.text+0x46c): undefined reference to `g_clear_error'
/usr/bin/ld: main.c:(.text+0x478): undefined reference to `g_object_unref'
/usr/bin/ld: main.c:(.text+0x4d0): undefined reference to `g_clear_error'
collect2: error: ld returned 1 exit status

Im using pkg-config as recommended, here is the command i run:
“gcc -v $(pkg-config --libs --cflags aravis-0.8) main.c -o main”

Im running with -v to get information about compilation, here is the log:

(first part)

(second part)

COLLECT_GCC_OPTIONS='-v' '-pthread' '-I' '/usr/local/include/aravis-0.8' '-I' '/usr/include/libxml2' '-I' '/usr/include/libmount' '-I' '/usr/include/blkid' '-I' '/usr/include/glib-2.0' '-I' '/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-L/usr/local/lib/x86_64-linux-gnu' '-o' 'main' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/cc6K5EMt.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o main /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/10/crtbeginS.o -L/usr/local/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/local/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. -laravis-0.8 -lgio-2.0 -lgobject-2.0 -lglib-2.0 /tmp/ccgYRBbr.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lpthread -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/10/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o

-libaravis-0.8.so 

is in
“/usr/local/lib/x86_64-linux-gnu/”

-libgio-2.0.so
-libglib-2.0.so 
-libgobject-2.0.so

are in
“usr/lib/x86_64-linux-gnu/”

We can see in the log picture that i posted, that these paths are in the LIBRARY_PATH:

LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/local/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/

Im using Ubuntu 20.10

I have been trying to fix this the whole day already, i would appreciate any help, thanks!

Hi,

Please don’t post screenshots, they are hard to read, and prevent cut’n paste.

Try:

gcc -v main.c -o main `pkg-config --cflags --libs aravis-0.8`
1 Like