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

Undefined reference if linking against static library #169

Closed
rherrmannr opened this issue Mar 12, 2024 · 2 comments
Closed

Undefined reference if linking against static library #169

rherrmannr opened this issue Mar 12, 2024 · 2 comments

Comments

@rherrmannr
Copy link

rherrmannr commented Mar 12, 2024

Describe the bug
Undefined reference if linking against static library.

Expected behavior
It should be possible to link against the static library. All references must be resolved.

Observed behavior
No object files for osdp_pcap.c and pcap_gen.c. They should be added to LIB_OSDP_SOURCES instead of LIB_OSDP_UTILS_SRC:

if (CONFIG_OSDP_PACKET_TRACE OR CONFIG_OSDP_PACKET_TRACE)
	list(APPEND LIB_OSDP_SOURCES
		${CMAKE_CURRENT_SOURCE_DIR}/osdp_pcap.c
	)
endif()

# and later on:
if (CONFIG_OSDP_PACKET_TRACE OR CONFIG_OSDP_PACKET_TRACE)
	list(APPEND LIB_OSDP_SOURCES
		${PROJECT_SOURCE_DIR}/utils/src/pcap_gen.c
	)
endif()

Additional context
Config using CMake:

set(CONFIG_OSDP_PACKET_TRACE ON)
set(CONFIG_OSDP_DATA_TRACE OFF)
set(CONFIG_OSDP_SKIP_MARK_BYTE OFF)
set(CONFIG_DISABLE_PRETTY_LOGGING OFF)
set(CONFIG_OSDP_STATIC_PD OFF)
set(CONFIG_OSDP_LIB_ONLY ON)

A Comprehensive Log file

/usr/bin/ld: ../mylib.so: undefined reference to `osdp_packet_capture_init'
/usr/bin/ld: ../mylib.so: undefined reference to `osdp_capture_packet'
/usr/bin/ld: ../mylib.so: undefined reference to `osdp_packet_capture_finish'
@sidcha sidcha closed this as completed in 6cca1f3 Mar 12, 2024
@sidcha
Copy link
Member

sidcha commented Mar 12, 2024

@rherrmannr please feel free to re-open this issue if does not fix your problem. I didn't test this fix, just eye-balled :)

@rherrmannr
Copy link
Author

For me it's working. Thanks 👍

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

No branches or pull requests

2 participants