PCem MSYS2 build guide (with wxWidgets)

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

PCem MSYS2 build guide (with wxWidgets)

Post by shermanp » Tue 10 Oct, 2017 7:32 am

[EDITED 2017-10-14]
[2017-10-15 Makefiles updated for revision ab5cef9]
[2018-01-12] Guide updated for post V13.1. Makefiles are for commit 4f766e8
[2018-01-22] Makefiles updated for at least commit ba387e5 (Zip drive emulation)

Hi all.

I spent the afternoon banging my head against the desk trying to get PCem to compile with MSYS2. I finally managed it however, so I'm going to share with you the process.

This will hopefully build PCem with wxWidgets/SDL2 support. Thanks to darksabre76, I have now got networking compiled.

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. Update packages by following the directions in 'III Updating Packages' from https://github.com/msys2/msys2/wiki/MSYS2-installation. Note that during the update process, you will be asked to close the shell, then reopen it and continue the update.

Once MSYS2 has been installed and packages updated continue to the next step.

Install needed packages
From the MSYS2 MSYS shell, type the following to install the mingw-w64 32 bit toolchain, and mercurial (used to download PCem later):

Code: Select all

pacman -S mingw-w64-i686-toolchain mercurial
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
Close the MSYS2 MSYS shell.

Prepare and Compile PCem
Open the 'MSYS2 MinGW 32-bit' shell from the start menu.

Download PCem from bitbucket using mercurial:

Code: Select all

hg clone https://bitbucket.org/pcem_emulator/pcem
cd pcem/src
[EDIT 2018-01-12] Editing 'cdrom-ioctl.c' no longer required. Section removed.

[networking support]
Edit the file '<msys>\home\<user>\pcem\src\nethandler.c' and change the order of

Code: Select all

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

Code: Select all

#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
While many have suggested using WinPcap, I suggest the newer npcap, which works for Windows 7+, and especially Windows 10.

Download 'npcap installer' (if you are going to use PCAP instead of SLIRP), and 'npcap SDK' from https://nmap.org/npcap/

From the npcap SDK zip file, extract the files from 'npcap-sdk-0.x\Lib' to '<msys>\mingw32\lib' and the files from 'npcap-sdk-0.x\Include' to '<msys>\mingw32\include'

Install npcap. Ensure to check the "Install Npcap in WinPcap API-compatible Mode" checkbox during the installation process. You only need to install npcap if you are going to use PCem in PCAP mode instead of SLIRP.
[/networking support]

Download and unzip the makefiles I've attached to this post into '<msys>\home\<user>\pcem\src'. Note that the makefiles are only valid for PCem commits shown in the edit at the top of this post. Thanks to darksabre76 for the networking makefile.

Assuming you are in the 'pcem/src' directory in the shell, type the following to compile PCem:

Code: Select all

mingw32-make -j[i]n[/i] -f Makefile.msys2-wx-sdl2
Or, for networking:

Code: Select all

mingw32-make -j[i]n[/i] -f Makefile.msys2-wx-sdl2-network
Where -jn is the number of threads to compile with. Eg. -j4 for a quad core processor

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

copy the newly compiled 'PCem-wx-SDL2.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

Code: Select all

$ cd /path/to/pcem/src
$  mingw32-make clean -f Makefile.msys2-wx-sdl2(-network)
$ cd ..
$ hg pull && hg update default
$ cd src
$ mingw32-make -jn -f Makefile.msys2-wx-sdl2(-network)
Hopefully this guide will have got you up and running with a freshly compiled PCem, ready for testing.
Attachments
Msys2 Makefiles.zip
(3.67 KiB) Downloaded 5 times
Last edited by shermanp on Sun 21 Jan, 2018 11:51 pm, edited 6 times in total.

jznomoney
Posts: 45
Joined: Sat 06 Dec, 2014 9:11 pm

Re: PCem MSYS2 build guide (with wxWidgets)

Post by jznomoney » Tue 10 Oct, 2017 12:51 pm

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: 574
Joined: Thu 17 Dec, 2015 6:20 pm

Re: PCem MSYS2 build guide (with wxWidgets)

Post by omarsis81 » Tue 10 Oct, 2017 1:45 pm

I didn't try it yet, but thanks for the job!

basic2004
Posts: 119
Joined: Sun 08 Jan, 2017 5:59 pm

Re: PCem MSYS2 build guide (with wxWidgets)

Post by basic2004 » Tue 10 Oct, 2017 2:19 pm

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: 17
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp » Tue 10 Oct, 2017 7:37 pm

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: 21
Joined: Tue 12 Sep, 2017 4:33 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by darksabre76 » Tue 10 Oct, 2017 9:11 pm

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 31 times
Last edited by darksabre76 on Tue 10 Oct, 2017 10:49 pm, edited 1 time in total.

User avatar
ruben_balea
Posts: 47
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea » Tue 10 Oct, 2017 10:41 pm

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 1274 times

User avatar
dreamer
Posts: 29
Joined: Wed 28 Dec, 2016 11:56 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by dreamer » Thu 12 Oct, 2017 6:25 pm

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: 21
Joined: Tue 12 Sep, 2017 4:33 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by darksabre76 » Sat 14 Oct, 2017 4:27 am

Updated build files with the new sound driver.
Attachments
Makefile.msys2-wx-sdl2-network.txt
(4.05 KiB) Downloaded 29 times
Makefile.msys2-wx-sdl2.txt
(3.88 KiB) Downloaded 30 times

shermanp
Posts: 17
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp » Sat 14 Oct, 2017 4:48 am

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: 17
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp » Sat 14 Oct, 2017 9:01 pm

First post has updated makefiles for commit ab5cef9

User avatar
ruben_balea
Posts: 47
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: PCem MSYS2 build guide (with wxWidgets)

Post by ruben_balea » Mon 18 Dec, 2017 11:32 pm

: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: 17
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp » Thu 11 Jan, 2018 9:38 pm

Hi all,

The OP has been updated with a revised guide, and makefiles required for the T1000 commit.

shermanp
Posts: 17
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Post by shermanp » Sun 21 Jan, 2018 8:54 pm

Hi all,

The Makefiles have been updated to support the Zip drive additions that Sarah has added.

Post Reply