uglyDwarf / linuxtrack

Headtracking for Linux/Mac
MIT License
155 stars 30 forks source link

PTHREAD_MUTEX_INITIALIZER issue #195

Closed domrnet closed 1 year ago

domrnet commented 1 year ago

Hi

I am getting issues when trying to build on ubuntu 20.10 and now 23.4 ... configure steps seem to run fine but then when I am running make -j it finishes with the below errors. Any ideas what I need to tweak here to fix it?

ake[2]: Entering directory '/home/dom/codelt/linuxtrack/linuxtrack/src' g++ -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -O2 -g -O2 -g -O2 -Wall -Wextra -Wformat -Wformat-security --param ssp-buffer-size=4 -fstack-protector -D_FORTIFY_SOURCE=2 -c -o ltr_srv_master.o ltr_srv_master.cpp ltr_srv_master.cpp:35:34: error: ‘PTHREAD_MUTEX_INITIALIZER’ was not declared in this scope; did you mean ‘LTR_AXES_T_INITIALIZER’? 35 | static pthread_mutex_t send_mx = PTHREAD_MUTEX_INITIALIZER; | ^~~~~~~~~~~~~~~~~~~~~~~~~ | LTR_AXES_T_INITIALIZER ltr_srv_master.cpp: In function ‘void ltr_int_change(const char*, int, int, float)’: ltr_srv_master.cpp:77:3: error: ‘pthread_mutex_lock’ was not declared in this scope; did you mean ‘pthread_mutex_t’? 77 | pthread_mutex_lock(&send_mx); | ^~~~~~~~~~~~~~~~~~ | pthread_mutex_t ltr_srv_master.cpp:92:3: error: ‘pthread_mutex_unlock’ was not declared in this scope; did you mean ‘pthread_mutex_t’? 92 | pthread_mutex_unlock(&send_mx); | ^~~~~~~~~~~~~~~~~~~~ | pthread_mutex_t ltr_srv_master.cpp: In function ‘bool ltr_int_broadcast_pose(linuxtrack_full_pose_t&)’: ltr_srv_master.cpp:109:3: error: ‘pthread_mutex_lock’ was not declared in this scope; did you mean ‘pthread_mutex_t’? 109 | pthread_mutex_lock(&send_mx); | ^~~~~~~~~~~~~~~~~~ | pthread_mutex_t ltr_srv_master.cpp:130:3: error: ‘pthread_mutex_unlock’ was not declared in this scope; did you mean ‘pthread_mutex_t’? 130 | pthread_mutex_unlock(&send_mx); | ^~~~~~~~~~~~~~~~~~~~ | pthread_mutex_t ltr_srv_master.cpp: In function ‘bool ltr_int_register_slave(int, message_t&)’: ltr_srv_master.cpp:163:3: error: ‘pthread_mutex_lock’ was not declared in this scope; did you mean ‘pthread_mutex_t’? 163 | pthread_mutex_lock(&send_mx); | ^~~~~~~~~~~~~~~~~~ | pthread_mutex_t ltr_srv_master.cpp:166:3: error: ‘pthread_mutex_unlock’ was not declared in this scope; did you mean ‘pthread_mutex_t’? 166 | pthread_mutex_unlock(&send_mx); | ^~~~~~~~~~~~~~~~~~~~ | pthread_mutex_t make[2]: *** [Makefile:1344: ltr_srv_master.o] Error 1

KunstDerFuge commented 1 year ago

I have this same problem on Ubuntu 23.04, and was able to fix it by modifying the file ltr_srv_master.cpp and adding #include <pthread.h> as the first line, per this source. I used bieganski's fork and install script and ran into another error which was fixed by incorporating the changes from #182, and then it at least builds and runs with a little more fiddling, manually running make install. Detects my TrackIR, but says there are no permissions to access it -- will try rebooting and then continue to test.

Update: After building again manually (not using the previously mentioned install script), I was able to install the TrackIR firmware, the WINE bridge, and get head tracking working in DCS through Lutris on Ubuntu 23.04. Success!

domrnet commented 1 year ago

Many many thanks. @KunstDerFuge You really saved me I searched for days and never found that I had almost given up. I can now use my ancient trackIR2 that I got probably 15 years ago but haven't been able to use for many years.

Your answer got rid of the error. I didn't use anything to do with WINE so removed those parts as I will be using this natively on xplane11 only. I used the scrip from rfvizarra:master then most steps from https://github.com/uglyDwarf/linuxtrack/issues/190#issuecomment-1270730183 .

Now it works fine I tried on Ubuntu 23.4 and Kubuntu 23.4 and it works well for me. So in the end my steps were..

sudo apt install --install-recommends -y git checkinstall build-essential automake bison gawk flex gcc-multilib g++-multilib gobjc gobjc++ libmxml-dev libssl-dev libusb-1.0-0-dev libcwiid-dev libopencv-dev libv4l-dev libqt5opengl5-dev libqt5webkit5-dev libqt5x11extras5-dev qttools5-dev qttools5-dev-tools nsis

git clone https://github.com/rfvizarra/linuxtrack

modify the file ltr_srv_master.cpp and adding #include as first line

cd linuxtrack/ aclocal autoupdate autoconf automake

./configure --prefix=/home/linuxtrack --with-xplane-sdk=/home/dom/codelt/SDK/CHeaders

make -j

sudo make install