Menu

#407 WIN32: fix build for MSVC.

v3.x
closed-accepted
gpz
None
enhancement
2025-11-26
2025-11-24
No

MSVC complains the fact that unistd.h doesn't exist.
This fix comes from my port for the compiler from Microsoft, but it is needed also by my other port made with CEGCC, the GNU based environment for WinCE.
Presence of unistd.h is already tested by configure script and the HAVE_UNISTD_H is already available to the developers.
So, nothing should change for all other ports.

1 Attachments

Discussion

  • gpz

    gpz - 2025-11-24

    applied in r45867 - thanks!

    Is that MSVC port available somewhere? It would be interesting to look at, perhaps we can make it build for regular Windows this way again (which would make debugging on Windows easier)

     
  • gpz

    gpz - 2025-11-24
    • status: open --> closed-accepted
    • assigned_to: gpz
     
  • Carlo Bramini

    Carlo Bramini - 2025-11-26

    Actually, it is not something very awesome ^^;
    I made it in this way:
    1) I created an empty project with VS2022, for creating only the emulator for C64.
    2) Under CYGWIN, I configured VICE with autotools.
    3) I grabbed all *.c and *.h files generated by autotools and I put them into the root directory of the above project. Some modifications were needed into config.h actually.
    4) I included all files of VICE into the project and I excluded the ones that are not needed.
    5) Copy data files into the output directory (typically "Debug" or "Release"), compile and run.

    It's a very quick and dirty work, but at the end the resulting executable worked fine.
    Actually, between "compile" and "run" there is a number of modifications to do for MSVC.
    Hopefully, there aren't many changes to make.
    However, the easy debugging experience with Visual Studio paid all efforts for creating it.

    Probably, the best way for supporting Visual Studio is to migrate to CMake, which is much more open to foreign platforms than autotools and it allows you to use modern and much faster build tools than Make, like Ninja for example.

    However, I won't recommend to you to use MSVC for creating also the files to be released (at least in my opinion), just because the created binaries are not able to run on older versions of Windows.
    Infact, even the execution of a simple hello world program is blocked on system running obsolete versions of the operating system, while with MinGW you can make binaries that can run from Windows 95 to the latest Windows 11.

    However, I can share the project for VS2022 if you want, so you could try it yourself.

     

    Last edit: Carlo Bramini 2025-11-26
  • gpz

    gpz - 2025-11-26

    actually msys2 also dropped support for anything before windows 10 (and we don't support anything more ancient either).

    VICE can produce a cmake build environment (configure with --enable-cmake) - but the result doesnt work with msvc at all ( tried)

    It would be great if you could share your entire project (including whatever modifications in the source), so i can try what happens when i try in msvc :)

     

Log in to post a comment.

MongoDB Logo MongoDB