hugegreenbug / xf86-input-cmt

X11 ChromiumOS touchpad driver ported to Linux
BSD 3-Clause "New" or "Revised" License
83 stars 15 forks source link

Failed to compile because of errors in libgestures #36

Closed jackz314 closed 6 years ago

jackz314 commented 6 years ago

I tried to compile the drivers but soon figured out I was missing libgestures and libevdevc, so I went and try to install them, installing libevdevc went well while installing libgestures failed because of several( programmatical) errors:

In file included from include/gestures/include/box_filter_interpreter.h:9:0,
                 from src/box_filter_interpreter.cc:5:
include/gestures/include/finger_metrics.h: In member function ‘float gestures::Vector2::Mag() const’:
include/gestures/include/finger_metrics.h:38:12: error: ‘sqrtf’ was not declared in this scope
     return sqrtf(MagSq());
            ^~~~~
include/gestures/include/finger_metrics.h:38:12: note: suggested alternative: ‘strtof’
     return sqrtf(MagSq());
            ^~~~~
            strtof
Makefile:175: recipe for target 'obj/box_filter_interpreter.o' failed
make: *** [obj/box_filter_interpreter.o] Error 1

Then I saw a pull request that wasn't approved, it adds a line +#include <math.h> which solved that sqrtf() problem, but then the ultimate error came:

src/immediate_interpreter.cc: In member function ‘void gestures::ImmediateInterpreter::UpdateThumbState(const HardwareState&)’:
src/immediate_interpreter.cc:1279:34: error: ‘*’ in boolean context, suggest ‘&&’ instead [-Werror=int-in-bool-context]
     bool slower_moved = (dist_sq * min_dt &&
                          ~~~~~~~~^~~~~~~~
src/immediate_interpreter.cc: In member function ‘void gestures::ImmediateInterpreter::FillResultGesture(const HardwareState&, const FingerMap&)’:
src/immediate_interpreter.cc:2667:22: error: ‘*’ in boolean context, suggest ‘&&’ instead [-Werror=int-in-bool-context]
         if (dist_sq2 * dt &&  // have prev dist and current time
             ~~~~~~~~~^~~~
cc1plus: all warnings being treated as errors
Makefile:175: recipe for target 'obj/immediate_interpreter.o' failed
make: *** [obj/immediate_interpreter.o] Error 1

I'm really baffled by how difficult this whole compile/install process is, I had to manually install all kinds of packages to get the compiling working, but in the end, there's still one (or more) error that made the whole process impossible. Am I missing something or is there a problem with the repository? If there's this problem in the file, how did all these other people get their drivers installed? Please help me out, thanks in advance!

jackz314 commented 6 years ago

Never mind, the programmatical problem solved, after a round of research, I found out that when compiling (making) libgestures, the newer version (which is probably what most people have right now) of gcc (7.1 +) will mark '' s in a bool or if statement as errors. I solved the problem by introducing local variables to store the values and use variables in the if statements instead of '' direct calculations, I've made a pull request (or two) in the libgestures repository, hope it helps those who are also frustrating with these similar errors.