cvuchener / hidpp

Collection of HID++ tools
GNU General Public License v3.0
90 stars 23 forks source link

Can't get it to build #6

Open robomancer-or opened 6 years ago

robomancer-or commented 6 years ago

I'm trying to build, but it's giving me a bunch of errors... perhaps cmake isn't adding an important flag to the makefile somewhere?

[ 93%] Built target hidpp-check-device
[ 94%] Building CXX object src/tools/CMakeFiles/hidpp20-raw-touchpad-driver.dir/hidpp20-raw-touchpad-driver.cpp.o
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/vector:60,
                 from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:20:
/usr/include/c++/5/bits/stl_pair.h: In instantiation of ‘constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&) [with _U1 = const char*&; <template-parameter-2-2> = void; _T1 = const std::__cxx11::basic_string<char>; _T2 = MyMonitor::node]’:
/usr/include/c++/5/ext/new_allocator.h:120:4:   required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node>; _Args = {const char*&, const char*&}; _Tp = std::_Rb_tree_node<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >]’
/usr/include/c++/5/bits/alloc_traits.h:530:4:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node>; _Args = {const char*&, const char*&}; _Tp = std::_Rb_tree_node<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::_Rb_tree_node<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> > >]’
/usr/include/c++/5/bits/stl_tree.h:529:32:   required from ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {const char*&, const char*&}; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >*]’
/usr/include/c++/5/bits/stl_tree.h:546:21:   required from ‘std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const char*&, const char*&}; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >*]’
/usr/include/c++/5/bits/stl_tree.h:2123:33:   required from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_unique(_Args&& ...) [with _Args = {const char*&, const char*&}; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >]’
/usr/include/c++/5/bits/stl_map.h:559:64:   required from ‘std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {const char*&, const char*&}; _Key = std::__cxx11::basic_string<char>; _Tp = MyMonitor::node; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator = std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, MyMonitor::node> >]’
/home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:346:35:   required from here
/usr/include/c++/5/bits/stl_pair.h:134:45: error: use of deleted function ‘MyMonitor::node::node(const MyMonitor::node&)’
  : first(std::forward<_U1>(__x)), second(__y) { }
                                             ^
/home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:321:9: note: ‘MyMonitor::node::node(const MyMonitor::node&)’ is implicitly deleted because the default definition would be ill-formed:
  struct node
         ^
/home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:321:9: error: use of deleted function ‘HIDPP::DispatcherThread::DispatcherThread(const HIDPP::DispatcherThread&)’
In file included from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:38:0:
/home/robomancer/code/hidpp/src/tools/../libhidpp/hidpp/DispatcherThread.h:32:7: note: ‘HIDPP::DispatcherThread::DispatcherThread(const HIDPP::DispatcherThread&)’ is implicitly deleted because the default definition would be ill-formed:
 class DispatcherThread: public Dispatcher
       ^
/home/robomancer/code/hidpp/src/tools/../libhidpp/hidpp/DispatcherThread.h:32:7: error: use of deleted function ‘std::mutex::mutex(const std::mutex&)’
In file included from /home/robomancer/code/hidpp/src/tools/common/EventQueue.h:23:0,
                 from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:26:
/usr/include/c++/5/mutex:129:5: note: declared here
     mutex(const mutex&) = delete;
     ^
In file included from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:38:0:
/home/robomancer/code/hidpp/src/tools/../libhidpp/hidpp/DispatcherThread.h:32:7: error: use of deleted function ‘std::mutex::mutex(const std::mutex&)’
 class DispatcherThread: public Dispatcher
       ^
In file included from /home/robomancer/code/hidpp/src/tools/common/EventQueue.h:23:0,
                 from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:26:
/usr/include/c++/5/mutex:129:5: note: declared here
     mutex(const mutex&) = delete;
     ^
/home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:321:9: error: use of deleted function ‘std::thread::thread(const std::thread&)’
  struct node
         ^
In file included from /usr/include/c++/5/future:40:0,
                 from /home/robomancer/code/hidpp/src/tools/../libhidpp/hidpp/DispatcherThread.h:24,
                 from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:38:
/usr/include/c++/5/thread:126:5: note: declared here
     thread(const thread&) = delete;
     ^
/home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:321:9: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Driver; _Dp = std::default_delete<Driver>]’
  struct node
         ^
In file included from /usr/include/c++/5/condition_variable:43:0,
                 from /home/robomancer/code/hidpp/src/tools/common/EventQueue.h:24,
                 from /home/robomancer/code/hidpp/src/tools/hidpp20-raw-touchpad-driver.cpp:26:
/usr/include/c++/5/bits/unique_ptr.h:356:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^
make[2]: *** [src/tools/CMakeFiles/hidpp20-raw-touchpad-driver.dir/hidpp20-raw-touchpad-driver.cpp.o] Error 1
cvuchener commented 6 years ago

Are you using gcc 5? There is an issue withh gcc 5 that does not happen with later versions. You can try this patch or just skip the compilation of this tool if you don't need it.

diff --git a/src/tools/hidpp20-raw-touchpad-driver.cpp b/src/tools/hidpp20-raw-touchpad-driver.cpp
index bf59e40..fbb0845 100644
--- a/src/tools/hidpp20-raw-touchpad-driver.cpp
+++ b/src/tools/hidpp20-raw-touchpad-driver.cpp
@@ -343,7 +343,7 @@ public:
        {
                std::map<std::string, node>::iterator it;
                try {
-                       it = _nodes.emplace (path, path).first;
+                       it = _nodes.emplace (std::piecewise_construct, std::forward_as_tuple(path), std::forward_as_tuple(path)).first;
                }
                catch (std::exception &e) {
                        Log::debug () << "Ignored device " << path << ": " << e.what () << std::endl;
robomancer-or commented 6 years ago

That got it to build, but now make install tells me "-- Set runtime path of "/usr/local/bin/hidpp-list-devices" to "" ", and when I try to run it I get "hidpp-list-devices: error while loading shared libraries: libhidpp.so: cannot open shared object file: No such file or directory", which I suspect is related, but I don't know how to fix it.

robomancer-or commented 6 years ago

Success! I found https://stackoverflow.com/questions/32469953/why-is-cmake-designed-so-that-it-removes-runtime-path-when-installing and added

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

to CMakeLists.txt right after project(hidpp) and rebuilt everything and the code can now run! As soon as my device comes in I'll be able to test if it works...

cvuchener commented 6 years ago

On some distributions, ld.so may not look into /usr/local/lib by default, you can change that in /etc/ld.so.conf or /etc/ld.so.conf.d/ (and then update the cache with ldconfig).

If you are installing in a non-standard prefix, you can set LD_LIBRARY_PATH to include the location of libhidpp.so.