Skip to content
Rolzad73 edited this page May 2, 2017 · 24 revisions

This page explains how to compile wagic

Wagic's source code is currently hosted at Github.

You might want to compile the game from the sources for various reasons. You want to play the game with the newest features which aren't present in the official release yet, or perhaps you want to add features to the game, or you want to see how to create a game with the JGE library, or you're trying to port Wagic to another platform, or trying to create a Pokemon card game, who knows ...

Compiling Wagic shouldn't be difficult, however you might need to have some basic in PSP programming or at least in bash or DOS shell commands to compile it for the PSP.

Getting the sources

For non-developers

The simplest way is to get the latest Wagic master branch code located here. It's a simple zip file that you can decompress it wherever you want. This method does not allow source update. Each time you want to update the sources, you need to re-download the zip file.

For developers

No excuse for you to not use the full git power. So, if you're not familiar with Git, just read GitHub help, create an account, select your prefer Git client, fork or clone Wagic repository and start hacking around.

Compiling on Windows

This part of the article deals with compilation under a Windows environment.

Thanks to various portability layers, Wagic can be compiled for Mac, Windows, Linux, Android, iOS and of course PSP. Compiling a Windows version helps a lot for debugging.

Compiling on Windows for Windows

  1. Download and install Microsoft's Visual C++ Express 2010 (freeware)
  2. Start Visual C++ Express. In the top menu bar, click on "File -> Open -> Project/Solution". Navigate to the file "{where you stored Wagic sources}\projects\mtg\mtg_vs2010.sln" and open it.
  3. Visual C++ Express will now read the structure of the source code files and folders, and display that structure in the "Solution Explorer" to the left of the screen.
  4. In the Solution Explorer, right-click on the topmost entry (which should read "Solution 'mtg' (2 projects)"). A context menu opens, click on "Clean Solution". The Output Window at the bottom on the screen should now show the information "Clean: 2 succeeded, 0 failed, 0 skipped"
  5. Still in the Solution Explorer, right-click on the folder "mtg" and choose "Build". Wait while Visual C++ compiles the source code. You will probably see some warnings (which you can ignore at this stage). When the process has finished, the bottom line in the output window should start with "Build: 2 succeeded, 0 failed". If the build has failed instead, then copy the error from the output window and ask for help in the forum.
  6. You have now successfully built the program from the git sources. To actually play it, you have several alternatives:
  7. "Clean" method: Create a Wagic installation solely for playing the game. Copy everything from "{where you stored Wagic sources}\projects\mtg\bin" (including folders and subfolders) to a different location. There, start the file "template.exe" that has been created by the steps above. this "template.exe" is your Wagic executable. You can now play Wagic. Whenever you update the sources from the SVN, and/or compile them again, you have to repeat this step, to update the files in your "playing" installation.
  8. "Easy" method: Just start the file "template.exe" that has been created in "{where you stored Wagic sources}\projects\mtg\bin". This means that you use the files in your {where you stored Wagic sources} folder for playing. This has a small risk that your files get overwritten if you update the sources using git.
  9. "Debug" method: You can further simplify the process by just clicking on the green "play" symbol (a green triangle pointing to the right) in VC 2008's icon bar. (If it doesn't work the first time, try it again, sometimes the program tries to build JGE and Wagic in the wrong order, but it will then work on the second attempt. This will start Wagic in "Debug" mode. This is the same as option (2), with the additional advantage that if something goes wrong, you'll get a more meaningful error message, and the Visual C++ editor will show you the file and the line of code that caused the problem. All three are valuable pieces of information for the programmers, so please add them to your bug report if you post one.
  10. Enjoy the bleeding edge of Wagic development.

Note: The Git repository always a work in progress, and therefore the binaries may have problems, or may not even start in the first place. If this happens to you, first reduce potential error sources by testing your new template.exe in a fresh unmodded install of Wagic, instead of a using a modded installation. If the problem persists, ask in the forum for help.

Note 2: Compiling the sources for the first time may take quite long. Compiling them again after an update will be much quicker, since the compiler will only update the files that are affected by the changes.

Compiling on Windows for the PSP

To run Wagic on the PSP, you need to compile a new EBOOT.PBP. The method described here has successfully been tested on Vista and Windows XP machines (with version 0.11.1 of the minimalist PSP SDK). Please report any issues or success!

  1. Download and install a PSPSDK environment for windows, such as the Minimalist PSP SDK by Heimdall. Let the PSPSDK add its path to the system paths (the Minimalist SDK has an option for that which is on by default, just don't turn it off).
  2. Using a DOS command line shell, navigate to the JGE directory, and type "make clean" (and ENTER). This is to remove the old JGE library. (Note: If you get a message "command not found" at this stage, then the PSPSDK's path information has not been installed correctly; repeat step (2).)
  3. In the same directory, type "make" (and ENTER). It should create some files. The important one is named libjge300.a in the lib/psp/ folder. If there is no lib/psp/libjge300.a file in your JGE directory, or if this file is old, then something went bad.
  4. Go to the directory projects/mtg with a DOS shell
  5. Type "make clean" (and ENTER)
  6. Type "make" (and ENTER). This should create an EBOOT.PBP file in your projects/mtg folder. That's it!

Note: If there haven't been any changes to the JGE library itself, then you obviously don't need to recreate it each time, so steps 3 and 4 are not necessary in this case. If you're not sure whether you need to compile JGE, then it's better to do it, to be on the safe side.

Note 2: The "make clean" step itself is usually not necessary, but recommended if you are not a C++ guru.

Note 3: If you don't know what a DOS shell is and how to use it, here are some quick instructions:

  • To open the DOS shell, click on "Start" in the Windows task bar, then click on "Run", type cmd and click on "Ok". This will open a black DOS window with a command line prompt.
  • To navigate to another drive, type that drive's letter, followed by a colon, and press Enter.
  • *To navigate to a specific directory, type cd, press space, then type a * sign, and then type the name that directory and press Enter.
  • _So, if you want to navigate to a directory called Games\WagTheSource\JGE, which sits on drive E:, you have to first type E: (and press Enter) and then type cd \Games\WagTheSource\JGE (and press Enter).

Compiling on GNU/Linux

Linux is one of the main development environment of Wagic developers. So, Linux has not one but 3 possible projects using either X, Qt or SDL. The most maintained Wagic frontend is Qt. Note that the same method works on Mac and Windows as well.

Compiling on Linux for Linux using QtCreator

  1. Install QtCreator using your Linux distribution package installation mechanism.
  2. Open QtCreator
  3. Navigate where you stored wagic sources and open "{where you stored Wagic sources}/projects/mtg/wagic-qt.pro"
  4. By default, the console wagic without UI is built. To build the graphic version, go into projects/build steps/qmake and adds CONFIG+=graphics.
  5. Go into "build" menu and select "rebuild all".
  6. To run the program simply press the green "run" arrow.

Troubleshooting:

  1. Sometimes, the compiler might just not complete the compilation because of WARNING messages getting treated as ERRORS. If you come across one of those warnings, report it on the forums.
  2. To continue the compilation, edit the "wagic-qt.pro", and then search for "-Werror", removing it from anywhere you find it.
  3. Sometimes, when generating the executable, the console may output a message saying that it skipped an incompatible "libboost_thread.a". This is generally not an issue. None the less, in some 64 bits systems, the compiled executable will give a "Segmentation Fault" error when trying to run it.

Compiling on Linux for Linux using QMake

  1. Resolve Dependancies sudo apt-get -qq install qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev
  2. $ mkdir qt-gui-build
  3. $ cd qt-gui-build
  4. $ qmake ../projects/mtg/wagic-qt.pro CONFIG+=release CONFIG+=graphics
  5. $ make -j8
  6. the resulting executable is qt-gui-build/wagic

Compiling on Linux for Linux x11

TODO: complete steps, but basically:

  1. cd to JGE/
  2. $ make linux
  3. cd to projects/mtg/
  4. $ make x11
  5. the resulting executable is projects/mtg/bin/wagic

NOTE: not included in instructions was resolving dependencies.

NOTE: at one time there was also a step to include FMOD for sound I think, but it may have been deprecated to the point of no return IIRC

Compiling on Linux for PSP

The steps to do:

  1. Installing PSP SDK
  2. Compile JGE
  3. Compile Wagic

The steps in details:

  1. Installing PSP SDK
  2. Go to Minimalist PSPSDK Project Download Page on sourceforge and then grab the correct RPM or DEB that matches your system. Once you have the file, install it manually with your system installer (dpkg for Debian software packages). On some distributions, double clicking the RPM or DEB file gives you the option to install the package.

  3. Once installed, you need to add several environment variables.

  4. ** In case the lines already exist on your file, be sure then they are uncommented and pointing to your PSP SDK installation.

  5. **

    If you are using bash and want to set the variable for only one user you can use a text editor (vi, kate, nano, gedit, or any other alike) to and edit the "/.profile" or "/.bash_rc" file. At the end of one of those file, add those lines:

export PSPDEV="/opt/pspsdk" export PSPSDK="$PSPDEV/psp/sdk" export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin" ::: ** If you are using zsh, edit ~/.zshrc if you want to set the variables for a single user. ::: * If you use a different shell, search in your shell manual to know which file you need to edit.

  1. Compile JGE 1. If I compiled for another platform before, I usually do a “make clean” 1. I went to JGE dir (cd JGE) and launch a “make“ 1. If you get a ERROR while compiling, telling you that the file "vram.h" is missing, head then to the "JGE/include/" folder, and copy the "vram.h" file from there on "JGE/src/", it will solve the problem.
  2. Compile Wagic 1. If I compiled for another platform before, I usually do a “make clean” 1. I went to Wagic dir (cd projects/mtg) and launch a “make“

Signing the EBOOT file on Linux

Software required:

  1. wine. Install it typing "sudo apt-get install wine" on your console.

Steps to do:

  1. Once the PSP EBOOT has finished compiling, you need to copy the "wagic.prx" file generated on your "projects/mtg/" folder to "pspsdk/" (inside your checked out source code of wagic). There you'll see a file named "signing.zip", unpack the zip file there. Once done, move the "wagic.prx" onto the bin folder, and on the bin folder remember to set the "execution" permission on the two exe files there.

  2. On your console, head to the bin folder ("pspsdk/bin", or either press F4 if your File Manager supports the Terminal feature) and then execute the next commands: wine fix-relocations.exe wagic.prx wine prxEncrypter.exe wagic.prx

  3. The two commands will show little, or no feedback, but they will generate an additional file. Then, copy the "wagic.prx" and "data.psp" back to the "projects/mtg/" folder, overriding any previous files.

  4. On your console then, into the "projects/mtg/" folder, execute the next command: pack-pbp EBOOT.PBP PARAM.SFO icon.png NULL pic0.png pic1.png NULL data.psp NULL

  5. It will pack the EBOOT.PBP file with the signing on it.

Compiling on Linux for Windows

That should be doable with g++ but the make need to be changed and I don’t know how to do that.

Compiling for Android (SDK Tools, Revision before 25.3.0)

These instructions are command-line compiling on Linux for Android, but will also work on Windows using the appropriate command-line format.

Required installations

  • Wagic source tree
  • Java JDK
  • Android NDK
  • Android SDK
  • Apache Ant

Assumptions (change as required)

  • Wagic source directory = /wagic
  • Android NDK directory = /android-ndk
  • Android SDK directory = /android-sdk
  • Apache Ant directory = /apache-ant

Steps

Build process
  1. Compile the Wagic source using the NDK.
    In the terminal type:
    $ /android-ndk/ndk-build -C /wagic/projects/mtg/Android

    where -C sets the Wagic Android source directory. You can also add the switch -j with a number of jobs (aka -j8 for 8 jobs) to compile faster. After it has finished compiling, you will have two folders (armeabi and armeabi-v7a) in /wagic/projects/mtg/Android/libs.

  2. Set target Android platform.
    In the terminal type:
    $ /android-sdk/tools/android list targets

    It will list all of the installed Android target IDs for the platform we will use. In my case the target id is 11 (yours will most likely be different) for Android 2.3.3, so in the terminal type:
    $ /android-sdk/tools/android update project -t 11 -p /wagic/projects/mtg/Android

    where -t is the target ID and -p is the path for the Wagic Android source directory.

  3. Compile apk using Apache Ant.
    In the terminal type:
    $ /apache-ant/bin/ant debug -f /wagic/projects/mtg/Android

    where -f indicates the path of the Wagic Android source directory and debug is for the debug version. Alternatively, you can compile a release build by using release instead of debug. You will have to enter in 2 passwords for the signing key, which at this time are both 'password'.

If successful, the apk (named Wagic-debug.apk or Wagic-release.apk) will be located in the /wagic/projects/mtg/Android/bin folder.

General Notes

This is probably obvious, but you don't need two different copies of the sources if you want to create both a Windows/Linux and a PSP version.

It is more than recommended to develop using the Windows/Linux version, and test with the PSP version from time to time.

If you have any issue compiling, please report your problems in the forums, with as much precision as possible. If you get an error in Visual Studio, search the output window for the first occurrence of the term "error", and post that line in the forum. If you get an error while compiling for the PSP, copy the last lines of the compiler output and paste them into your forum post.

Playing compiled source

See windows info, make it more general (same thing for linux too, only exec name changes)