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

Warnings when compiling Python bindings on macOS + clang 12.0.0 #4

Closed
ntamas opened this issue Mar 24, 2021 · 3 comments · Fixed by #26
Closed

Warnings when compiling Python bindings on macOS + clang 12.0.0 #4

ntamas opened this issue Mar 24, 2021 · 3 comments · Fixed by #26
Labels
bug Something isn't working

Comments

@ntamas
Copy link

ntamas commented Mar 24, 2021

I'm getting the following warnings while compiling the Python bindings on macOS:

ld: warning: direct access in function 'pybind11_init_cflinkcpp(pybind11::module_&)' from file '/tmp/lto.o' to global weak symbol 'bitcraze::crazyflieLinkCpp::Packet::valid() const' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'pybind11_init_cflinkcpp(pybind11::module_&)' from file '/tmp/lto.o' to global weak symbol 'bitcraze::crazyflieLinkCpp::Packet::port() const' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'char const* std::__1::__find_end<bool (*)(char, char), char const*, char const*>(char const*, char const*, char const*, char const*, bool (*)(char, char), std::__1::random_access_iterator_tag, std::__1::random_access_iterator_tag)' from file '/tmp/lto.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

The Python bindings seems to work fine, though, at least I could definitely run the console example without problems so I'm not sure this is something to worry about.

@knmcguire knmcguire added the bug Something isn't working label Mar 8, 2022
@knmcguire
Copy link
Member

sorry for the late reply... I guess this is still an issue for you currently right?

Probably not immediately something to worry about I would say. @whoenig is more acquinted with python binding though.

@ntamas
Copy link
Author

ntamas commented Mar 8, 2022

Yes, it's still an issue with the latest master, although the messages are a bit different now:

ld: warning: direct access in function 'pybind11_init_cflinkcpp(pybind11::module_&)' from file 'CMakeFiles/cflinkcpp.dir/src/python_bindings.cpp.o' to global weak symbol 'bitcraze::crazyflieLinkCpp::Packet::valid() const' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'pybind11_init_cflinkcpp(pybind11::module_&)' from file 'CMakeFiles/cflinkcpp.dir/src/python_bindings.cpp.o' to global weak symbol 'bitcraze::crazyflieLinkCpp::Packet::valid() const' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'pybind11_init_cflinkcpp(pybind11::module_&)' from file 'CMakeFiles/cflinkcpp.dir/src/python_bindings.cpp.o' to global weak symbol 'bitcraze::crazyflieLinkCpp::Packet::port() const' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'pybind11_init_cflinkcpp(pybind11::module_&)' from file 'CMakeFiles/cflinkcpp.dir/src/python_bindings.cpp.o' to global weak symbol 'bitcraze::crazyflieLinkCpp::Packet::port() const' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'unsigned long std::__1::__str_rfind<char, unsigned long, std::__1::char_traits<char>, 18446744073709551615ul>(char const*, unsigned long, char const*, unsigned long, unsigned long)' from file 'CMakeFiles/cflinkcpp.dir/src/python_bindings.cpp.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'unsigned long std::__1::__str_rfind<char, unsigned long, std::__1::char_traits<char>, 18446744073709551615ul>(char const*, unsigned long, char const*, unsigned long, unsigned long)' from file 'CMakeFiles/cflinkcpp.dir/src/python_bindings.cpp.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file 'libcrazyflieLinkCpp.a(Connection.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

Furthermore, I needed to patch CMakeLists.txt to build on macOS:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d2f972c..a543583 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,8 +75,8 @@ add_library(crazyflieLinkCpp

 # Apple macOS libraries
 if (APPLE)
-  set(CMAKE_EXE_LINKER_FLAGS "-lobjc -framework IOKit -framework CoreFoundation")
-  set(CMAKE_MODULE_LINKER_FLAGS "-lobjc -framework IOKit -framework CoreFoundation")
+  set(CMAKE_EXE_LINKER_FLAGS "-lobjc -framework IOKit -framework CoreFoundation -framework Security")
+  set(CMAKE_MODULE_LINKER_FLAGS "-lobjc -framework IOKit -framework CoreFoundation -framework Security")
 endif()

 # Link pthread on Linux and Mac only

Required linker flags were taken from the pkg-config configuration file from libusb:

Libs.private:  -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation -Wl,-framework,Security

@ntamas
Copy link
Author

ntamas commented Jun 4, 2022

CMakeLists.txt patch as outlined in the previous comment is not necessary any more now that 2095781 was committed.

The original warnings are still there, but indeed they don't seem to cause any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants