Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build error when POSIX and runtime is both enabled #4

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

tobiasfrejo
Copy link
Member

@tobiasfrejo tobiasfrejo commented Apr 21, 2024

When building a project with build parameters csp_proc:posix=true and csp_proc:proc_runtime=true, linking fails with "multiple definition of 'recursion_depth_key';", as this variable is defined in both runtime/proc_runtime_POSIX.c:26 and runtime/proc_runtime_instructions_POSIX.c:19.

Found as I was integrating csp_proc into csp-pi-gpio:

FAILED: app 
cc  -o app app.p/src_main.c.o app.p/src_param_config.c.o app.p/src_hooks.c.o app.p/src_serial.c.o app.p/src_gpio.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--whole-archive -Wl,--start-group lib/csp/libcsp.a lib/param/libparam.a lib/csp_proc/libcsp_proc.a -Wl,--no-whole-archive -Wl,--export-dynamic -ldl /usr/lib/x86_64-linux-gnu/libyaml.so -lc -pthread /usr/lib/x86_64-linux-gnu/libsocketcan.so /usr/lib/x86_64-linux-gnu/libzmq.so /usr/lib/x86_64-linux-gnu/libbsd.so -Wl,--end-group
/usr/bin/ld: lib/csp_proc/libcsp_proc.a.p/src_runtime_proc_runtime_POSIX.c.o:/home/tobias/git/csp-gpio/builddir/../lib/csp_proc/src/runtime/proc_runtime_POSIX.c:26: multiple definition of `recursion_depth_key'; lib/csp_proc/libcsp_proc.a.p/src_runtime_proc_runtime_instructions_POSIX.c.o:/home/tobias/git/csp-gpio/builddir/../lib/csp_proc/src/runtime/proc_runtime_instructions_POSIX.c:19: first defined here
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

A solution seems to be marking one of the definitions as extern

@tobiasfrejo tobiasfrejo requested a review from NValsted April 23, 2024 19:13
@NValsted
Copy link
Member

Good catch! 🚀

@NValsted NValsted merged commit 6173234 into main Apr 24, 2024
1 check passed
@NValsted NValsted deleted the posix-runtime-build-error-fix branch April 24, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants