[Sep 2020 ed.] PCem MSYS2 build guide (with wxWidgets)

Discussion of development and patch submission.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

[Sep 2020 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

The September 2020 Edition
[2018-02-13: Update instructions on compiling PCem after update...
[2018-02-14: Added autoreconf into the mix. Should hopefully make to process more robust.

Thanks to darksabre76, compiling PCem in MSYS2 has gotten even easier than it was before. I now present to you the September 2020 edition of this guide.

Download and install MSYS2


Download MSYS2 from http://www.msys2.org/. I686 or x86_64 doesn't matter. Install it.
For the rest of this guide, I will refer to the installation directory of MSYS2 (eg: C:\msys64) as <msys>

When the install finishes, it should open the MSYS2 MSYS shell. We next need to update our MSYS2 installation by typing the following in the shell:

Code: Select all

$ pacman -Syuu
If it asks if you want to remove catgets, do so. There appears to be a conflict at time of writing.

You will be asked to close the terminal without exiting. Just click the x at the window corner, and wait till it crashes

From the start menu, search for MSYS, and select MSYS2 MSYS. Run the previous pacman command again:

Code: Select all

$ pacman -Syuu
MSYS2 has now been updated to the latest packages.

Install prerequisites

From the MSYS2 MSYS shell, type the following to install the mingw-w64 32 bit toolchain, base-devel (for autotools such as autoreconf), mercurial (used to download PCem later), and unzip:

Code: Select all

$ pacman -S mingw-w64-i686-toolchain base-devel git unzip
When it asks what to install, press <enter> to select all for installation.

Next, we install the PCem dependencies OpenAL, SDL2 and wxWidgets:

Code: Select all

$ pacman -S mingw-w64-i686-SDL2 mingw-w64-i686-openal mingw-w64-i686-wxWidgets
Download and install the npcap SDK (for networking):

Code: Select all

$ wget https://nmap.org/npcap/dist/npcap-sdk-1.05.zip
$ unzip -d npcap-sdk-1.05/ npcap-sdk-1.05.zip
$ cd npcap-sdk-1.05
$ cp -r Include/* /mingw32/include/
$ cp -r Lib/* /mingw32/lib/
Close the MSYS2 MSYS shell.

For pcap networking to work, download the Npcap installer from https://nmap.org/npcap/

Install Npcap. Ensure to check the "Install Npcap in WinPcap API-compatible Mode" checkbox during the installation process.

Prepare and Compile PCem

Open the MSYS2 MinGW 32-bit shell from the start menu. Note, do NOT use the "MSYS2 MSYS" shell for the rest of this guide, it won't work!

Download PCem from bitbucket using mercurial:

Code: Select all

$ git clone https://github.com/sarah-walker-pcem/pcem
$ cd pcem
This is where darksabre76 made our lives much easier. As of commit 45a203d, we no longer have to use (and maintain) a special Makefile. The following should configure and compile PCem for us:

Code: Select all

$ autoreconf -i
$ ./configure --enable-networking --enable-release-build
$ mingw32-make -j
Hopefully, PCem should compile without errors.

Post Compilation Steps
Create a pcem runtime directory structure with configs, nvr, roms and screenshot folders. Populate roms folder etc.
If they exist, delete all current exe and dll files

Alternatively, the parent pcem directory contains the required directory structure.

Copy the newly compiled pcem.exe file into this directory
Also copy the following libraries from the <msys>\mingw32\bin directory:

Code: Select all

libgcc_s_dw2-1.dll
libjpeg-8.dll
libopenal-1.dll
libpng16-16.dll
libstdc++-6.dll
libtiff-5.dll
libwinpthread-1.dll
SDL2.dll
zlib1.dll
all wx*.dll files

dreamer suggests that liblzma-5.dll may also be required.
Run PCem. If for some reason it complains of missing dlls, they should be in the directory you copied the previous dlls from.

Recompiling after updated revisions

From the MSYS2 MinGW 32-bit shell:

Code: Select all

$ cd ~/pcem
$ mingw32-make clean
$ hg pull && hg update default
$ autoreconf -i
$ ./configure --enable-networking --enable-release-build
$ mingw32-make -j
Hopefully this guide will have got you up and running with a freshly compiled PCem, ready for testing.
Last edited by shermanp on Sat 26 Sep, 2020 12:16 pm, edited 15 times in total.
jznomoney
Posts: 97
Joined: Sat 06 Dec, 2014 9:11 pm

Re: PCem MSYS2 build guide (with wxWidgets)

Post by jznomoney »

I want to thank you for this guide. I got it to work. Anyone have any idea how to get network working?
User avatar
omarsis81
Posts: 945
Joined: Thu 17 Dec, 2015 6:20 pm

Re: PCem MSYS2 build guide (with wxWidgets)

Post by omarsis81 »

I didn't try it yet, but thanks for the job!
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: PCem MSYS2 build guide (with wxWidgets)

Post by basic2004 »

I changed cdrom-ioctl.c

Code: Select all

__MINGW64__
to

Code: Select all

__MINGW32__
so this compiled correctly.

This modification was JosepMa's advice, thanks to him.
https://pcem-emulator.co.uk/phpBB3/view ... 6624#p6624

I checked this makefile, maybe this will use system libraries (-ltiff -ljpeg -lpng -lz -lregex -lexpat).
original makefile use built-in wxWidgets libraries, there appears linker error when installing wxWidgets by pacman.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

basic2004 wrote:I changed cdrom-ioctl.c

Code: Select all

__MINGW64__
to

Code: Select all

__MINGW32__
so this compiled correctly.

This modification was JosepMa's advice, thanks to him.
https://pcem-emulator.co.uk/phpBB3/view ... 6624#p6624

I checked this makefile, maybe this will use system libraries (-ltiff -ljpeg -lpng -lz -lregex -lexpat).
original makefile use built-in wxWidgets libraries, there appears linker error when installing wxWidgets by pacman.

Problem with __MINGW32__ is it breaks compilation with legacy mingw.

Yeah, the pacman version of wxWidgets does not include the optional libraries libwxtiff, libwxjpeg etc. Fortunately, I don't think these specifically are needed, it seems to work alright without them.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: PCem MSYS2 build guide (with wxWidgets)

Post by darksabre76 »

I got the networking build to work with a couple of very tiny tweaks:

- Downloading the developer pack from https://www.winpcap.org/devel.htm
- Extracting the "include" and "lib" folders to <msys>\mingw32 (thanks to ruben_balea for figuring it out)
- Changing the top of nethandler.c from

Code: Select all

#ifdef _WIN32
#include <windows.h>
#include <winsock2.h>
#endif
to

Code: Select all

#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#endif
- And bringing the new msys makefile up to par with "Makefile.mingw-wx-sdl2-network". I have attached my changed version. Same thing as above, just remove the .txt extension before trying to use it.

Hope this helps someone :D

Edit: Almost forgot, you need to put the file "wpcap.dll" in the runtime folder for the networking stuff to actually end up working. At least, it was needed for the non-wxWidgets networking build.
Attachments
Makefile.msys2-wx-sdl2-network.txt
(4.04 KiB) Downloaded 993 times
Last edited by darksabre76 on Tue 10 Oct, 2017 10:49 pm, edited 1 time in total.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea »

Hi,
Many thanks to everybody for this work, on past night I got some headache trying to bring wxWidgets to my old (and perhaps corrupt) Msys installation.
- Extracting the "include" and "lib" folders to every place where there were already include and lib folders (I never did figure out which one actually ended up working)
In my case I tried to copy those folders first to "C:\msys64\mingw32" and PCem compiled on the first try with "Makefile.msys2-wx-sdl2-network"

And the network card has returned to my Windows 95 (I do use SLiRP because I'm over WIFI but WinPcap should be fine too)
snapshot.png
snapshot.png (29.14 KiB) Viewed 51855 times
User avatar
dreamer
Posts: 40
Joined: Wed 28 Dec, 2016 11:56 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by dreamer »

You also have to copy liblzma-5.dll from the mingw32/bin folder, and make sure you run the initial pacman -Syu (restart) pacman -Su commands when you install msys2. Other than that it works beautifully!
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: PCem MSYS2 build guide (with wxWidgets)

Post by darksabre76 »

Updated build files with the new sound driver.
Attachments
Makefile.msys2-wx-sdl2-network.txt
(4.05 KiB) Downloaded 1003 times
Makefile.msys2-wx-sdl2.txt
(3.88 KiB) Downloaded 978 times
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

darksabre76 wrote:Updated build files with the new sound driver.
Great minds think alike, I have just updated the first post.

I have also added networking to the initial post.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

First post has updated makefiles for commit ab5cef9
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea »

:arrow: EDIT: It was my fault, for some reason I was using one or more invalid dll's, restoring the previous ones from a backup fixed those errors:

Code: Select all

The procedure entry point _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc could not be located in the dynamic link library C:\msys64\home\user\PCem_V13\PCem-wx-SDL2.exe. 
The procedure entry point _ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE4findEPKwjj could not be located in the dynamic link library C:\msys64\home\user\PCem_V13\wxmsw30u_adv_gcc_custom.dll. 
The procedure entry point _ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE4findEPKwjj could not be located in the dynamic link library C:\msys64\home\user\PCem_V13\wxmsw30u_core_gcc_custom.dll. 
The procedure entry point _ZNKSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEE12find_last_ofEPKwjj could not be located in the dynamic link library C:\msys64\home\user\PCem_V13\wxbase30u_gcc_custom.dll. 
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

Hi all,

The OP has been updated with a revised guide, and makefiles required for the T1000 commit.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

Hi all,

The Makefiles have been updated to support the Zip drive additions that Sarah has added.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

Hi all,

The guide has been streamlined and updated now that autotools can be used to configure and make PCem in MSYS2.

Please let me know if you have any problems.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

Hi all,

I've updated the guide for (hopefully) working steps to compile new revisions, especially those that have an updated Makefile.am
misterj88
Posts: 6
Joined: Wed 10 Sep, 2014 2:03 pm

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by misterj88 »

Love this guide - have successfully built using this guide - thank you! Just one quick note - to get autoreconf I had to run:

Code: Select all

$ pacman -S base-devel
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea »

I did the same (installed everything included in msys2-devel) because I got this message before:

Code: Select all

$ Mingw32-make -j
CDPATH="${ZSH_VERSION+.}:" && cd . && C:/msys64/usr/bin/sh.exe /home/user/pcem/missing aclocal-1.15
/home/user/pcem/missing: línea 80: aclocal-1.15: no se encontró la orden
WARNING: 'aclocal-1.15' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
Mingw32-make: *** [Makefile:355: aclocal.m4] Error 127

And now PCem hangs at machine start when I enable Sound Blaster 16 or AWE32, with all other sound, network and video cards it seems to be fine.
No matter what config and so on, with a fresh setup and loading any machine with a SB16 crashes PCem without creating any log file.
I'm not sure if it has any relation with msys2-devel or is due to a change in source code or another thing.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

Did you try and run autoreconf? before compilation?

I have no issue with the emulator crashing with SB16/AWE32 enabled. Running 98SE guest.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

It turns out that base-devel is what's required for autoreconf. I have updated the guide for this.

And it turns out when I did a fresh compilation from scratch, it broke PCem, like ruben_balea is having.
JosepMa
Posts: 202
Joined: Tue 20 Jun, 2017 6:25 pm

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by JosepMa »

These instructions are in an incorrect order:

Code: Select all

$ ./configure --enable-networking --enable-release-build
$ autoreconf
$ mingw32-make -j
autoreconf (preferably with the -i parameter), comes before the ./configure line, as basically autoreconf will regenerate the configure script.

And this is incorrect too. autoreconf by itself does not execute the configure script, which is needed to refresh the Makefile files.

Code: Select all

$ cd ~/pcem
$ mingw32-make clean
$ hg pull && hg update default
$ autoreconf
$ mingw32-make -j
JosepMa
Posts: 202
Joined: Tue 20 Jun, 2017 6:25 pm

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by JosepMa »

Btw, Windows 10 + Windows Defender.

I got speeds similar to when compiling with the premade Makefile by excluding the msys folder and the sources folder for Windows Defender scan (I have the sources outside of msys).

The setting is found by opening Windows Defender, going to the second sidebar option (virus protection), there to "virus protection configuration", and there, scroll down to "Exclusions".
(Beware: My copy is not in english, so those names are translations from my language).

A reboot may be necessary for it to accept the changes.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

JosepMa wrote: Tue 13 Feb, 2018 9:35 pm These instructions are in an incorrect order:

Code: Select all

$ ./configure --enable-networking --enable-release-build
$ autoreconf
$ mingw32-make -j
autoreconf (preferably with the -i parameter), comes before the ./configure line, as basically autoreconf will regenerate the configure script.

And this is incorrect too. autoreconf by itself does not execute the configure script, which is needed to refresh the Makefile files.

Code: Select all

$ cd ~/pcem
$ mingw32-make clean
$ hg pull && hg update default
$ autoreconf
$ mingw32-make -j
Oops, my bad.

I'm not an expert on autotools obviously...

I shall fix.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea »

Well, I still have the problem with SB16, perhaps am I using some wrong dll? corrupt MSYS2 environment? somewhat missing? :roll:
Could anyone with a successful compilation under MSYS2 upload somewhere its pcem.exe + all dll files please? even the full src folder with the good Makefile will be useful to discard problems.
Thanks!

:idea: Of course I followed the last instructions in the good order: fresh download ---> autoreconf ---> ./configure --enable-networking --enable-release-build ---> mingw32-make -j
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by shermanp »

ruben_balea wrote: Tue 13 Feb, 2018 11:24 pm Well, I still have the problem with SB16, perhaps am I using some wrong dll? corrupt MSYS2 environment? somewhat missing? :roll:
Could anyone with a successful compilation under MSYS2 upload somewhere its pcem.exe + all dll files please? even the full src folder with the good Makefile will be useful to discard problems.
Thanks!
Check this post => viewtopic.php?f=2&t=2909

Not sure if it's an issue with MSYS2, or an issue with the code that MSYS2 exposes, but there is definitely a problem somewhere.

I would advise waiting a day or two for the issue to be resolved one way or another. This is a reason why Sarah does not like people to distribute precompiled binaries...
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea »

shermanp wrote: Tue 13 Feb, 2018 11:32 pm
ruben_balea wrote: Tue 13 Feb, 2018 11:24 pm Well, I still have the problem with SB16, perhaps am I using some wrong dll? corrupt MSYS2 environment? somewhat missing? :roll:
Could anyone with a successful compilation under MSYS2 upload somewhere its pcem.exe + all dll files please? even the full src folder with the good Makefile will be useful to discard problems.
Thanks!
Check this post => viewtopic.php?f=2&t=2909

Not sure if it's an issue with MSYS2, or an issue with the code that MSYS2 exposes, but there is definitely a problem somewhere.

I would advise waiting a day or two for the issue to be resolved one way or another. This is a reason why Sarah does not like people to distribute precompiled binaries...
Thank you very much for letting me know, as you can see above on my post from 19 Dec 2017 I made a bad dll mixup in the past and I was thinking that something similar had happened to me again.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by SarahWalker »

SB16 crash should (hopefully) be fixed as of rev 1037.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea »

Nice job, everything works fine again.
arellano80
Posts: 8
Joined: Wed 04 Apr, 2018 11:05 pm

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by arellano80 »

Hi, I'm trying to download PCem from bitbucket, but in the process it throws me an error, what should I do.

Code: Select all

$ hg clone https://bitbucket.org/pcem_emulator/pcem
destination directory: pcem
applying clone bundle from https://api.media.atlassian.com/file/36c3088b-a83e-40d8-9f75-467f7382673a/binary?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhODJiOThlZC0yZWUxLTQ4NTEtODE0NS04YTI0MjkwMzM2OGMiLCJhY2Nlc3MiOnsidXJuOmZpbGVzdG9yZTpmaWxlOjM2YzMwODhiLWE4M2UtNDBkOC05Zjc1LTQ2N2Y3MzgyNjczYSI6WyJyZWFkIl19LCJuYmYiOjE1MjM3MjQyOTMsImV4cCI6MTUyMzcyNDcxM30.H5ymBjJwKd-Cy0KW2pswHXWlzju0D7uOv04VC-zLhjU&client=a82b98ed-2ee1-4851-8145-8a242903368c
adding changesets
adding manifests
adding file changes
added 1126 changesets with 5328 changes to 874 files
finished applying clone bundle
searching for changes
adding changesets
adding manifests
adding file changes
added 33 changesets with 46 changes to 32 files
new changesets f6c46bccb4d7:f791b7ee0b12
updating to branch default
      0 [main] python2 5540 child_info_fork::abort: address space needed by 'osutil.dll' (0x120000) is already occupied
abort: Resource temporarily unavailable

edit: solved...

to solve execute batch in: ..\msys32\autorebase.bat


done. You can clone PCem from bitbucket.
== Something nostalgic, but one is happy to see and learn something new from the old days ==
altieres.lima
Posts: 5
Joined: Sun 18 Sep, 2016 1:54 pm

Re: [Feb 2018 ed.] PCem MSYS2 build guide (with wxWidgets)

Post by altieres.lima »

How to include all dll's in exe?
Post Reply