PCem MSYS2 build guide (with wxWidgets)

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

PCem MSYS2 build guide (with wxWidgets)

Postby shermanp » Tue 10 Oct, 2017 7:32 am

[EDITED 2017-10-14]
[2017-10-15 Makefiles updated for revision ab5cef9]

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 the file '<msys>\home\<user>\pcem\src\cdrom-ioctl.c' with your favorite text editor. Change the two occurrences of

Code: Select all

__MINGW64__
wuth

Code: Select all

__MINGW64_VERSION_MAJOR

Save and close the file.

[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 -f Makefile.msys2-wx-sdl2

Or, for networking:

Code: Select all

mingw32-make -f Makefile.msys2-wx-sdl2-network

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.


Hopefully this guide will have got you up and running with a freshly compiled PCem, ready for testing.
Attachments
msys2-makefiles.zip
(3.6 KiB) Downloaded 67 times
Last edited by shermanp on Sat 14 Oct, 2017 9:04 pm, edited 3 times in total.
jznomoney
Posts: 40
Joined: Sat 06 Dec, 2014 9:11 pm

Re: PCem MSYS2 build guide (with wxWidgets)

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

Re: PCem MSYS2 build guide (with wxWidgets)

Postby omarsis81 » Tue 10 Oct, 2017 1:45 pm

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

Re: PCem MSYS2 build guide (with wxWidgets)

Postby 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/viewtopic.php?f=3&t=637&p=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: 12
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

Postby 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/viewtopic.php?f=3&t=637&p=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: 17
Joined: Tue 12 Sep, 2017 4:33 am

Re: PCem MSYS2 build guide (with wxWidgets)

Postby 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 26 times
Last edited by darksabre76 on Tue 10 Oct, 2017 10:49 pm, edited 1 time in total.
User avatar
ruben_balea
Posts: 46
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: PCem MSYS2 build guide (with wxWidgets)

Postby 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 745 times
User avatar
dreamer
Posts: 29
Joined: Wed 28 Dec, 2016 11:56 am

Re: PCem MSYS2 build guide (with wxWidgets)

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

Re: PCem MSYS2 build guide (with wxWidgets)

Postby 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 22 times
Makefile.msys2-wx-sdl2.txt
(3.88 KiB) Downloaded 20 times
shermanp
Posts: 12
Joined: Sat 18 Feb, 2017 2:09 am

Re: PCem MSYS2 build guide (with wxWidgets)

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

Re: PCem MSYS2 build guide (with wxWidgets)

Postby shermanp » Sat 14 Oct, 2017 9:01 pm

First post has updated makefiles for commit ab5cef9

Return to “Development”

Who is online

Users browsing this forum: No registered users and 2 guests