How to compile SDLPoP for Windows?

Open-source port of PoP that runs natively on Windows, Linux, etc.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

How to compile SDLPoP for Windows?

Post by atrueprincefanfrom18 »

How can people play on custom levels (with modified source code) on Windows?
On Linux, we can compile all and run ./prince through command line, but how to compile all into an EXE without having Windows installation?
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: 5749
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

atrueprincefanfrom18 wrote: April 4th, 2021, 11:24 am[...], but how to compile all into an EXE without having Windows installation?
You could follow its Dev-C++ instructions, through Wine.
I also make the Windows executables for apoplexy with Dev-C++ through Wine.

It should also be possible to cross-compile using just the command-line, but I've never found a solid tutorial for that.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: SDLPoP; David's open-source port of PoP

Post by atrueprincefanfrom18 »

Norbert wrote: April 4th, 2021, 2:11 pm You could follow its Dev-C++ instructions, through Wine.
I also make the Windows executables for apoplexy with Dev-C++ through Wine.
I had some issues with Wine for other stuff, so I created a virtual machine and it has Windows 10 on it. I got this far, but I'm not understanding what to do after downloading the ZIP files. It has a lot of files in it. Which ones to copy and paste? And mainly where?

This line says that I need to extract the contents of the i686-w64-mingw32 folder but there don't seem to have any folder with that name... I have to download the development libraries from both of the links right?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: SDLPoP; David's open-source port of PoP

Post by dmitrys »

Download the "tar.gz" files from the "development libraries" section in these 2 links.

https://www.libsdl.org/download-2.0.php
https://www.libsdl.org/projects/SDL_image/

Copy files from the "i686-..." folders from those archives into the "Dev-Cpp\MinGW64" folder.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: SDLPoP; David's open-source port of PoP

Post by atrueprincefanfrom18 »

dmitrys wrote: April 5th, 2021, 5:08 pm Download the "tar.gz" files from the "development libraries" section in these 2 links.

https://www.libsdl.org/download-2.0.php
https://www.libsdl.org/projects/SDL_image/

Copy files from the "i686-..." folders from those archives into the "Dev-Cpp\MinGW64" folder.
Oh, the tar files? But why? I'm developing on Windows! Shouldn't I be downloading the Windows files? Anyway, I'll try this today.
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: SDLPoP; David's open-source port of PoP

Post by dmitrys »

Dev-CPP uses GNU C++. I believe ZIP files are for Visual Studio.

I have tried compiling it under VS and the EXE was significantly larger. It might have been my imagination but the game felt slightly laggier.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: SDLPoP; David's open-source port of PoP

Post by atrueprincefanfrom18 »

dmitrys wrote: April 5th, 2021, 5:08 pm Download the "tar.gz" files from the "development libraries" section in these 2 links.

https://www.libsdl.org/download-2.0.php
https://www.libsdl.org/projects/SDL_image/

Copy files from the "i686-..." folders from those archives into the "Dev-Cpp\MinGW64" folder.
Sorry, I don't understand this. The i686... folder has three folders in it. What to to do with them? Or copy and paste the files from each of the folders to the respective folders in Dev-Cpp\MinGW64\?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: SDLPoP; David's open-source port of PoP

Post by dmitrys »

Yes, just copy all the files/folders from each of the i686 folders into Dev-Cpp\MinGW64\.
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: How to compile SDLPoP for Windows?

Post by David »

(I moved these posts into a separate thread.)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP; David's open-source port of PoP

Post by David »

atrueprincefanfrom18 wrote: April 6th, 2021, 8:32 am Sorry, I don't understand this. The i686... folder has three folders in it. What to to do with them?
Sorry that the readme is unclear.
Do what Dmitrys wrote.

I was implying that when you copy the bin, include, etc. folders to a place where folders with the same name already exist, then the contents of the corresponding folders are merged (recursively).
Both Total Commander and Windows Explorer do this, though the latter asks first if I want to merge.

I also realized that the path of the destination folder is not given explicitly.
And it's incorrect even: it's given as "the Dev-Cpp folder", but it should say the MinGW64 folder within it.

I will clarify the Readme.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: How to compile SDLPoP for Windows?

Post by atrueprincefanfrom18 »

No!!! :|

I tried for hours but failed... :(
It's very difficult to build the environment.

Can anyone please just compile this on Windows and upload/PM me?

Here's the file:

mod-and-custom-sdlpop.zip
(2.67 MiB) Downloaded 53 times

Sincerely appreciate your efforts!
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: How to compile SDLPoP for Windows?

Post by dmitrys »

Here is the compiled EXE (zipped).

It looks like you have the wrong version of the library installed (x64 instead of x86) based on the ".o" files that I had to delete.

No back button in the mod. :D
Attachments
prince.zip
(137.6 KiB) Downloaded 59 times
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: How to compile SDLPoP for Windows?

Post by David »

dmitrys wrote: April 11th, 2021, 7:39 pm It looks like you have the wrong version of the library installed (x64 instead of x86) based on the ".o" files that I had to delete.
Additionally they are in ELF format, but Dev-C++ creates *.o files in COFF format.
I think they were created when Amogh compiled SDLPoP for Linux.
They even contain an Ubuntu version string.

If I just press Compile on the files posted by Amogh, I get errors like this:

Code: Select all

[..]\ld.exe	i386:x86-64 architecture of input file `main.o' is incompatible with i386 output
[..]\ld.exe	i386:x86-64 architecture of input file `seg008.o' is incompatible with i386 output
[..]\ld.exe	i386:x86-64 architecture of input file `seg007.o' is incompatible with i386 output
etc.
followed by:
[...]\seg008.o	In function `get_image':
[...]\seg008.c	(.text+0x8d7): undefined reference to `_printf_chk'
[...]\seg008.c	(.text+0x8fc): undefined reference to `_printf_chk'
[...]\seg008.c	(.text+0x915): undefined reference to `_printf_chk'
etc.
So what happens here?
Dev-C++ sees that the *.o files are already there and newer than the corresponding *.c files, so it doesn't recompile them.
So it only tries to link the *.o files together into prince.exe, but that fails because the *.o files have a different architecture from what is set in the project file.
But even if I set the project to 64-bit, the "undefined reference" errors still appear.

The solution is to delete the *.o files.
In Dev-C++, the Rebuild All button does that, and then it compiles everything.

@Amogh,
1. What error messages did you get? Were they similar to what I show above?
2. If you press Rebuild All instead of Compile, does that compile SDLPoP without errors?
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: How to compile SDLPoP for Windows?

Post by atrueprincefanfrom18 »

dmitrys wrote: April 11th, 2021, 7:39 pm Here is the compiled EXE (zipped).
Thanks!
dmitrys wrote: April 11th, 2021, 7:39 pm No back button in the mod. :D
Sorry, didn't get it... What do you mean?
David wrote: April 11th, 2021, 8:44 pm I think they were created when Amogh compiled SDLPoP for Linux.
Yes, the attached ZIP is uploaded from a Linux computer, yes, were compiled for Linux.
David wrote: April 11th, 2021, 8:44 pm In Dev-C++, the Rebuild All button does that, and then it compiles everything.

@Amogh,
1. What error messages did you get? Were they similar to what I show above?
2. If you press Rebuild All instead of Compile, does that compile SDLPoP without errors?
Yes, I did try to rebuild it, but the common.h had problems, compiler was not finding <stdio.h>!
Maybe it was using g++ to compile instead of gcc. I tried to add the environment variables and tried running it too, but in the end, nothing was working, hence I gave up and requested here to compile it for me. And no, as I just mentioned, it was not able to find <stdio.h>, it couldn't compile.

Maybe if I just fix the compiler issue, it might work, but again, it was a lot of time consuming.

I guess there's a bit of lack of enough (written) documentation (and video documentation too). I couldn't really find a good video explaining what to do. Maybe David and/or dmitrys can record a video on how to set up the environment, it might be good for other people who want to develop a mod involving custom SDLPoP source code (and me too!).
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
User avatar
dmitrys
Developer
Developer
Posts: 195
Joined: October 1st, 2020, 6:05 am

Re: How to compile SDLPoP for Windows?

Post by dmitrys »

The left arrow key was not doing anything. Kid could only move forward.

All I have to do is install the Dev-CPP using its installer. And then copy the entire file/folder structure from i686-* folders in SDL2 and SDL_Image2 *mingw.tar.gz archives right into "Dev-CPP\MinGW-64\" folder. Delete any ".o" files in the src folder and do a rebuild. It should work.

Dev-CPP already comes with the GNU C/C++ compiler so no additional configuration is needed.

"port_release.dev" is the file to load when opening the project.

I use real Windows 10, not WINE though.
Post Reply