The Gizmo Daemon is a very powerfull little utility to control applications and devices based on input events. I am using Gizmod to control my DIY Arcade Cabinet with USB Controllers to navigate through the menus and start or stop games. When I updated my Arcade Cabinet with new hardware I found out that Gizmod does not compile on newer Ubuntu versions. It seems like Gizmod is not well maintained at the moment.
I'm using the Gizmo Daemon to create input events from USB gamepads As described in the documentation… 1) Checkout the Subversion code of Gizmod:
svn checkout svn://svn.code.sf.net/p/gizmod/code/ gizmod-code
2) Install some dependencies neccessary for the compile:
sudo apt-get install libboost-all-dev
sudo apt-get install libx11-dev
sudo apt-get install libvisual-0.4-dev
sudo apt-get install libasound2
3) Create the build directory:
mkdir build
cd build
4) And call cmake:
cmake -DCMAKE_INSTALL_PREFIX = /usr -DSYSCONF_INSTALL_DIR = /etc ..
CMake Warning ( dev) at CMakeLists.txt:55 ( include) :
Policy CMP0011 is not set : Included scripts do automatic cmake_policy PUSH
and POP. Run "cmake --help-policy CMP0011" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
The included script
/home/user/Software/gizmod/gizmod-code/gizmod3/cmake/Modules/
DefineProjectDefaults.cmake
affects policy settings. CMake is implying the NO_POLICY_SCOPE option for
compatibility, so the effects are applied to the including context.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Boost: /usr/lib/x86_64-linux-gnu/libboost_date_time.so; /usr/lib/
x86_64-linux-gnu/libboost_filesystem.so; /usr/lib/x86_64-linux-gnu/
libboost_iostreams.so; /usr/lib/x86_64-linux-gnu/libboost_prg_exec_monitor.so;
/usr/lib/x86_64-linux-gnu/libboost_program_options.so; /usr/lib/
x86_64-linux-gnu/libboost_python.so; /usr/lib/x86_64-linux-gnu/
libboost_regex.so; /usr/lib/x86_64-linux-gnu/libboost_serialization.so;
/usr/lib/x86_64-linux-gnu/libboost_signals.so; /usr/lib/x86_64-linux-gnu/
libboost_test_exec_monitor.a;
/usr/lib/x86_64-linux-gnu/libboost_thread.so; /usr/lib/x86_64-linux-gnu/
libboost_unit_test_framework.so; /usr/lib/x86_64-linux-gnu/
libboost_wserialization.so
-- Installation Variables:
Build Type ( CMAKE_BUILD_TYPE) : Release
Install Prefix ( CMAKE_INSTALL_PREFIX) : /usr
Data Dir ( DATA_INSTALL_DIR) : /usr/share/Gizmod
Lib Dir ( LIB_INSTALL_DIR) : /usr/lib
Plugin Dir ( PLUGIN_INSTALL_DIR) : /usr/lib/Gizmod
Config Dir ( SYSCONF_INSTALL_DIR) : /usr/etc
Build vis plugin ( BUILD_VIS_PLUGIN) : True
-- ALSA not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/Software/gizmod/gizmod-code/
gizmod3/build
5) Compile:
make
Scanning dependencies of target H
[ 1%] Building CXX object libH/CMakeFiles/H.dir/Average.o
In file included from /home/user/Software/gizmod/gizmod-code/gizmod3/libH/
Average.cpp:31:0:
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.hpp:74:5:
error: ‘size_t’ does not name a type
size_t mHeadIdx; ///< Current location in the circular buffer
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.hpp:76:5: error:
‘size_t’ does not name a type
size_t mFillState; ///< Current fill state
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp: In constructor
‘H::Average::Average( int) ’:
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:53:2: error:
‘mHeadIdx’ was not declared in this scope
mHeadIdx = 0;
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:55:2: error:
‘mFillState’ was not declared in this scope
mFillState = 0;
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp: In member
function ‘void H::Average::push( double) ’:
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:73:6: error:
‘mFillState’ was not declared in this scope
if ( mFillState == mValues.size()) {
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:74:27: error:
‘mHeadIdx’ was not declared in this scope
mSum += Value - mValues[mHeadIdx];
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:79:11: error:
‘mHeadIdx’ was not declared in this scope
mValues[mHeadIdx] = Value;
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:81:2: error:
‘mHeadIdx’ was not declared in this scope
mHeadIdx = ( mHeadIdx + 1) % mValues.size() ;
^
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp: In member
function ‘double H::Average::average() ’:
/home/user/Software/gizmod/gizmod-code/gizmod3/libH/Average.cpp:89:8: error:
‘mFillState’ was not declared in this scope
if ( mFillState == 0)
^
make[2]: *** [ libH/CMakeFiles/H.dir/Average.o] Fehler 1
make[1]: *** [ libH/CMakeFiles/H.dir/all] Fehler 2
make: *** [ all] Fehler 2
Fix the errors The compiler throws some errors. To fix the size_t errors add the following include in the files libH/Average.hpp and libH/DynamicBuffer.hpp
#include <stdlib>
If we run make again we get:
make
/home/user/Software/gizmod/gizmod-code/gizmod3/libGizmod/Processes.cpp:157:27:
error: ‘class boost::filesystem::directory_entry’ has no member named ‘string’
string StatPath = iter->string() + "/stat" ;
^
make[2]: *** [ libGizmod/CMakeFiles/Gizmod.dir/Processes.o] Fehler 1
make[1]: *** [ libGizmod/CMakeFiles/Gizmod.dir/all] Fehler 2
make: *** [ all] Fehler 2
To fix these errors we have to change the line 157 in file /gizmod-3.5/libGizmod/Proceses.cpp :
string StatPath = iter -> string () + "/stat" ;
to
string StatPath = iter -> path (). string () + "/stat" ;
and in the file /gizmod-3.5/gizmod/GizmoDaemon.cpp on line 1109 we have to change:
ret += "sys.path.insert(0, \" " + iter -> string () + " \" ) \n " ;
to:
ret += "sys.path.insert(0, \" " + iter -> path (). string () + " \" ) \n " ;
On line 1567 we have to change:
UserScripts . push_back ( iter -> path (). leaf ());
to:
UserScripts . push_back ( iter -> path (). filename (). string ());
On line 2192:
if ( iter -> path (). leaf (). find ( "event" ) != 0 )
to:
if ( iter -> path (). filename (). string (). find ( "event" ) != 0 )
And on line 2194, change:
eventsFiles . push_back ( mEventsDir + "/" + iter -> path (). leaf ());
to:
eventsFiles . push_back ( mEventsDir + "/" + iter -> path (). filename (). string ());
Let’s call make again:
make
[ 29%] Built target H
[ 87%] Built target Gizmod
Scanning dependencies of target gizmod
[ 88%] Building CXX object gizmod/CMakeFiles/gizmod.dir/GizmoDaemon.o
[ 90%] Building CXX object gizmod/CMakeFiles/gizmod.dir/GizmoUtils.o
[ 92%] Building CXX object gizmod/CMakeFiles/gizmod.dir/
GizmodEventHandlerInterface.o
[ 94%] Building CXX object gizmod/CMakeFiles/gizmod.dir/Main.o
/home/user/Software/gizmod/gizmod-code/gizmod3/gizmod/Main.cpp: In function
‘int main( int, char** ) ’:
/home/user/Software/gizmod/gizmod-code/gizmod3/gizmod/Main.cpp:57:2: error:
‘default_name_check’ is not a member of ‘boost::filesystem::path’
path::default_name_check( native) ;
^
make[2]: *** [ gizmod/CMakeFiles/gizmod.dir/Main.o] Fehler 1
make[1]: *** [ gizmod/CMakeFiles/gizmod.dir/all] Fehler 2
make: *** [ all] Fehler 2
Still not there! To fix this error, we have to remove line 57 from gizmod-3.5/gizmod/Main.cpp
// set filesystem to native filesystem checking
// path::default_name_check(native);
We call make once again:
make:
[ 29%] Built target H
Scanning dependencies of target Gizmod
[ 31%] Building CXX object libGizmod/CMakeFiles/Gizmod.dir/Processes.o
Linking CXX shared library libGizmod.so
[ 87%] Built target Gizmod
Scanning dependencies of target gizmod
[ 88%] Building CXX object gizmod/CMakeFiles/gizmod.dir/Main.o
Linking CXX executable gizmod
/usr/bin/ld: CMakeFiles/gizmod.dir/GizmoDaemon.o: undefined reference to
symbol '_ZN5boost6system15system_categoryEv'
//usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0: error adding symbols:
DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [ gizmod/gizmod] Fehler 1
make[1]: *** [ gizmod/CMakeFiles/gizmod.dir/all] Fehler 2
make: *** [ all] Fehler 2
To fix this error add -lboost_system to the arguments in file /gizmod-3.5/build/gizmod/CMakeFiles/gizmod.dir/link.txt
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/gizmod.dir/GizmoDaemon.o
CMakeFiles/gizmod.dir/GizmoUtils.o CMakeFiles/gizmod.dir/
GizmodEventHandlerInterface.o CMakeFiles/gizmod.dir/Main.o
-o gizmod -rdynamic ../libH/libH.a ../libGizmod/libGizmod.so.3.4.0
-lboost_program_options -lpython2 .7 ../libH/libH.a -lboost_filesystem
-lboost_system -lboost_thread -lboost_serialization -lboost_python
-lasound -lSM -lICE -lX11 -lXext -lutil -lpython2 .7
-Wl ,-rpath,/home/user/tmp/gizmod/gizmod-3.5/build/libGizmod:
And finally edit the file /gizmod-3.5/libH/FileEventWatcher.cpp in line 232-236 to fix the 100% CPU usage problem:
case WATCH_INOUT :
flags = O_RDWR ;
//events = POLLIN | POLLOUT; // This line causes 100% CPU usage on
newer kernels
events = POLLIN ; // | POLLOUT;
ModeString = "Read / Write" ;
break ;
That’s it, Gizmod should compile and run fine.
WRITTEN BY
Sebastian Glahn is a Senior Software Engineer living in Cologne. He writes about Software Development, 3D-Printing, Robots and other stuff. He is also a maintainer of several open source projects.
about | github | twitter