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 references to sdbus (SDBusCpp) #109

Open
evan-erasmus opened this issue Nov 12, 2024 · 4 comments
Open

Undefined references to sdbus (SDBusCpp) #109

evan-erasmus opened this issue Nov 12, 2024 · 4 comments

Comments

@evan-erasmus
Copy link

Building on Ubuntu 24.10
cmake version 3.30.3

Found an issue with SDBus not being referenced in the CMakeLists.txt

/usr/bin/ld: CMakeFiles/hypridle.dir/src/core/Hypridle.cpp.o: in function `handleDbusLogin(sdbus::Message)':
Hypridle.cpp:(.text+0x335d): undefined reference to `sdbus::Message::getMemberName() const'
/usr/bin/ld: CMakeFiles/hypridle.dir/src/core/Hypridle.cpp.o: in function `handleDbusBlockInhibitsPropertyChanged(sdbus::Message)':
Hypridle.cpp:(.text+0x44f7): undefined reference to `sdbus::Message::enterContainer(char const*)'
/usr/bin/ld: Hypridle.cpp:(.text+0x4555): undefined reference to `sdbus::Message::enterDictEntry(char const*)'
/usr/bin/ld: Hypridle.cpp:(.text+0x4a5a): undefined reference to `sdbus::Message::enterVariant(char const*)'
/usr/bin/ld: CMakeFiles/hypridle.dir/src/core/Hypridle.cpp.o: in function `CHypridle::setupDBUS()':
Hypridle.cpp:(.text+0x4f17): undefined reference to `sdbus::createProxy(sdbus::IConnection&, sdbus::BusName, sdbus::ObjectPath)'
/usr/bin/ld: Hypridle.cpp:(.text+0x5550): undefined reference to `sdbus::createSessionBusConnection(sdbus::BusName const&)'
/usr/bin/ld: Hypridle.cpp:(.text+0x5665): undefined reference to `sdbus::createObject(sdbus::IConnection&, sdbus::ObjectPath)'
/usr/bin/ld: Hypridle.cpp:(.text+0x5e79): undefined reference to `sdbus::Message::operator<<(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: Hypridle.cpp:(.text+0x5e91): undefined reference to `sdbus::Message::operator<<(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: Hypridle.cpp:(.text+0x5f20): undefined reference to `sdbus::Message::enterVariant(char const*)'
/usr/bin/ld: CMakeFiles/hypridle.dir/src/core/Hypridle.cpp.o: in function `handleDbusSleep(sdbus::Message)':
Hypridle.cpp:(.text+0x76cb): undefined reference to `sdbus::Message::getMemberName() const'
/usr/bin/ld: CMakeFiles/hypridle.dir/src/core/Hypridle.cpp.o: in function `std::_Function_handler<void (sdbus::MethodCall), sdbus::MethodVTableItem::implementedAs<CHypridle::setupDBUS()::{lambda(unsigned int)#1}>(CHypridle::setupDBUS()::{lambda(unsigned int)#1}&&)::{lambda(sdbus::MethodCall)#1}>::_M_invoke(std::_Any_data const&, sdbus::MethodCall&&)':
Hypridle.cpp:(.text+0x8555): undefined reference to `sdbus::Message::getSender() const'
/usr/bin/ld: CMakeFiles/hypridle.dir/src/core/Hypridle.cpp.o: in function `std::_Function_handler<void (sdbus::MethodCall), sdbus::MethodVTableItem::implementedAs<CHypridle::setupDBUS()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#1}>(CHypridle::setupDBUS()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#1}&&)::{lambda(sdbus::MethodCall)#1}>::_M_invoke(std::_Any_data const&, sdbus::MethodCall&&)':
Hypridle.cpp:(.text+0x87c6): undefined reference to `sdbus::Message::getSender() const'
collect2: error: ld returned 1 exit status
gmake[3]: *** [CMakeFiles/hypridle.dir/build.make:150: hypridle] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hypridle.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/hypridle.dir/rule] Error 2
gmake: *** [Makefile:170: hypridle] Error 2

After hours of agonizing pain, I added the following and it works flawlessly:

find_package(sdbus-c++ REQUIRED) # -> line 34
# ...
target_link_libraries(hypridle PRIVATE rt Threads::Threads PkgConfig::deps SDBusCpp::sdbus-c++) # -> line 49

Thought I'd drop it here for anyone that needs help with this in the future :)

@vaxerski
Copy link
Member

it should already be linked, though... thats odd

@evan-erasmus
Copy link
Author

No idea, I'm a php dev, not C++ XD

But the same issue exists for https://github.com/hyprwm/hyprlock

As I said I'm also compiling on Ubuntu so even sdbus-c++ had to be compiled from source - thinking that might be the reason (maybe part of it?)

sdbus I used: https://github.com/Kistler-Group/sdbus-cpp

@vaxerski
Copy link
Member

make sure to checkout to v2.0.0

@zjeffer
Copy link

zjeffer commented Feb 24, 2025

I fixed it by configuring sdbus-cpp to install in /usr/, instead of in /usr/local/:
So the sdbus-cpp building instructions become:

$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr ${OTHER_CONFIG_FLAGS}
$ cmake --build .
$ sudo cmake --build . --target install

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

3 participants