Compilation problem.

A free software implementation of Prince of Persia 1.
User avatar
oitofelix
Wise Scribe
Wise Scribe
Posts: 227
Joined: February 17th, 2016, 1:59 pm
Location: Brazil
Contact:

Re: Compilation problem.

Post by oitofelix »

Giorgos wrote:In case you prefer another debugger, or giving any advanced commands, just tell me.
Thanks for the report. However, it only shows the specific location of the crash (for which no debugging symbols are available). Could you please issue a "bt" command to get a backtrace right after the crash?
Bruno Félix Rezende Ribeiro (oitofelix)
MININIM author
User avatar
Giorgos
Efendi
Efendi
Posts: 15
Joined: May 29th, 2016, 1:58 am

Re: Compilation problem.

Post by Giorgos »

oitofelix wrote: Could you please issue a "bt" command to get a backtrace right after the crash?
Of course! ;)
Giving "bt", returns this:

Code: Select all

(gdb) bt
#0  0x00007fffe9590034 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#1  0x00007fffe958d573 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#2  0x00007fffe95d54a3 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#3  0x00007fffe95ea17b in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#4  0x00007fffe8af0d88 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#5  0x00007fffe8ae34b4 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#6  0x00007fffe8ae41d0 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#7  0x00007fffe8ae45c3 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#8  0x00007fffe8a6ae67 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#9  0x00007fffe8a8d544 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#10 0x00007fffe83c5c7a in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#11 0x00007fffe837587b in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#12 0x00007fffe818f99b in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#13 0x00007fffe79d19c3 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#14 0x00007fffe79d1b4d in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#15 0x00007fffe79d1c2d in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#16 0x00007fffe77fc40c in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#17 0x00007fffe7934222 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#18 0x00007fffe869e332 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#19 0x00007fffe86b1d9e in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#20 0x00007fffe868a15c in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#21 0x00007fffe86b2a97 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#22 0x00007fffe869b93e in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#23 0x00007fffe869ba66 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#24 0x00007fffe959600b in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#25 0x00007fffe9407059 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#26 0x00007fffe774f612 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#27 0x00007fffffffe030 in ?? ()
#28 0x00007fffe95f9281 in ?? () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so
#29 0x00007fffffffe030 in ?? ()
#30 0x00007ffff7deafe8 in _dl_fini () at dl-fini.c:257
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)
And now :?:
I grow old, ever learning many things. Solon.
User avatar
oitofelix
Wise Scribe
Wise Scribe
Posts: 227
Joined: February 17th, 2016, 1:59 pm
Location: Brazil
Contact:

Re: Compilation problem.

Post by oitofelix »

Giorgos wrote:Of course! ;)
Thanks! :)
Giorgos wrote:Giving "bt", returns this: [...]
As GDB says, it seems the stack has been corrupted, what makes the backtrace useless.
Giorgos wrote:And now :?:
How are you exiting MININIM? Sending a SIGINT (Ctrl+C at its terminal REPL)? Pressing Ctrl+Q? Closing its window?

Are you familiar with GDB and debugging in general? Just before you exit MININIM, could you set a breakpoint at the end of function 'play_anim' and step from there until you reach the segmentation fault and then post the gdb.txt log file here?
Bruno Félix Rezende Ribeiro (oitofelix)
MININIM author
User avatar
Giorgos
Efendi
Efendi
Posts: 15
Joined: May 29th, 2016, 1:58 am

Re: Compilation problem.

Post by Giorgos »

oitofelix wrote:Pressing Ctrl+Q?
Yes. Pressing ^Q from inside the game (while fullscreen).
oitofelix wrote: Are you familiar with GDB and debugging in general?
Ehm...well...so and so!
I'm familiar with simple tasks with gdb (I was using it at scummvm testing), but that was long ago and I never was an expert of any kind with gdb. :lol:
oitofelix wrote:Just before you exit MININIM, could you set a breakpoint at the end of function 'play_anim' and step from there until you reach the segmentation fault and then post the gdb.txt log file here?
Let me take a look at the documentation and I'll be back! :)
I grow old, ever learning many things. Solon.
User avatar
oitofelix
Wise Scribe
Wise Scribe
Posts: 227
Joined: February 17th, 2016, 1:59 pm
Location: Brazil
Contact:

Re: Compilation problem.

Post by oitofelix »

Giorgos wrote:I'm familiar with simple tasks with gdb (I was using it at scummvm testing), but that was long ago and I never was an expert of any kind with gdb. :lol:
Great! MININIM doesn't require more than that. ;)
Giorgos wrote:Let me take a look at the documentation and I'll be back! :)
Thanks!
Bruno Félix Rezende Ribeiro (oitofelix)
MININIM author
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Compilation problem.

