koka-lang / libmprompt

Robust multi-prompt delimited control and effect handlers in C/C++
MIT License
106 stars 11 forks source link

FreeBSD13 Debug build: undefined symbol: backtrace (linker is missing -lexecinfo?) #5

Closed gdiazlo closed 3 years ago

gdiazlo commented 3 years ago

When buiding a debug release on FreeBSD, the backtrace call needs to add -lexecinfo as per backtrace(3), but the current cmake configuration does not seem to include it.

$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Use the C++ compiler to compile (Clang) (MP_USE_C=OFF)
-- 
-- Libraries : libmpromptx, libmpeffx
-- Build type: Debug
-- Compiler  : /usr/bin/c++
--             -Wno-deprecated
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/home/gdiazlo/src/libmprompt/out/debug
$ make
Scanning dependencies of target mpeff
[  3%] Building CXX object CMakeFiles/mpeff.dir/src/mpeff/main.c.o
[  7%] Building ASM object CMakeFiles/mpeff.dir/src/mprompt/asm/longjmp_amd64.S.o
[ 10%] Linking CXX static library libmpeffx.a
[ 10%] Built target mpeff
Scanning dependencies of target test_mp_example_async
[ 14%] Building CXX object CMakeFiles/test_mp_example_async.dir/test/test_mp_example_async.c.o
[ 17%] Linking CXX executable test_mp_example_async
ld: error: undefined symbol: backtrace
>>> referenced by mprompt.c:756 (/usr/home/gdiazlo/src/libmprompt/src/mpeff/../mprompt/mprompt.c:756)
>>>               main.c.o:(mp_backtrace(void**, int)) in archive libmpeffx.a
c++: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[2]: stopped in /usr/home/gdiazlo/src/libmprompt/out/debug
*** Error code 1

Stop.
make[1]: stopped in /usr/home/gdiazlo/src/libmprompt/out/debug
*** Error code 1

Stop.
make: stopped in /usr/home/gdiazlo/src/libmprompt/out/debug
$ 
daanx commented 3 years ago

Ah, thanks! I will add that to the linker flags

daanx commented 3 years ago

Thanks, I added a check in the cmake.