How to set up Eclipse for C/C++ with MinGW-W64

Download the Eclipse installer (at writing the latest version is Neon.3) from https://www.eclipse.org/downloads/.

To run Eclipse you will need Java installed.

Download MinGW-W64 from https://sourceforge.net/projects/mingw-w64/.

Start up the Eclipse installer and update it if necessary.  Once that’s done, select Eclipse IDE for C/C++ developers.

Go ahead and install it, but don’t launch it.

Open the MinGW-W64 installer and choose x86_64 architecture.  Make sure the build revision is the highest possible and then continue.

Add the bin subfolder of where you installed MinGW to your Path variable.  For me, this was C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev0\mingw64\bin\.

Reboot if necessary, and then you’re done.

How to build wxLauncher with Eclipse, MinGW-W64 on Windows 10

This assumes that that you have Eclipse and MinGW-W64 already set up.

Download CMake.

Download wxWidgets from https://wxwidgets.org/downloads/.  Currently, the wxLauncher project uses v3.1.0, which is not the stable version.  After installing it, create a new environment variable named WXWIN pointing to the wxWidgets root directory.

Then you will need to compile it.

Open the Command Prompt and type “cd %WXWIN%\build\msw”.

Then type “mingw32-make -f makefile.gcc”.

After that’s finished (it will take a while), type “mingw32-make -f makefile.gcc BUILD=release”.

Download Python from https://www.python.org/downloads/windows/.  Either Python 2.7 or Python 3 is fine.

Make sure that Python has been added to your Path variable.

Download Python Markdown from https://pypi.python.org/pypi/Markdown.

Extract the files (you will need 7-Zip or some other extractor program).  Open the directory where you extracted the files, click on the File tab and open the command line.

Type “python setup.py install” and wait for it to finish.

Download and install the OpenAL SDK from https://www.openal.org/downloads/.

Add the “x86_64-w64-mingw32\lib” subdirectory of your MinGW-W64 installation as an environment variable.  For me, it was C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev0\mingw64\x86_64-w64-mingw32\lib\.

Then open up CMakeLists.txt and look for the following line:  target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES})

Above that, add

find_library(SHLWAPI libshlwapi.a)
find_library(MINCORE libversion.a)

Then replace the “target_link_libraries” line with

target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${MINCORE})
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SHLWAPI})
target_link_libraries(wxlauncher ${SDL2_LIBRARIES} ${MINCORE})
target_link_libraries(wxlauncher ${SDL2_LIBRARIES} ${SHLWAPI})
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES})

Run CMake and fill the SHLWAPI variable with something like the following (it will depend on your version of GCC):  “C:\\Program\ Files\\mingw-w64\\x86_64-7.1.0-posix-seh-rt_v5-rev0\\mingw64\\x86_64-w64-mingw32\\lib\\libshlwapi.a” and MINCORE with C:\\Program\ Files\\mingw-w64\\x86_64-7.1.0-posix-seh-rt_v5-rev0\\mingw64\\x86_64-w64-mingw32\\lib\\libversion.a.

Replace the CMAKE_INSTALL_PREFIX value with the directory where you want wxLauncher to be built.

Import the project into Eclipse and build the Install target.  Then go into the folder you specified for CMAKE_INSTALL_PREFIX and drill down into the bin subfolder, where you will find the executable.

To actually run the game, I found that you must use an FSO later than 3.7.4, or a registry error will prevent you from launching the game.  Also, you might encounter some errors, which can simply be clicked through.

Install Boost for Eclipse Neon, MinGW-W64 on Windows 10

Download the Boost source code from https://sourceforge.net/projects/boost/files/boost/1.63.0/.

Extract the 7Z file (you will need 7-Zip or some other extractor program).

Open the folder, go to tools\build, click on the File tab and open the command line.

Type “bootstrap.bat gcc” and wait a while.

Type “.\b2 –prefix=DIR install” where DIR is where you want to install Boost.  I chose C:\Boost, just to make sure UAC wouldn’t cause any problems.  Wait some more.

When the command line finishes, you need to edit your PATH system variable.  If you don’t know how to get there, search for “environment” and click on “Edit the system environment variables”.

Click on Environment Variables at the bottom of the box that shows up.  In the bottom pane, click on Path and then Edit.  Click on new and add DIR\bin where DIR is the address of the folder where you installed it.  For me, that’s C:\Boost\bin.

You shouldn’t have to reboot, but you might.

How to build Freespace 2 with Eclipse Neon and MinGW-W64

Make sure you have Git installed from https://git-scm.com/ or, if you have Windows 10 with Bash, with “sudo apt-get install git”.

Make a new folder where you want to store the source code.

Run “git clone https://github.com/scp-fs2open/fs2open.github.com.git”.  The full repo is available at https://github.com/scp-fs2open/fs2open.github.com

Run “git submodule update –init –recursive”.

Make a new Path variable called FS2PATH pointing to your Freespace 2 installation

Download CMake from https://cmake.org/download/

Open up CMake (cmake-gui).

Specify the directory where the source code is and the directory where you want the files to be built (I recommend a clean folder).

Click Configure and select “Eclipse CDT4 – MinGW Makefiles”.  You can leave the other options alone.  Click Finish.

When the process has completed, you need to set some variables.

CMAKE_ECLIPSE_EXECUTABLE to the path of your Eclipse executable

CMAKE_ECLIPSE_VERSION to 4.5 (Mars), which is the latest available as of CMake 3.7.2

Check FSO_BUILD_TESTS and FSO_BUILD_TOOLS

Uncheck FSO_BUILD_FRED since Fred can only be build in Microsoft Visual Studio.

Uncheck FSO_USE_SPEECH and FSO_USE_VOICEREC.  I think these might rely on the Boost library.  I will update this post later once I figure it out.

If you have wxWidgets installed, you can check FSO_BUILD_WXFRED2.

If you get an error message, play around with the variables until everything is ok.  This setup worked for me.  The official FS2 repo README is valuable here.

Then click Generate.

Once that is done, open Eclipse for C/C++ and import the folder where everything was built using File/Open projects from File System.

Expand the Build Targets subcategory and right-click on “all”.  Click on Build Target and then wait for a while.

To use your newly build executable, copy all the files in the bin subdirectory of your build folder to your FS2 folder.  Alternatively, you could build the “Install” target instead of “all”, although I have not tested this.