Skip to content

CMake and Visual Studio support#64

Open
vii1 wants to merge 12 commits into
commanderx16:masterfrom
vii1:pr_cmake_msvc
Open

CMake and Visual Studio support#64
vii1 wants to merge 12 commits into
commanderx16:masterfrom
vii1:pr_cmake_msvc

Conversation

@vii1
Copy link
Copy Markdown

@vii1 vii1 commented Sep 15, 2019

CMake makefile.
Some conditionals for MSVC which lacks some POSIX headers.
Provided alternatives for some GCC extensions.
Also changed SDL_WINDOW_FULLSCREEN to SDL_WINDOW_FULLSCREEN_DESKTOP, which doesn't change the screen video mode and is friendlier, at least in Windows.

@tobier
Copy link
Copy Markdown
Contributor

tobier commented Sep 19, 2019

We really need this for easier cross-platform building.

@vii1 Can you squash your PR into a single commit and rebase on origin/master?

@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 19, 2019

@vii1 Can you squash your PR into a single commit and rebase on origin/master?

I think I got it. 👍

@tobier
Copy link
Copy Markdown
Contributor

tobier commented Sep 19, 2019

@vii1 Can you squash your PR into a single commit and rebase on origin/master?

I think I got it.

LGTM but I'm not in a position of authority 👍

@mist64
Copy link
Copy Markdown
Collaborator

mist64 commented Sep 19, 2019

Looks great. Will try out later today.

Copy link
Copy Markdown
Contributor

@madebr madebr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2 cents. Looks good but not tested.
Appveyor CI (or equivalent) would be useful.

Comment thread CMakeLists.txt Outdated
Comment thread ps2.c Outdated
Comment thread ps2.c Outdated
Comment thread cmake/FindSDL2.cmake
Comment thread CMakeLists.txt Outdated
Comment thread debugger.h Outdated
Comment thread loadsave.c
@mist64
Copy link
Copy Markdown
Collaborator

mist64 commented Sep 19, 2019

I'll keep following your conversation for a little while longer. :)

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 19, 2019

@mist64 I've got appveyor CI working (including artifacts)!
You should let the admins register an organization account on appveyor.com such that https://ci.appveyor.com/project/commanderx16/x16-emulator will point to the builds.

See https://ci.appveyor.com/project/madebr/x16-emulator/builds/27537615

@tobier
Copy link
Copy Markdown
Contributor

tobier commented Sep 20, 2019

We merged a patch yesterday about Travis CI integration for Linux and macOS, it would be great to add Windows support via AppVeyor (I believe AppVeyor only support Linux and Windows).

@vii1 @madebr if you're working on CI for CMake can you please also update the .travis.yml file I added in commit 44ec5dd. We should probably also drop the existing Makefile if we decide to go with CMake

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 20, 2019

@madebr travis CI using CMake is already working: https://travis-ci.com/madebr/x16-emulator/builds/128437480

I'm currently working on adding CMake support to x16-rom, and then x16-docs.
That way, a release can be built easily.

@tobier
Copy link
Copy Markdown
Contributor

tobier commented Sep 20, 2019

@madebr 👍

Comment thread ps2.c Outdated
@vii1 vii1 requested a review from mist64 September 20, 2019 15:44
@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 20, 2019

@mist64 While working on adding emscripten support, I needed the chargen.bin file.
README.md says it is in the binary releases.
I could find it in x16emu_linux-r30.zip but not in x16emu_linux-r31.zip.
Also, wouldn't it be easier to add it to the rom repo? (Including steps how to generate it)

@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 20, 2019

@mist64 While working on adding emscripten support, I needed the chargen.bin file.
README.md says it is in the binary releases.
I could find it in x16emu_linux-r30.zip but not in x16emu_linux-r31.zip.
Also, wouldn't it be easier to add it to the rom repo? (Including steps how to generate it)

