Guide:Compiling VVVVVV on Windows with Visual Studio

From Viki
Jump to navigation Jump to search

This page is a guide to compiling VVVVVV on Windows with Visual Studio.

Windows and Visual Studio are chosen because most people use Windows, and most Windows users use Visual Studio.

Setting up Visual Studio

If you don't already have Visual Studio installed, then you will need to download it.

This guide assumes that you will download and install Visual Studio 2022 (the latest non-preview version).

To download Visual Studio:

  1. Go to the Visual Studio downloads page.
  2. Next to Visual Studio 2022, click Free download under Community.
  3. VisualStudioSetup.exe will be downloaded. Run it.
  4. During installation, make sure to check the Desktop development with C++ workload, because VVVVVV is programmed in C++. You can uncheck everything else; they won't be needed.

By the way, Visual Studio 2022 (with the C++ stuff) will take up about 12 gigs on your disk (it gets worse with each version). So if you're almost out of disk space, make sure to clear it up before installing.

Also, you might be prompted to restart your computer before being able to use Visual Studio.

Once you have Visual Studio open, it will ask you to sign in with an account. You don't really have to for now, but if you don't, it considers you on a trial until you sign in with an account. When the trial expires, it will make you sign in with an account anyways. If you are advanced enough, you can extend the license expiration date indefinitely with the VSCELicense PowerShell module and avoid signing in.

Cloning VVVVVV

You will need to download VVVVVV.

"Cloning" just means downloading a repository, but with a mechanism to let you easily download updates to it later, without having to re-download everything all over again. It is recommended to clone the VVVVVV source code repository instead of merely downloading it.

Visual Studio lets you clone Git repositories directly from the app. Doing this also automatically creates a new project for you, too. How convenient!

From the Visual Studio welcome screen:

  1. Click on Clone a repository.
  2. Enter in https://github.com/TerryCavanagh/VVVVVV under Repository location.
  3. Click Clone.

Downloading dependencies

You will need to download SDL 2.

Note that since VVVVVV 2.2, the game uses SDL 2. There are older versions of SDL (SDL 1.2), but you don't want to use those.

To download SDL:

  1. Go to the SDL download page.
  2. Under Assets, click on SDL2-devel-2.26.4-VC.zip to download it.
  3. In Windows Explorer, right-click on the file, and click on Extract All....
  4. Click Extract.
  5. Inside the extracted folder, drag SDL2-2.26.4 to C:\.
    • You can put this folder anywhere you want, but the rest of this guide assumes you have it in C:\. If you have it somewhere else, then you will need to change all paths referencing C:\SDL2-2.26.4 accordingly.

Generating the VS Solution

You will need to generate the files used to compile the game. Visual Studio's build files are called "Solutions". No, I don't know why they call them that.

Doing this entails opening a command prompt.

  1. From the menu bar, click on Tools, then Command Line, then Developer Command Prompt.
  2. In the command prompt, type cd desktop_version.
  3. Type mkdir build, then cd build.
  4. Then enter in this long command:
    cmake -A Win32 -G "Visual Studio 17 2022" .. -DSDL2_INCLUDE_DIRS="C:\SDL2-2.26.4\include" -DSDL2_LIBRARIES="C:\SDL2-2.26.4\lib\x86\SDL2;C:\SDL2-2.26.4\lib\x86\SDL2main"

    If you prefer to copy and paste, then after copying the above command, you can paste it in by right-clicking inside the command prompt.

    • If your SDL2-2.26.4 folder is not in C:\, you will need to change the paths in this command.
    • If you didn't check Desktop development with C++ when installing Visual Studio, you'll get an error. [1]
    • If you are using a Visual Studio version other than Visual Studio 2022, you will need to change the -G string to match your Visual Studio version. [2]

Compiling

Now you're finally ready to compile the game.

To compile:

  1. Navigate to the build folder under desktop_version in the Solution Explorer panel on the right side of the screen.
    • If you don't see it (which is highly likely), then you will need to click the Show All Files icon. Which looks like this:
      Visual Studio 2022 Show All Files icon.png
  2. Double-click on VVVVVV.sln.
  3. From the top menu bar, click on Build, then Build Solution. Visual Studio will attempt to compile the game.
    • If it fails with an error LNK1104 saying "cannot open file 'SDL2.obj'", you will need to re-run the cmake command in the previous section, but add .lib to all the lib paths of SDL2 and SDL2main, and try again.[3]

      Once you do this, there will be a prompt saying that "a file has been modified outside the environment". It's fine to click Ignore All, but if you're worried, you can click Reload All.

    • If it fails saying that an SDL function was not found (SDL_OpenURL, SDL_zero, SDL_zeroa, or similar), then your SDL is too old.
      • VVVVVV 2.3 needs SDL 2.0.14 or later.
      • VVVVVV 2.4 needs SDL 2.0.18 or later.

If it succeeds, then you just compiled VVVVVV!

Running

To navigate to the VVVVVV.exe:

  1. In the Solution Explorer panel, right-click on VVVVVV.
  2. Click on Open Folder in File Explorer.
  3. Open the Debug folder.
    • If you decided to compile in release mode, then you would open the Release folder instead.

You will need to put a copy of data.zip into the same folder as VVVVVV.exe, either by grabbing it from Steam or from downloading them directly from the Make & Play page (click on [Desktop data file]).

Lastly, you also need the SDL 2 .dll in the same folder as VVVVVV.exe. Copy over C:\SDL2-2.26.4\lib\x86\SDL2.dll (or wherever you put that folder) to the folder.

After that, running VVVVVV.exe should just work!

  • If you get an error dialogue saying "The application was unable to start correctly (0xc000007b)", that means you copied the 64-bit SDL2.dll instead of the 32-bit one. Copy the SDL2.dll from the x86 folder and try again.

Notes

  1. The error will probably look like:
      Generator
    
        Visual Studio 17 2022
    
      could not find any instance of Visual Studio.

    To fix this:

    1. Go back to Visual Studio.
    2. Click on Tools, then Get Tools and Features....
      • If you still have the installer open, then it will bring you to the installer with a dialogue box saying that it's already open.
    3. If prompted, click Modify next to Visual Studio Community 2022.
    4. Check Desktop development with C++.
    5. Click Modify in the bottom-right.
      • If you still have the VVVVVV project open, it will pop up a dialogue asking you to close the project. Just click Continue on that dialogue.

    You might be prompted to restart your computer before being able to use Visual Studio.

  2. Change the string to the one matching your version in this list:
    • VS 2010: "Visual Studio 10 2010"
    • VS 2012: "Visual Studio 11 2012"
    • VS 2013: "Visual Studio 12 2013"
    • VS 2015: "Visual Studio 14 2015"
    • VS 2017: "Visual Studio 15 2017"
    • VS 2019: "Visual Studio 16 2019"
    • VS 2022: "Visual Studio 17 2022"
  3. Like so:
    cmake -A Win32 -G "Visual Studio 17 2022" .. -DSDL2_INCLUDE_DIRS="C:\SDL2-2.26.4\include" -DSDL2_LIBRARIES="C:\SDL2-2.26.4\lib\x86\SDL2.lib;C:\SDL2-2.26.4\lib\x86\SDL2main.lib"