Post by Norbert »

oitofelix wrote: March 9th, 2017, 8:14 pm
Norbert wrote: then if I run the program it says:
-----
./mininim: error while loading shared libraries: liballegro.so.5.2: cannot open shared object file: No such file or directory
-----

I could probably figure out what the problem is there (maybe a symbolic link would fix it), but I'm busy with other things.
Perhaps that's because you have your distribution's Allegro installed alongside MININIM's fork. Try

Code: Select all

sudo apt-get remove liballegro5-dev liballegro-image5-dev \
  liballegro-audio5-dev liballegro-acodec5-dev liballegro-dialog5-dev
Then don't forget to run

Code: Select all

sudo ldconfig
.
It took me a while, but I've now tried this.
It doesn't fix the problem.
oitofelix wrote: March 9th, 2017, 8:14 pm
Norbert wrote:Regardless, if we both can't make it work out of the box with the available instructions, it needs work.
Well, there are an infinitude of possible configurations for GNU/Linux systems out there. This is life when it comes to building software. I can't possibly foresee every possible corner case in which the build procedure can fail. As experience shows, build recipes are just general guidance to point people committed to the task of building from source to the right direction at best. There is absolutely no guarantee, implicit or otherwise, that they will work for you out of the box if you follow them rigorously. You should just consider yourself lucky, in case they do. That's not to say however that I won't help users building MININIM or that MININIM's building documentation can't be improved.
I may disagree with your stance here. I normally don't run into the kind of problems that I run into with MININIM when manually compiling packages. While there are a lot of possible configurations for GNU/Linux systems, my Mint installation is fairly standard, and the distro is part of the prominent group of Debian/Ubuntu-based systems; even relies on Ubuntu's repositories. I don't think your statement that you "can't possibly foresee every possible corner case" is applicable in this instance; also, I wouldn't ask (or expect) you to. My experience with manually compiling packages is not that one "should just consider yourself lucky, in case [instructions/building work(s)]". If I can't simply follow the instructions, even for a huge package such as Wine, then I'm unlucky.

There's something I've been meaning to ask you. The page at GitHub about the 201701051749 release says "oitofelix released this on Dec 28, 2016". I can imagine you decided to push out this release earlier than expected, but I'm wondering why the version number that includes datetime 2017-01-05_17:49 wasn't changed to match the release date.

Anyway, today I wanted to test the legitimacy of the uploaded MININIM replays I linked to here, saw you made some replay related commits on January 5th of 2017, and therefore opted to manually compile a recent MININIM. (Also, the Windows version crashes in my Wine.)

I decided to clone Allegro. Following MININIM's documentation, I tried...

Code: Select all

$ sudo apt-get build-dep allegro5
Reading package lists... Done
E: Unable to find a source package for allegro5
...which failed; as did cmake and make:

Code: Select all

$ cmake
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

$ make
make: *** No targets specified and no makefile found.  Stop.
I made progress with...

Code: Select all

mkdir build
cd build
cmake ..
make
...and (thus) later "cd ../..".

MININIM compiled, but, unfortunately, I ran into the same shared library error as I did in March:

Code: Select all

$ ./mininim 
./mininim: error while loading shared libraries: liballegro.so.5.2: cannot open shared object file: No such file or directory
I decided to run...

Code: Select all

$ sudo xargs rm < allegro5/build/install_manifest.txt
$ sudo apt-get install liballegro5-dev
...and tried both 201701122309 and the bleeding edge master. Configure ended with:

Code: Select all

[...]
checking for ALLEGRO... no
checking for ALLEGRO... yes
checking for ALLEGRO_IMAGE... no
checking for ALLEGRO_IMAGE... no
configure: error: MININIM requires Allegro 5.0.9 (or superior) image addon
(Strange that it mentions both ALLEGRO and ALLEGRO_IMAGE twice, with the former saying "no" and then "yes".)
I have a suggestion here. I started checking...

Code: Select all

$ sudo dpkg -s liballegro5-dev|grep Version
Version: 2:5.0.11-2
...because the error message appears to address "Allegro 5.0.9".
The suggestion is to modify configure.ac to use:

Code: Select all

AC_MSG_ERROR([MININIM requires Allegro-image $allegro_minver (or superior)]))])
instead of:

Code: Select all

AC_MSG_ERROR([MININIM requires Allegro $allegro_minver (or superior) image addon]))])
The same goes for the messages about Allegro-audio, Allegro-acodec and Allegro-dialog.

But yeah, now make says ALLEGRO_MENU and such are unknown.
Oh well, 2.15am local time. Time for bed. :P
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Compilation problem.

