Trouble compiling GIMX on Manjaro (Arch Linux)

Talk about anything concerning the source code.
Post Reply
User avatar
SteamController
Posts: 22
Joined: Mon Oct 24, 2022 6:27 pm
Contact:

Trouble compiling GIMX on Manjaro (Arch Linux)

Post by SteamController »

I'm not an expert on compiling programs but I'm trying to get GIMX running on Manjaro (basically Arch Linux) so I don't have to dual-boot into PopOS just to use it. I know it's not officially supported since the wiki only has instructions for Debian and Fedora based distros, but I figure the error is probably due to a compilation flag since it says it is treating warnings as errors:

Code: Select all

make -C shared
make -C loader
make -C po
make[1]: Entering directory '/home/mbutler/src/GIMX/shared'
make -C gimxlog UHID=1
make[1]: Entering directory '/home/mbutler/src/GIMX/po'
make[1]: 'all' is up to date.
make[1]: Leaving directory '/home/mbutler/src/GIMX/po'
make -C gimxcontroller UHID=1
make -C gimxusb UHID=1
make[1]: Entering directory '/home/mbutler/src/GIMX/loader'
make[2]: Entering directory '/home/mbutler/src/GIMX/shared/gimxlog'
make[2]: Entering directory '/home/mbutler/src/GIMX/shared/gimxcontroller'
make[2]: Entering directory '/home/mbutler/src/GIMX/shared/gimxusb'
g++ -Wall -Wextra -Werror -O3 -I../shared `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-cast-function-type -Wno-deprecated-copy -Wno-ignored-qualifiers  -c -o gimx-loader.o gimx-loader.cpp
cc -fPIC -Wall -Wextra -Werror -O3 -Iinclude -I../ -DGLOG_NAME=gimxlog  -c -o src/glog.o src/glog.c
cc -fPIC -Iinclude -Wall -Wextra -Werror -O3 -I../ -DGLOG_NAME=gimxcontroller  -c -o src/controller.o src/controller.c
cc -fPIC -Wall -Wextra -Werror -O3 -Iinclude -I. -I../ -DGLOG_NAME=gimxusb  -c -o src/gusb.o src/gusb.c
src/controller.c: In function ‘controller_get_axis_index’:
src/controller.c:361:10: error: the comparison will always evaluate as ‘true’ for the address of ‘name’ will never be NULL [-Werror=address]
  361 |       if(controllers[C_TYPE_SIXAXIS]->axes[i].name)
      |          ^~~~~~~~~~~
In file included from src/controller.c:6:
src/../include/controller.h:46:14: note: ‘name’ declared here
   46 |   const char name[AXIS_NAME_MAX_SIZE];
      |              ^~~~
cc -Iinclude -I../ -DGLOG_NAME=gimxlog -fPIC -Wall -Wextra -Werror -O3 -Wall -Wextra -Werror -O3 -shared src/glog.o -o libgimxlog.so  
cc1: all warnings being treated as errors
make[2]: *** [<builtin>: src/controller.o] Error 1
make[2]: Leaving directory '/home/mbutler/src/GIMX/shared/gimxcontroller'
make[1]: *** [Makefile:35: build-gimxcontroller] Error 2
make[1]: *** Waiting for unfinished jobs....
g++ -Wall -Wextra -Werror -O3 -I../shared `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-cast-function-type -Wno-deprecated-copy -Wno-ignored-qualifiers  -c -o loaderApp.o loaderApp.cpp
make[2]: Leaving directory '/home/mbutler/src/GIMX/shared/gimxlog'
In function ‘get_string_descriptor’,
    inlined from ‘get_string_descriptor’ at src/gusb.c:523:12:
src/gusb.c:569:120: error: pointer ‘data’ may be used after ‘realloc’ [-Werror=use-after-free]
  569 |         LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | index, descriptors->langId0.wData[0], data, descriptor->bLength, DEFAULT_TIMEOUT);
      |                                                                                                              ~~~~~~~~~~^~~~~~~~~
src/gusb.c:559:18: note: call to ‘realloc’ here
  559 |     void * ptr = realloc(data, descriptor->bLength * sizeof(*data));
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [<builtin>: src/gusb.o] Error 1
make[2]: Leaving directory '/home/mbutler/src/GIMX/shared/gimxusb'
make[1]: *** [Makefile:35: build-gimxusb] Error 2
make[1]: Leaving directory '/home/mbutler/src/GIMX/shared'
make: *** [Makefile:15: build-shared] Error 2
make: *** Waiting for unfinished jobs....
cc -L../shared/gimxtime  gimx-loader.o loaderApp.o  `wx-config --libs` -lstdc++ -lgimxtime -o gimx-loader
/usr/bin/ld: cannot find -lgimxtime: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [<builtin>: gimx-loader] Error 1
make[1]: Leaving directory '/home/mbutler/src/GIMX/loader'
make: *** [Makefile:15: build-loader] Error 2
Specifically:

Code: Select all

src/controller.c: In function ‘controller_get_axis_index’:
src/controller.c:361:10: error: the comparison will always evaluate as ‘true’ for the address of ‘name’ will never be NULL [-Werror=address]
  361 |       if(controllers[C_TYPE_SIXAXIS]->axes[i].name)
Is that right? Will that always evaluate to "true" so we can just delete the if statement?

EDIT: And the second warning/error looks to be some security use-after-free protection detection.
-- -- --
:mrgreen: Michael from USA here. I'm selling GIMX USB adapters on eBay and Etsy!
Compact design supporting modern USB-C cables. :P
Image
User avatar
GoDlike
Posts: 1318
Joined: Thu Apr 28, 2016 12:47 pm
Location: Poland

Re: Trouble compiling GIMX on Manjaro (Arch Linux)

Post by GoDlike »

Try disabling that setting that treats warnings as errors.
My hardware: PS3 Slim CFW 4.80 | PS4 Pro 500 Million LE | PS5 | Xbox Series X
Steam: Godlike_RU | PSN: GoDlike_RU | XBL: GoDlike
User avatar
SteamController
Posts: 22
Joined: Mon Oct 24, 2022 6:27 pm
Contact:

Re: Trouble compiling GIMX on Manjaro (Arch Linux)

Post by SteamController »

Thanks, your idea helped. I went and started deleting -Werror in various Makedefs files so it wouldn't fail on the new warnings. Now my problem is that ncurses.h is not found. I have ncurses installed but I'm guessing I don't have the .c and .h files (includes) installed. Other distros seem to have ncurses-devel package but it looks like there is no such package on Arch/Manjaro sadly. I'm not exactly sure how to get those on my system or put them in the right spot (probably somewhere in /usr/include)
-- -- --
:mrgreen: Michael from USA here. I'm selling GIMX USB adapters on eBay and Etsy!
Compact design supporting modern USB-C cables. :P
Image
User avatar
SteamController
Posts: 22
Joined: Mon Oct 24, 2022 6:27 pm
Contact:

Re: Trouble compiling GIMX on Manjaro (Arch Linux)

Post by SteamController »

ok wow, somehow I hacked it after some google searching about ncurses.h includes and it works now!

Besides removing -Werror, I follow this answer: https://stackoverflow.com/questions/261 ... -libraries

Doing that put ncurses.h in this folder:/home/mbutler/.local/include/ncursesw/ncurses.h

Then, I did export LIB_PATH=$HOME/.local in my terminal and then kept running make -j 4 to find which compile steps failed and ran them manually.

Finally I got to the step that tried to compile display.c and I added this flag: -I/home/mbutler/.local/include and it compiled. Then, make -j 4 on the whole project worked. Then I did sudo make install and now I can run it.

That was a crazy journey, I hope I didn't break my system!

EDIT: and now I'm reading https://aur.archlinux.org/cgit/aur.git/tree/?h=gimx-git to see how they fixed this and I think I could have done it more easily by tweaking the PKGBUILD! Oh well!
-- -- --
:mrgreen: Michael from USA here. I'm selling GIMX USB adapters on eBay and Etsy!
Compact design supporting modern USB-C cables. :P
Image
User avatar
GoDlike
Posts: 1318
Joined: Thu Apr 28, 2016 12:47 pm
Location: Poland

Re: Trouble compiling GIMX on Manjaro (Arch Linux)

Post by GoDlike »

I admit our source code structure is a bit messed up. I'm glad you got it running. Have fun with gimx.
My hardware: PS3 Slim CFW 4.80 | PS4 Pro 500 Million LE | PS5 | Xbox Series X
Steam: Godlike_RU | PSN: GoDlike_RU | XBL: GoDlike
User avatar
SteamController
Posts: 22
Joined: Mon Oct 24, 2022 6:27 pm
Contact:

Re: Trouble compiling GIMX on Manjaro (Arch Linux)

Post by SteamController »

alicebobby wrote: Fri Feb 23, 2024 2:23 am Many thanks; your suggestion was helpful. To make it work with the new warnings, I went ahead and began removing -Werror from other Makedefs files. Curses.h cannot be found, which is my current issue. It is likely that I do not have the includes (.c and.h) installed even if I have ncurses installed. Curses-devel appears to be a package available for other distributions, but alas, Arch/Manjaro doesn't appear to contain it. Although they should be in /usr/include, I'm not entirely sure how to get those on my system or where to put them.  tunnel rush 
To be honest I just switched to flashing GIMX on my KDE Ubuntu 22.04 laptop instead. If you have an extra computer laying around, or can dual-boot, it might just be easier that way.
-- -- --
:mrgreen: Michael from USA here. I'm selling GIMX USB adapters on eBay and Etsy!
Compact design supporting modern USB-C cables. :P
Image
Post Reply