Chargen data is now included in rom.bin, so chargen.bin is not necessary anymore.

Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt Outdated
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
if(WIN32)
include_directories("${CMAKE_CURRENT_LIST_DIR}/windows")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put it in another folder.
Maybe in msvc/include or support/msvc/include.
Maybe @mist64 has a preference

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to support/msvc/include for now.

Comment thread debugger.c
Comment thread debugger.h
Comment thread ps2.c Outdated
Comment thread video.h Outdated
Comment thread CMakeLists.txt Outdated
Comment thread main.c
Comment thread CMakeLists.txt
@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 22, 2019

This all looks good to me.
Once this gets merged, I'll open a new PR that will add all functionality of the current Makefile.

@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 26, 2019

@madebr Maybe this can help ocaml/flexdll@3a7fe09

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 26, 2019

@vii1 I modified the mingw toolchain script based upon your link.
Can you clean the build dir and try again? Also, output of make VERBOSE=y would be very useful (or cmake --build . --verbose)!
Also, after cmake configuration, can you confirm (using e.g. cmake-gui) that SDL2_INCLUDE_DIR and SDL2_LIBRARY are the ones in your mingw toolchain?
(I need to do these CMAKE_FIND_ROOT_PATH shenanigans to avoid picking up the native SDL2 includes in /usr/include etc)

@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 27, 2019

@madebr It detected everything except the SDL2 include directory. I set it explicitly and then it worked.

log.txt

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 28, 2019