Post by David »

I managed to compile MININIM on Linux, but I had to change the custom version of Allegro a bit, to fix compilation errors.
Here are the changes:

Code: Select all

$ git diff
diff --git a/include/allegro5/allegro_opengl.h b/include/allegro5/allegro_opengl.h
index 0f86a6768..2d9f77f6b 100644
--- a/include/allegro5/allegro_opengl.h
+++ b/include/allegro5/allegro_opengl.h
@@ -101,12 +101,14 @@

 #else /* ALLEGRO_MACOSX */

+#define GL_GLEXT_PROTOTYPES // David
 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */
 #define __glext_h_
 #define __glxext_h_
 #include <GL/gl.h>
 #undef  __glext_h_
 #undef  __glxext_h_
+#undef GL_VERSION_3_0 // David

 #endif /* ALLEGRO_MACOSX */

diff --git a/include/allegro5/opengl/GLext/glx_ext_defs.h b/include/allegro5/opengl/GLext/glx_ext_defs.h
index 49c502091..7cb131fb9 100644
--- a/include/allegro5/opengl/GLext/glx_ext_defs.h
+++ b/include/allegro5/opengl/GLext/glx_ext_defs.h
@@ -1,3 +1,4 @@
+#define GLX_GLXEXT_PROTOTYPES // David
 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */
 #define __glxext_h_
 #include <GL/glx.h>
Two things that I don't understand:
1. If the OpenGL headers declare the prototypes only if asked to, and Allegro needs those prototypes, then why aren't those defines already defined by Allegro?
2. If GL_VERSION_3_0 is defined then _ALLEGRO_GL_VERSION_3_0 will not be defined, and thus a certain struct will not contain the GetStringi member, which is needed here.

After I compile MININIM, it starts, but immediately crashes with this:

Code: Select all

$ ./mininim
./mininim: can't get setting '[REPLAY FAVORITE 0] FILE' from '/home/nagy/.config/mininim/mininim.mcf': No such file or directory
./mininim: can't get setting '[REPLAY FAVORITE 0] CYCLE' from '/home/nagy/.config/mininim/mininim.mcf': No such file or directory
The program 'mininim' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
  (Details: serial 32 error_code 9 request_code 155 minor_code 4)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
This one is probably not MININIM's fault, though, since for example glxinfo crashes as well, with the same request code (major 155, minor 4).

Code: Select all

$ glxinfo
name of display: :0.0
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  155 (NV-GLX)
  Minor opcode of failed request:  4 ()
  Resource id in failed request:  0x420000d
  Serial number of failed request:  69
  Current serial number in output stream:  69
The GLX crash is probably because I installed the nVidia driver manually, based on this: https://adufray.com/blog/2018/06/02/nvi ... -on-bionic
(Note: Firefox blocks the site and shows a HTTPS error, but the site loads fine in Chromium or CURL.)
I installed it manually because:
* The nVidia drivers available from APT don't support my (decade-old) graphics card anymore.
* The nouveau driver works (IIRC, even glxinfo works with it), but it will switch the screen to 640×480 and won't let me select any other resolution. (But now I see that the internet has some solutions for this, I might try them.)

Oddly enough, the Snap version of SDLPoP used to crash with a similar error, but it works currently.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Compilation problem.

Post by David »

David wrote: July 13th, 2019, 10:01 am * The nouveau driver works (IIRC, even glxinfo works with it), but it will switch the screen to 640×480 and won't let me select any other resolution. (But now I see that the internet has some solutions for this, I might try them.)
While doing the "fix", I managed to bork up my Linux so much that I couldn't log in on the GUI, only in a console (Ctrl+Alt+F1).
(Logging in on the GUI could actually start the desktop manager, but it crashed immediately and the system returned to the login screen.)
Since I had no idea how to fix it, I installed Ubuntu 16.04 from scratch in place of the broken 18.04.
Now I could compile MININIM and the custom Allegro, without any changes to their sources.
And MININIM starts without any errors!

The only problem is that the nouveau driver sometimes hangs the whole system, and garbles the screen while doing so.
This is why I switched to nVidia's drivers in the first place...
I wonder if this bug of nouveau was fixed in Ubuntu 18.04.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1782
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Compilation problem.

Post by atrueprincefanfrom18 »

I am getting a compilation error on Ubuntu 18.04, when I one-click-downloaded it from Apoplexy 3.8.

Code: Select all

./mininim: error while loading shared libraries: liballegro.so.5.0: cannot open shared object file: No such file or directory
It's the same error as described here.

I tried

Code: Select all

$ make all
but it doesn't work.

I searched a lot, but didn't get any working results. Any working way I can compile it again?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Compilation problem.

Post by Norbert »

atrueprincefanfrom18 wrote: September 25th, 2020, 6:11 amerror while loading shared libraries: liballegro.so.5.0
Most likely your distro's repository provides liballegro5.2, so 5.2 instead of 5.0.

-----
Solution 1.
-----
The easiest solution is to install wine, and then edit+recompile apoplexy.c to make it use the Windows executable of MININIM. The change you need to make to apoplexy.c is in the function RunLevelM(), which you can find by searching for "void RunLevelM". In that function, change (on line 15464 of apoplexy 3.9):
snprintf (sToWrite, MAX_TOWRITE, "..%s%s%s %s %i 2> %s\n",
to
snprintf (sToWrite, MAX_TOWRITE, "wine ..%s%s%s.exe %s %i 2> %s\n",

-----
Solution 2.
-----
Alternatively, you could try to recompile MININIM. Here you will run into the problem that MININIM does not use a simple Makefile (like apoplexy or SDLPoP) but GNU Autoconf. You would have to modify configure.ac to have PKG_CHECK_MODULES detect 5.2, which may not work. After modifying configure.ac, run "autoreconf -i", then ./configure, then make, make install. Personally, I've moved away from GNU Autoconf completely for all my projects. My personal opinion is that GNU Autoconf is terrible, for reasons including but not limited to those mentioned here.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1782
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Compilation problem.

Post by atrueprincefanfrom18 »

Norbert wrote: September 25th, 2020, 12:19 pm -----
Solution 2.
-----
Alternatively, you could try to recompile MININIM. Here you will run into the problem that MININIM does not use a simple Makefile (like apoplexy or SDLPoP) but GNU Autoconf. You would have to modify configure.ac to have PKG_CHECK_MODULES detect 5.2, which may not work. After modifying configure.ac, run "autoreconf -i", then ./configure, then make, make install. Personally, I've moved away from GNU Autoconf completely for all my projects. My personal opinion is that GNU Autoconf is terrible, for reasons including but not limited to those mentioned here.
Thanks Norbert for trying to help me out.

I tried #1, but somehow wine is not able to handle the program. I am getting lot of error messages, so I think I should give #2 a try. Can you please help me out on how to do this?

How do I modify configure.ac file? How to make it detect 5.2? Otherwise my last option (which is too RAM intensive for my PC) would be to install it in the Windows which would be on the VirtualBox (which take a lot of battery and memory, I can't keep it on for a lot of time and I want to avoid it unless it's the last option).

On the other hand, I am curious, what is it that is preventing to create a single Makefile similar to Apoplexy and SDLPoP? It would be nice to have a single file and do

Code: Select all

$ make all
and have the program compiled.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Compilation problem.

Post by Norbert »

atrueprincefanfrom18 wrote: September 25th, 2020, 5:36 pmI tried #1, but somehow wine is not able to handle the program. I am getting lot of error messages, [...]
Did you replace the line correctly?
Note that it's more than just adding "wine ". You also need to add the ".exe" bit.
If you did, what are the error messages?
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1782
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Compilation problem.

Post by atrueprincefanfrom18 »

Norbert wrote: September 25th, 2020, 8:26 pm
atrueprincefanfrom18 wrote: September 25th, 2020, 5:36 pmI tried #1, but somehow wine is not able to handle the program. I am getting lot of error messages, [...]
Did you replace the line correctly?
Note that it's more than just adding "wine ". You also need to add the ".exe" bit.
If you did, what are the error messages?
I ran the wine directly and it didn't work. So even if I edit Apoplexy's code it's definitely not gonna work as it's just going to invoke the same command, right?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
oitofelix
Wise Scribe
Wise Scribe
Posts: 227
Joined: February 17th, 2016, 1:59 pm
Location: Brazil
Contact:

Re: Compilation problem.

Post by oitofelix »

atrueprincefanfrom18 wrote: September 25th, 2020, 6:11 am I am getting a compilation error on Ubuntu 18.04, when I one-click-downloaded it from Apoplexy 3.8.

Code: Select all

./mininim: error while loading shared libraries: liballegro.so.5.0: cannot open shared object file: No such file or directory
It's the same error as described here.
I guess this may help you viewtopic.php?f=127&t=4601. Let me know.
Bruno Félix Rezende Ribeiro (oitofelix)
MININIM author
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Compilation problem.

Post by Norbert »

atrueprincefanfrom18 wrote: September 25th, 2020, 8:37 pmI ran the wine directly and it didn't work.
If you want, you could post error message(s), and then perhaps we could help.
Post Reply