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

Shared library linker options #1

Open
mkarev opened this issue Aug 16, 2024 · 0 comments
Open

Shared library linker options #1

mkarev opened this issue Aug 16, 2024 · 0 comments

Comments

@mkarev
Copy link

mkarev commented Aug 16, 2024

Linking with the ztd.text library results in the addition of a global macro dl (Ubuntu 22, GCC11):

#include <ztd/text.hpp>

int maint () {
    int dl = 0; // compilation error
    return 0;
}

The suggested solution is to move CMAKE_DL_LIBS from target_compile_definitions to target_link_libraries.
Before:

target_compile_definitions(ztd.encoding_tables
	PRIVATE
		ZTD_ENCODING_TABLES_BUILD=1
	PUBLIC
		$<$<STREQUAL:$<TARGET_PROPERTY:ztd.encoding_tables,TYPE>,SHARED_LIBRARY>:ZTD_ENCODING_TABLES_DLL=1>
		${CMAKE_DL_LIBS}
)

After:

target_compile_definitions(ztd.encoding_tables
	PRIVATE
		ZTD_ENCODING_TABLES_BUILD=1
	PUBLIC
		$<$<STREQUAL:$<TARGET_PROPERTY:ztd.encoding_tables,TYPE>,SHARED_LIBRARY>:ZTD_ENCODING_TABLES_DLL=1>
)
target_link_libraries(ztd.encoding_tables
	PUBLIC
		${CMAKE_DL_LIBS}
)
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

1 participant