Building PCSX2 core on GNU/Linux

Hi!

Trying to build PCSX2 core on GNU/Linux (Debian 11) I get this:

/root/src/pcsx2/3rdparty/xz/xz/src/common/mythread.h:337:10: fatal error: windows.h: No such file or directory
  337 | #include <windows.h>

I am configuring the code previously like this:

cd pcsx2
mkdir build
cmake .. -DCMAKE_BUILD_TYPE=Release -DLIBRETRO=ON

So, any idea on what am I doing wrong, please?

Weird. Builds fine here, but only after I deleted this from CMakeLists.txt:

if(NOT MSVC)
   set(CMAKE_C_COMPILER_LAUNCHER ccache)
   set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
endif()

Requiring people to install ccache is highly dubious. But I don’t think this is the cause of your build error. Although you can try it, you never know.

Also, make sure you have the latest xz git submodule. If in doubt, delete the whole pcsx2 directory and re-clone the git repo with:

git clone --recurse-submodules 'https://github.com/libretro/pcsx2.git'

This will make sure that the xz git submodule is the latest one.

1 Like

Tried that, and still the same errors. It happens on both Debian stable and testing. Maybe no one has built this core outside Ubuntu? :frowning:

I use Gentoo, and it builds fine.

@RealNC Is that mythread.h file built in your system?

Yes. But the <windows.h> include only happens if MYTHREAD_POSIX is not defined and MYTHREAD_WIN95 or MYTHREAD_VISTA are defined.

Something seems very wrong on your end. Did you try to cross-compile this maybe at some point for Windows? Is ccache responsible for this? Try and delete the section in the CMakeFile.txt I mentioned previously. And always remember to rm -r build && mkdir build so you can be sure there’s nothing left over in the build directory.

Removing the ccache lines had no effect at all.

OTOH, I see that MYTHREAD_POSIX is defined in 3rdparty/xz/xz/configure.ac when $enable_threads is set to posix, right?

…and of course Debian should be detected as a posix system…

Oh wait, sorry. I made a mistake. xz is NOT being built here. Not sure why I thought it was.

So yeah, on my system, the xz-utils package is installed, which on Gentoo provides liblzma and the needed headers in /usr/include/lzma. Try to find the debian equivalent of it. I think the development package for it on Debian is liblzma-dev.

@RealNC Yep, that was it. Installing liblzma-dev avoids built-in xz compilation and that lets the core to be built! Maybe it should be mentioned somewhere on the core repository?

@RealNC

Hmm… It seems I am not quite there yet. I get this at the end of the building process:

[100%] Linking CXX static library libGS.a

[100%] Built target GS

So it seems that pcsx2_libretro.so is not being built. I can’t locate it anywhere under the main pcsx2 sources dir or it’s subdirs. Do I need to pass anything else to CMake?

What does the cmake step say? Remember to rm -rf build && mkdir build first so that cmake does a full scan. Here, it looks like this:

$ cmake -DCMAKE_BUILD_TYPE=Release -DLIBRETRO=ON ../
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Disabling the inclusion of the binary compile date.
-- Building with GNU GCC
-- Enable the building of po files by default in Release build !!!
-- Cross compilation is disabled.
-- Compiling a x86_64 build on a x86_64 host.
-- Found PCAP: /usr/lib64/libpcap.so  
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success
-- Looking for pcap_get_pfring_id
-- Looking for pcap_get_pfring_id - not found
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.9.14") 
-- Found Gettext: /usr/bin/msgmerge (found version "0.21") 
-- Found Git: /usr/bin/git (found version "2.35.1") 
-- Looking for lzma_auto_decoder in /usr/lib64/liblzma.so
-- Looking for lzma_auto_decoder in /usr/lib64/liblzma.so - found
-- Looking for lzma_easy_encoder in /usr/lib64/liblzma.so
-- Looking for lzma_easy_encoder in /usr/lib64/liblzma.so - found
-- Looking for lzma_lzma_preset in /usr/lib64/liblzma.so
-- Looking for lzma_lzma_preset in /usr/lib64/liblzma.so - found
-- Found LibLZMA: /usr/lib64/liblzma.so (found version "5.2.5") 
-- Found OpenGL: /usr/lib64/libOpenGL.so   
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.12") 
-- Found PNG: /usr/lib64/libpng.so (found version "1.6.37") 
-- Found Libc: /usr/lib64/librt.a;/usr/lib64/libm.so  
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0") 
-- AIO found
-- Found xxd. GameIndex.h, cheats_ws.h, cheats_60fps.h and cheats_nointerlacing.h will be generated.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/realnc/projects/misc/libretro/pcsx2/build

@RealNC after deleting the build dir and recreating it, cmake says this:

[email protected]:~/src/pcsx2/build$ cmake -DCMAKE_BUILD_TYPE=Release -DLIBRETRO=ON ../
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Disabling the inclusion of the binary compile date.
-- Building with GNU GCC
-- Enable the building of po files by default in Release build !!!
-- Cross compilation is disabled.
-- Compiling a x86_64 build on a x86_64 host.
-- Found PCAP: /usr/lib/x86_64-linux-gnu/libpcap.so  
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Success
-- Looking for pcap_get_pfring_id
-- Looking for pcap_get_pfring_id - not found
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Could NOT find Gettext (missing: GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE) 
-- Found Git: /usr/bin/git (found version "2.30.2") 
-- Looking for lzma_auto_decoder in /usr/lib/x86_64-linux-gnu/liblzma.so
-- Looking for lzma_auto_decoder in /usr/lib/x86_64-linux-gnu/liblzma.so - found
-- Looking for lzma_easy_encoder in /usr/lib/x86_64-linux-gnu/liblzma.so
-- Looking for lzma_easy_encoder in /usr/lib/x86_64-linux-gnu/liblzma.so - found
-- Looking for lzma_lzma_preset in /usr/lib/x86_64-linux-gnu/liblzma.so
-- Looking for lzma_lzma_preset in /usr/lib/x86_64-linux-gnu/liblzma.so - found
-- Found LibLZMA: /usr/lib/x86_64-linux-gnu/liblzma.so (found version "5.2.5") 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 
-- Found Libc: /usr/lib/x86_64-linux-gnu/librt.so;/usr/lib/x86_64-linux-gnu/libm.so  
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- AIO not found
-- Skip build of pcsx2 core: missing dependencies:check these libraries -> wxWidgets (>=3.0), gtk2, zlib (>=1.2.4), pcsx2 common libs
-- Configuring done
-- Generating done
-- Build files have been written to: /home/manuel/src/pcsx2/build 

Seems fine to me…

Not sure where you see the “fine” part :stuck_out_tongue: It says it can’t find LibXml2, Gettext, PNG and AIO. And then at the end it says:

Skip build of pcsx2 core: missing dependencies:check these libraries -> wxWidgets (>=3.0), gtk2, zlib (>=1.2.4), pcsx2 common libs

Not sure if wxwidgets and gtk are actually needed for the libretro core, but zlib is probably needed.

@RealNC

I see… I though these could be ignored. Why would a libretro core need wxWidgets or gtk2? That’s totally absurd. Also, libzip-dev is installed here:

libzip-dev is already the newest version (1.7.3-1).

And most of those are living under pcsx2/3rdparty anyway…

This is simply broken.

Try to install their -dev packages anyway. It sucks, but it might work.