@vii1 Weird. It's detecting the library, but not the include directory. Which means cmake knows about the root directory.
To debug:

  • This is Arch Linux under WSL, correct?
  • What is the output of x86_64-w64-mingw32-gcc -print-search-dirs?
  • Can you rerun the mingw toolchain of my fork and copy paste the line about CMAKE_FIND_ROOT_PATH? (I've added a debug statement)
  • SDL2 include directory is at /usr/x86_64-w64-mingw32/include/SDL2?
  • SDL2.dll is at /usr/x86_64-w64-mingw32/bin/SDL2.dll?
  • Isn't there a SDL2.dll.a (or similar static library)?

@MouriNaruto
Copy link
Copy Markdown

Good job, and I also think this project should use CMake instead of Makefile.

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 29, 2019

@vii1 I just tried out archlinux/base in a docker and could compile and link x16emu using the mingw-w64 packages of ownstuff
So I think the toolchain is fine.
For reference:

x86_64-w64-mingw32-gcc -print-search-dirs
install: /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/
programs: =/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/9.2.0/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/
libraries: =/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/9.2.0/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/
Arch Linux mingw-w64 output

[root@9e09e7f3dc87 build]# CC=x86_64-w64-mingw32-gcc cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/mingw.cmake
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..
-- The C compiler identification is GNU 9.2.0
-- Check for working C compiler: /usr/sbin/x86_64-w64-mingw32-gcc
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..
-- Check for working C compiler: /usr/sbin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Development build
-- Looking for pthread.h
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/9.2.0/;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib//..;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib//..
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found SDL2: mingw32;-mwindows;/usr/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/../bin/SDL2.dll  
-- Configuring done
-- Generating done
-- Build files have been written to: /x16/build
[root@9e09e7f3dc87 build]# make VERBOSE=y
/usr/bin/cmake -S/x16 -B/x16/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /x16/build/CMakeFiles /x16/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/x16/build'
make -f CMakeFiles/x16emu.dir/build.make CMakeFiles/x16emu.dir/depend
make[2]: Entering directory '/x16/build'
cd /x16/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /x16 /x16 /x16/build /x16/build /x16/build/CMakeFiles/x16emu.dir/DependInfo.cmake --color=
Dependee "/x16/build/CMakeFiles/x16emu.dir/DependInfo.cmake" is newer than depender "/x16/build/CMakeFiles/x16emu.dir/depend.internal".
Dependee "/x16/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/x16/build/CMakeFiles/x16emu.dir/depend.internal".
Scanning dependencies of target x16emu
make[2]: Leaving directory '/x16/build'
make -f CMakeFiles/x16emu.dir/build.make CMakeFiles/x16emu.dir/build
make[2]: Entering directory '/x16/build'
[  7%] Building C object CMakeFiles/x16emu.dir/cpu/fake6502.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/cpu/fake6502.c.obj   -c /x16/cpu/fake6502.c
[ 15%] Building C object CMakeFiles/x16emu.dir/debugger.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/debugger.c.obj   -c /x16/debugger.c
[ 23%] Building C object CMakeFiles/x16emu.dir/disasm.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/disasm.c.obj   -c /x16/disasm.c
[ 30%] Building C object CMakeFiles/x16emu.dir/loadsave.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/loadsave.c.obj   -c /x16/loadsave.c
[ 38%] Building C object CMakeFiles/x16emu.dir/main.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/main.c.obj   -c /x16/main.c
[ 46%] Building C object CMakeFiles/x16emu.dir/memory.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/memory.c.obj   -c /x16/memory.c
[ 53%] Building C object CMakeFiles/x16emu.dir/ps2.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/ps2.c.obj   -c /x16/ps2.c
[ 61%] Building C object CMakeFiles/x16emu.dir/sdcard.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/sdcard.c.obj   -c /x16/sdcard.c
[ 69%] Building C object CMakeFiles/x16emu.dir/spi.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/spi.c.obj   -c /x16/spi.c
[ 76%] Building C object CMakeFiles/x16emu.dir/vera_spi.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/vera_spi.c.obj   -c /x16/vera_spi.c
[ 84%] Building C object CMakeFiles/x16emu.dir/via.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/via.c.obj   -c /x16/via.c
[ 92%] Building C object CMakeFiles/x16emu.dir/video.c.obj
/usr/sbin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/video.c.obj   -c /x16/video.c
[100%] Linking C executable x16emu.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/x16emu.dir/link.txt --verbose=y
/usr/bin/cmake -E remove -f CMakeFiles/x16emu.dir/objects.a
/usr/sbin/x86_64-w64-mingw32-ar cr CMakeFiles/x16emu.dir/objects.a @CMakeFiles/x16emu.dir/objects1.rsp
/usr/sbin/x86_64-w64-mingw32-gcc   -Wl,--subsystem,console -Wl,--whole-archive CMakeFiles/x16emu.dir/objects.a -Wl,--no-whole-archive  -o x16emu.exe -Wl,--out-implib,libx16emu.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/x16emu.dir/linklibs.rsp
make[2]: Leaving directory '/x16/build'
[100%] Built target x16emu
make[1]: Leaving directory '/x16/build'
/usr/bin/cmake -E cmake_progress_start /x16/build/CMakeFiles 0

More importantly:
Because #127 moved some files, you'll need to fix the CMake file:

  • add include directories to extern/src and extern/include (include_directories("${CMAKE_CURRENT_LIST_DIR}/extern/include" "${CMAKE_CURRENT_LIST_DIR}/extern/src")
  • Maybe move support/msvc/include/dirent.h to extern/include/msvc/dirent.h and include that directory?

@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 29, 2019

@madebr

  • This is Arch Linux under WSL, correct?

No. This is Ubuntu 18.04 LTS under WSL. I just used an Arch toolchain file but all paths match. Sorry about the confusion.

  • What is the output of x86_64-w64-mingw32-gcc -print-search-dirs?
install: /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/
programs: =/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/7.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/../../../../x86_64-w64-mingw32/bin/
libraries: =/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/7.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/../../../../x86_64-w64-mingw32/lib/

(how do you insert those neat disclosable blocks?)

  • Can you rerun the mingw toolchain of my fork and copy paste the line about CMAKE_FIND_ROOT_PATH? (I've added a debug statement)
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/../../../../x86_64-w64-mingw32/lib//..

Both paths are correct. That weird long path resolves to /usr/x86_64-w64-mingw32.

  • SDL2 include directory is at /usr/x86_64-w64-mingw32/include/SDL2?

Yes.

  • SDL2.dll is at /usr/x86_64-w64-mingw32/bin/SDL2.dll?

Yes.

  • Isn't there a SDL2.dll.a (or similar static library)?

Yes. This is what cd /usr/x86_64-w64-mingw32/lib; ls *SDL* yields:

libSDL2.a
libSDL2.dll.a
libSDL2.la
libSDL2_test.a
libSDL2_test.la
libSDL2main.a
libSDL2main.la

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 29, 2019

@vii1 I just tried the Ubuntu docker and got the same result.
Because apt does not provide mingw packages, I extracted the mingw runtimedevelopment directories of http://libsdl.org/download-2.0.php to the root.

Ubuntu Linux mingw-w64 output

root@0421053809e7:/x16/build# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=19.04
DISTRIB_CODENAME=disco
DISTRIB_DESCRIPTION="Ubuntu 19.04"
root@0421053809e7:/x16/build# CC=x86_64-w64-mingw32-gcc cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/mingw.cmake
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- The C compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Detecting C compiler ABI info - done
-- Detecting C compile features
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Detecting C compile features - done
-- Development build
-- Looking for pthread.h
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Looking for pthread.h - found
-- Looking for pthread_create
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
Setting CMAKE_FIND_ROOT_PATH to /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib//..
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found SDL2: mingw32;-mwindows;/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib/../bin/SDL2.dll;-lpthread  
-- Configuring done
-- Generating done
-- Build files have been written to: /x16/build
root@0421053809e7:/x16/build# make VERBOSE=y                                                                         
/usr/bin/cmake -S/x16 -B/x16/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /x16/build/CMakeFiles /x16/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/x16/build'
make -f CMakeFiles/x16emu.dir/build.make CMakeFiles/x16emu.dir/depend
make[2]: Entering directory '/x16/build'
cd /x16/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /x16 /x16 /x16/build /x16/build /x16/build/CMakeFiles/x16emu.dir/DependInfo.cmake --color=
Dependee "/x16/build/CMakeFiles/x16emu.dir/DependInfo.cmake" is newer than depender "/x16/build/CMakeFiles/x16emu.dir/depend.internal".
Dependee "/x16/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/x16/build/CMakeFiles/x16emu.dir/depend.internal".
Scanning dependencies of target x16emu
make[2]: Leaving directory '/x16/build'
make -f CMakeFiles/x16emu.dir/build.make CMakeFiles/x16emu.dir/build
make[2]: Entering directory '/x16/build'
[  7%] Building C object CMakeFiles/x16emu.dir/cpu/fake6502.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/cpu/fake6502.c.obj   -c /x16/cpu/fake6502.c
[ 15%] Building C object CMakeFiles/x16emu.dir/debugger.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/debugger.c.obj   -c /x16/debugger.c
[ 23%] Building C object CMakeFiles/x16emu.dir/disasm.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/disasm.c.obj   -c /x16/disasm.c
[ 30%] Building C object CMakeFiles/x16emu.dir/loadsave.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/loadsave.c.obj   -c /x16/loadsave.c
[ 38%] Building C object CMakeFiles/x16emu.dir/main.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/main.c.obj   -c /x16/main.c
[ 46%] Building C object CMakeFiles/x16emu.dir/memory.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/memory.c.obj   -c /x16/memory.c
[ 53%] Building C object CMakeFiles/x16emu.dir/ps2.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/ps2.c.obj   -c /x16/ps2.c
[ 61%] Building C object CMakeFiles/x16emu.dir/sdcard.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/sdcard.c.obj   -c /x16/sdcard.c
[ 69%] Building C object CMakeFiles/x16emu.dir/spi.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/spi.c.obj   -c /x16/spi.c
[ 76%] Building C object CMakeFiles/x16emu.dir/vera_spi.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/vera_spi.c.obj   -c /x16/vera_spi.c
[ 84%] Building C object CMakeFiles/x16emu.dir/via.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/via.c.obj   -c /x16/via.c
[ 92%] Building C object CMakeFiles/x16emu.dir/video.c.obj
/usr/bin/x86_64-w64-mingw32-gcc  @CMakeFiles/x16emu.dir/includes_C.rsp -O3 -Wall -Werror -std=c99 -o CMakeFiles/x16emu.dir/video.c.obj   -c /x16/video.c
[100%] Linking C executable x16emu.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/x16emu.dir/link.txt --verbose=y
/usr/bin/cmake -E remove -f CMakeFiles/x16emu.dir/objects.a
/usr/bin/x86_64-w64-mingw32-ar cr CMakeFiles/x16emu.dir/objects.a @CMakeFiles/x16emu.dir/objects1.rsp
/usr/bin/x86_64-w64-mingw32-gcc   -Wl,--subsystem,console -Wl,--whole-archive CMakeFiles/x16emu.dir/objects.a -Wl,--no-whole-archive  -o x16emu.exe -Wl,--out-implib,libx16emu.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/x16emu.dir/linklibs.rsp
make[2]: Leaving directory '/x16/build'
[100%] Built target x16emu
make[1]: Leaving directory '/x16/build'
/usr/bin/cmake -E cmake_progress_start /x16/build/CMakeFiles 0

sdl files in the mingw tree

root@0421053809e7:/x16/build# find /usr/x86_64-w64-mingw32/ -iname "*sdl*"
/usr/x86_64-w64-mingw32/bin/sdl2-config
/usr/x86_64-w64-mingw32/bin/SDL2.dll
/usr/x86_64-w64-mingw32/include/SDL2
/usr/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_revision.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_platform.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_audio.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_video.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_types.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_rect.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengl_glext.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_endian.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_quit.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_bits.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_assert.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_error.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_main.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_gl2.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_name.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_shape.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_power.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_config.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_version.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_thread.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_events.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_touch.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_surface.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_gl2ext.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_system.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_timer.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_hints.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_khrplatform.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_egl.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_gl2platform.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_log.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h
/usr/x86_64-w64-mingw32/include/SDL2/SDL_render.h
/usr/x86_64-w64-mingw32/include/rasdlg.h
/usr/x86_64-w64-mingw32/lib/libSDL2.dll.a
/usr/x86_64-w64-mingw32/lib/libSDL2_test.a
/usr/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc
/usr/x86_64-w64-mingw32/lib/libSDL2_test.la
/usr/x86_64-w64-mingw32/lib/cmake/SDL2
/usr/x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake
/usr/x86_64-w64-mingw32/lib/libSDL2.la
/usr/x86_64-w64-mingw32/lib/librasdlg.a
/usr/x86_64-w64-mingw32/lib/libSDL2main.la
/usr/x86_64-w64-mingw32/lib/libSDL2main.a
/usr/x86_64-w64-mingw32/lib/libSDL2.a

As you can see, our build trees are completely equivalent.

Collapsible sections

@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 29, 2019

Because #127 moved some files, you'll need to fix the CMake file:

  • add include directories to extern/src and extern/include (include_directories("${CMAKE_CURRENT_LIST_DIR}/extern/include" "${CMAKE_CURRENT_LIST_DIR}/extern/src")
  • Maybe move support/msvc/include/dirent.h to extern/include/msvc/dirent.h and include that directory?

@madebr Merged and done. I also added support for -DWITH_YM2151.

@vii1 I just tried the Ubuntu docker and got the same result.
Because apt does not provide mingw packages, I extracted the mingw runtime directories of http://libsdl.org/download-2.0.php to the root.

Ubuntu Linux mingw-w64 output
sdl files in the mingw tree
As you can see, our build trees are completely equivalent.

Then probably there's a mistake at my side. I think we can move on.

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 29, 2019

@vii1
I just tried it myself on WSL and could briefly reproduce a similar issue as you have.
The problem I had was that the copied SDL2 files in the /usr/x86_64-w64-mingw32 directory did not have the correct file mode bits and I did not copy the files correctly. (This is the first time I'm using WSL)

Try running this command and compare your output:

find /usr/x86_64-w64-mingw32/ -iname "*sdl*"  | (while read -r LINE;  do ls -dal "$LINE"; done;)
Output of command above on my WSL (working mingw build)
$ find /usr/x86_64-w64-mingw32/ -iname "*sdl*"  | (while read -r LINE;  do ls -dal "$LINE"; done;)
-rwxr-xr-x 1 root root 1401344 Sep 29 15:24 /usr/x86_64-w64-mingw32/bin/SDL2.dll
-rwxr-xr-x 1 root root 1444 Sep 29 15:24 /usr/x86_64-w64-mingw32/bin/sdl2-config
drwxr-xr-x 1 root root 512 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2
-rw-r--r-- 1 root root 4210 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL.h
-rw-r--r-- 1 root root 11045 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_assert.h
-rw-r--r-- 1 root root 10839 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h
-rw-r--r-- 1 root root 35788 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_audio.h
-rw-r--r-- 1 root root 3096 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_bits.h
-rw-r--r-- 1 root root 5115 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h
-rw-r--r-- 1 root root 1966 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h
-rw-r--r-- 1 root root 6776 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_config.h
-rw-r--r-- 1 root root 8610 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h
-rw-r--r-- 1 root root 73586 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_egl.h
-rw-r--r-- 1 root root 6451 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_endian.h
-rw-r--r-- 1 root root 2271 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_error.h
-rw-r--r-- 1 root root 30883 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_events.h
-rw-r--r-- 1 root root 5255 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h
-rw-r--r-- 1 root root 13531 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h
-rw-r--r-- 1 root root 2157 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h
-rw-r--r-- 1 root root 39294 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h
-rw-r--r-- 1 root root 53343 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_hints.h
-rw-r--r-- 1 root root 13836 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h
-rw-r--r-- 1 root root 6437 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h
-rw-r--r-- 1 root root 15262 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h
-rw-r--r-- 1 root root 2866 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h
-rw-r--r-- 1 root root 6491 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_log.h
-rw-r--r-- 1 root root 5375 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_main.h
-rw-r--r-- 1 root root 4611 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h
-rw-r--r-- 1 root root 10924 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h
-rw-r--r-- 1 root root 6665 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h
-rw-r--r-- 1 root root 1155 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_name.h
-rw-r--r-- 1 root root 82593 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h
-rw-r--r-- 1 root root 731497 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengl_glext.h
-rw-r--r-- 1 root root 1254 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h
-rw-r--r-- 1 root root 1552 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h
-rw-r--r-- 1 root root 31876 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_gl2.h
-rw-r--r-- 1 root root 98695 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_gl2ext.h
-rw-r--r-- 1 root root 913 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_gl2platform.h
-rw-r--r-- 1 root root 10022 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_opengles2_khrplatform.h
-rw-r--r-- 1 root root 17188 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h
-rw-r--r-- 1 root root 5203 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_platform.h
-rw-r--r-- 1 root root 2463 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_power.h
-rw-r--r-- 1 root root 2106 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_quit.h
-rw-r--r-- 1 root root 4839 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_rect.h
-rw-r--r-- 1 root root 42721 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_render.h
-rw-r--r-- 1 root root 79 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_revision.h
-rw-r--r-- 1 root root 9197 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h
-rw-r--r-- 1 root root 15254 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h
-rw-r--r-- 1 root root 7545 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h
-rw-r--r-- 1 root root 5681 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_shape.h
-rw-r--r-- 1 root root 22163 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h
-rw-r--r-- 1 root root 20632 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_surface.h
-rw-r--r-- 1 root root 9152 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_system.h
-rw-r--r-- 1 root root 9252 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h
-rw-r--r-- 1 root root 2000 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test.h
-rw-r--r-- 1 root root 3243 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h
-rw-r--r-- 1 root root 5732 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h
-rw-r--r-- 1 root root 2163 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h
-rw-r--r-- 1 root root 3385 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h
-rw-r--r-- 1 root root 2439 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h
-rw-r--r-- 1 root root 13122 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h
-rw-r--r-- 1 root root 4612 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h
-rw-r--r-- 1 root root 2215 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h
-rw-r--r-- 1 root root 1954 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h
-rw-r--r-- 1 root root 4630 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h
-rw-r--r-- 1 root root 1787 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h
-rw-r--r-- 1 root root 3156 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h
-rw-r--r-- 1 root root 12977 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_thread.h
-rw-r--r-- 1 root root 3454 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_timer.h
-rw-r--r-- 1 root root 2946 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_touch.h
-rw-r--r-- 1 root root 1031 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_types.h
-rw-r--r-- 1 root root 5162 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_version.h
-rw-r--r-- 1 root root 46512 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_video.h
-rw-r--r-- 1 root root 10797 Sep 29 15:54 /usr/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h
lrwxrwxrwx 1 root root 38 Nov 18  2017 /usr/x86_64-w64-mingw32/include/rasdlg.h -> ../../share/mingw-w64/include/rasdlg.h
drwxr-xr-x 1 root root 512 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/cmake/SDL2
-rw-r--r-- 1 root root 482 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/cmake/SDL2/sdl2-config.cmake
-rw-r--r-- 1 root root 13687676 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2.a
-rwxr-xr-x 1 root root 427788 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2.dll.a
-rwxr-xr-x 1 root root 1058 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2.la
-rw-r--r-- 1 root root 537396 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2_test.a
-rwxr-xr-x 1 root root 925 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2_test.la
-rw-r--r-- 1 root root 18782 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2main.a
-rwxr-xr-x 1 root root 922 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/libSDL2main.la
-rw-r--r-- 1 root root 30394 Nov 18  2017 /usr/x86_64-w64-mingw32/lib/librasdlg.a
-rw-r--r-- 1 root root 761 Sep 29 15:24 /usr/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Sep 29, 2019

@vii1 @mist64 PR is looking good!

vii added 2 commits September 30, 2019 21:10
There's no Elvis operator in MSVC.
@vii1
Copy link
Copy Markdown
Author

vii1 commented Sep 30, 2019

Merged and solved conflicts.
Removed Elvis ?: operator which does not exist in MSVC.

@y2k4life
Copy link
Copy Markdown

@vii1 Great work. Tested with Visual Studio 2019 no problems. The only drawback is not having the ROMs. I still had to compile in Linux due the conversion for the charset. Will you be working on building ROMs with Windows as well?

@manuvdp
Copy link
Copy Markdown

manuvdp commented Oct 23, 2019

I can't get it working on windows 64bit machine
receives this errors:
LNK2019 unresolved external symbol _SDL_RenderPresent referenced in function _video_update D:\Temp\x16-VS\CMakeLists.txt D:\Temp\x16-VS\video.c.obj 1

Can you please add the cMakeSettings.json, or other missing files like dirent.h.
I'm complete noob in c++ and i'm trying to learn. Can you help me with a set by step how I can get the build working? Doen it need to be build in 64bit? os x86 is ok?

In which foler should I put the /SDL/include and /SDL/lib? Just set a setting in the cMakeSettings.json?

`{
"configurations": [
{
"name": "x86-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\out\build\${name}",
"installRoot": "${projectDir}\out\install\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": [
{
"name": "SDL2_DIR",
"value": "D:/Temp/x16-VS/include",
"type": "PATH"
},
{
"name": "SDL2_INCLUDE_DIR",
"value": "D:/Temp/x16-VS/include",
"type": "PATH"
},
{
"name": "SDL2_LIBRARY_TEMP",
"value": "C:\Program Files\SDL\temp",
"type": "FILEPATH"
},
{
"name": "SDL2MAIN_LIBRARY",
"value": "D:/Temp/x16-VS/lib",
"type": "FILEPATH"
}
],
"cmakeToolchain": "D:/Temp/x16-VS/cmake/FindSDL2.cmake"

}

]
}`

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Oct 23, 2019

@manuvdp
The project can be built as either a 32- or a 64-bit executable. Don't forget that a 32-bit build needs to link to a 32-bit SDL2 library, and vice versa for 64-bit.

Assuming you downloaded SDL2-devel-2.0.10-VC.zip, you should only need to set SDL2_PATH to the location where you unzipped the archive.
I can't make up from your comment where you extracted this archive. C:\Program Files\SDL?
You can (and should) remove the other variables as CMake will autodetect these.
Don't forget to reconfigure because CMake might remember these old variables.

I think adding a CMakeSettings.json file is not useful, because the content of the SDL2_PATH variable will be different on every machine.

dirent.h is currently added in support/msvc/include

@manuvdp
Copy link
Copy Markdown

manuvdp commented Oct 24, 2019

@madebr , thanks for the fast response. These where the steps that I had to do. Perhaps good to add a readme_win.md file ?
download cmake-gui https://cmake.org/download/
install cmake-gui
use vs 2019 x86 in Gui
ROM_LABELS Have no idea? Generated an empty rom_labels.h file and pointed to him
SDL2MAIN_LIBRARY C:/Program Files/SDL/lib/x86/SDL2main.lib
SDL2_INCLUDE_DIR C:/Program Files/SDL/include
SLD2_LIBRARY C:/Program Files/SDL/lib/x86/SDL2.lib
Press 'Generate'
Press 'Open Project'

Then copy dlls from the executable x16 emulator:

  • libgcc_s_sjlj-1.dll
  • libwinpthread-1.dll
  • SDL2.lib
  • rom.bin
  • rom.sym
    to $$builddirectory$$/debug/

Then right click on thex16emu project and go to
-> Configuration Properties -> Debugging -> Working Directory set .\Debug

Launch

Now it runs but I have vertical lines on the screen:
image

The debugger seems to work:
image

Any idea?

@madebr
Copy link
Copy Markdown
Contributor

madebr commented Oct 24, 2019

@manuvdp

  • cmake-gui is indeed useful to configure cmake, modify variables etc. Please remember that the downloaded cmake version can differ from the cmake version supplied with Visual Studio.

  • Ideally, cmake should have detected these SDL_* variables automatically (from SDL2_PATH) but you can always define them yourself. Documenting this process somewhere may be useful. Adding it to a section in build_instructions.md would be useful.

  • From the files you listed, only rom.bin must be copied to the build directory.

    • libgcc_s_sjlj-1.dll and libwinpthread-1.dll are the libc and pthread libraries of mingw. Since you are compiling and linking using Visual Studio, these are not needed.
    • SDL2.lib: This is a link library. This is only needed at link time. Not at run time.
    • rom.bin: This is needed. This contains the actual rom
    • rom.sym: This file contains the address locations of the symbols. This is useful for debugging and playing with poking at addresses. But it is not actually needed at run time.
  • I don't know exactly, but I think your artifacts can be explained by this branch being out of date. The rom has been updated in the mean time. Yesterday, I have rebased my cmake branch on the master.
    I just tested it on and I see no visual artifacts.
    My code is at https://github.com/madebr/x16-emulator/tree/cmake_rebase (this branch might disappear in the future)
    Windows CI is at https://ci.appveyor.com/project/madebr/x16-emulator/history
    Note that I have uploaded artifacts: e.g. https://ci.appveyor.com/project/madebr/x16-emulator/builds/28339440/job/p1usf8pegdwty00d/artifacts

@manuvdp
Copy link
Copy Markdown

manuvdp commented Oct 24, 2019

@madebr it works with your latest version!
Thx! Now learning from the sourcecode....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants