hark130 / sketchy-idea

Reusable, stand-alone, Linux code
GNU General Public License v3.0
0 stars 0 forks source link

SKID-3: Add Check unit test linker flags #9

Closed hark130 closed 4 months ago

hark130 commented 4 months ago

Some older(?) versions of gcc require a bit more explicit linking for the Check unit tests to compile.

Add -lrt -lpthread to the CHECK_CC_ARGS in Makefile_linux

Why -lrt?

[snip]
    Linking Check unit test binary: dist/check_sfmr_get_access_time.bin
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcheck.a(check.o): in function `check_get_clockid':
(.text+0xcef): undefined reference to `timer_create'
/usr/bin/ld: (.text+0xd25): undefined reference to `timer_delete'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcheck.a(check_pack.o): in function `ppack':
(.text+0x63e): undefined reference to `__pthread_register_cancel'
/usr/bin/ld: (.text+0x688): undefined reference to `__pthread_unregister_cancel'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcheck.a(check_run.o): in function `srunner_run_tagged':
(.text+0xc07): undefined reference to `timer_create'
/usr/bin/ld: (.text+0xc4f): undefined reference to `timer_settime'
/usr/bin/ld: (.text+0xc82): undefined reference to `timer_delete'
[snip]

Why -lpthread?

[snip]
    Linking Check unit test binary: dist/check_sfmr_get_access_time.bin
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcheck.a(check_pack.o): undefined reference to symbol '__pthread_unregister_cancel@@GLIBC_2.3.3'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
[snip]