Good to know's & Lessons learned - Zmote/cppgame-dogan GitHub Wiki

Index


#Boost Boost has essentially two ways of working, one with header-only and one with built boost binaries, the library files. The both aren't mutually exclusive, working with library files can spare you manually linking a lot of headers. Working with header-only in boost is pretty straight forward and only requires you to set the right include path(which would be the installation folder of boost, the one-folder above of the directory with the folder "boost" in it). Working with libraries is a little trickier, ie. first off it needs you to build the libraries on your system. I'll go over it in a step-by-step fashion:

  1. Enter the directory with your command prompt where the "boost" folder is(that directory also contains the file bootstrap.bat)
  2. execute bootstrap gcc (for MinGW Installations), this will generate the appropriate b2.exe/cmd for your compiler (the one we use for this example is MinGW, which is supported by gcc toolset)
  3. Next, you can install all libraries with b2 --toolset=gcc (with b2 --show-libraries you can get a list of all library names, with another option you can install libraries seperately, like: b2 toolset=gcc regex) --> this will install the libraries into the current folder you're in)
  4. Now, in your current folder, the one where the boost - folder is as well, you should have a new folder named bin.v2. Don't mistake this folder as the one you need to link to as your library path! --> there should be another folder in the same directory called "stage", this is where all the build libraries are put, under stage/lib, that's what will be our library path.
  5. Now, in Cevelop under C++ where you define the Paths and Symbols(where you also define the include paths), navigate to library path and enter <boost_installation_folder>/stage/lib as your library path.
  6. We're almost done. Now we need to link the appropriate libraries for our programm, this might require you to link more than one, for example, for the log library, you'll also need the boost_system library and boost_thread libraries. For the appropriate names, check out the stage/lib folder(they are version and have additional info in their name, like -d for debu version)
  7. Example: If I want to use the logging features of Boost, I'll have to link following libraries --> boost_system, boost_log and boost_thread, which on my system look like following: boost_log-mgw61-mt-d-1_63, boost_thread-mgw61-mt-d-1_63, boost_system-mgw61-mt-d-1_63
  8. I know it's a pain in the ass! But after you've done all of this, a main program could look like this:

//#include (&lgt;)boost/log/trivial.hpp(rgt;)

int main() { BOOST_LOG_TRIVIAL(info) << "Application started"; return 0; }

#Git How to "remove" files defined in gitignore afterwars?

  1. Remove all files from cache/track index: git rm --cached -r .
  2. update gitignore file with the new patterns
  3. git add . (will only add those that don't match pattern + remove files from remote as well that match pattern)

#SFML

Using other libraries with SFML

  • SFML works with more powerful GUI libraries like Qt and wxWidgets. All you have to do is to embed the SFML context within the said library and SFML will react to key events as usual. See SFML Section: Playing with the window for more information.

OpenGL support

  • SFML allows to draw windows with OpenGL, which is very powerful, but can be very complex. SFML has own drawing, windowing, event handling libraries, but in case you'd wish to use OpenGL, it's available. See SFML OpenGL

Eclipse/Cevelop Installation

*See Link or follow: How-To Run SFML in Eclipse CDT (Windows, but *nix is similar)

Install the MinGW compiler and set up operating system PATH (Windows Only):

  1. Install MinGW. Note that the stable version of MinGW runs gcc 3.4.5, and SFML was built with 4.4, so you need a build that comes with gcc 4.4; a link to a compatible MinGW is provided in the Code::Blocks install tutorial.
  2. Download and install MSYS from the MinGW site. MSYS contains windows command-line utilities (e.g. "make") that supplement MinGW.
  3. Add the MinGW and MSYS bin dirs to your system PATH. The dirs you need to add are typically "C:\MinGW\bin" and "C:\msys\1.0\bin" (don't forget that windows uses semi-colons as delimiters, e.g.: "...;C:\MinGW\bin;C:\msys\1.0\bin").

Install Eclipse IDE and the CDT plugin (for C++ development): 4. Download/install the Java runtime (JRE). Eclipse runs using native SWT components under Java. 5. Download the Eclipse IDE and unpack into "C:\Program Files" or similar dir (no install :D ). 6. Download the latest Eclipse CDT archive file for C++ development (the authors provide a direct link in the CDT download website; they mention a bug in the repository related to the debugger). 7. Run Eclipse, and go to Help > Install New Software... > Add... Then, under the Add Repository dialog, select Archive... and open the "cdt-master" zipped archive. Give it a name like "CDT archive" and add. Under Work With, select the "CDT archive" from the drop-down, and check off "CDT Main Features" and "CDT Optional Features". Hit next and finish installation. 8. At this point, Eclipse is ready to build SFML projects as long as your path is setup correctly. Test on the command-line by typing "g++" and "make", both should run but not do anything because there's no targets.

Build and Run the Hello World Program: 9. In Eclipse, select File > New > C++ Project. Enter a project name such as "SFMLHelloWorld". Under Project type: select "Executable" and "Hello World C++ Project", and under Toolchains: select "MinGW GCC". Press Finish, which creates the project, including Debug and Release configurations. 10. Replace the content of "SFMLHelloWorld.cpp" with the example program from the Code::Blocks tutorial. Before we can build it, we need to tell the project where to find the SFML header files (include), and what libraries to link to when building (lib). 11. By default, the Debug configuration will be selected as the Active configuration; we will edit the settings for this configuration first. In the Project Explorer, Right-click on "SFMLHelloWorld" and select Properties. In the properties dialog, select C/C++ Build > Settings > Tool Settings. This is where you configure your project for search paths, library linking, and other options. Starting top to bottom, the first thing you probably want to do is to define the SFML_DYNAMIC macro (this is for dynamic library linking, e.g. DLLs, don't do this if you are going to perform static linking). Under GCC C++ Compiler > Preprocessor, click the "plus/add" icon under Defined symbols (-D) and add "SFML_DYNAMIC" (see image).

  1. Include the SFML header files on the search path. Under GCC C++ Compiler > Includes, click the "plus/add" icon under Include paths (-I) and add "C:\proj\lib\SFML-1.6\include" where "C:\proj\lib\SFML-1.6" is the path of your SFML installation (see image).

  2. Tell the Linker where to find the SFML libraries. Under MinGW C++ Linker > Libraries, click the "plus/add" icon under Libraries (-l) and add "sfml-system-d". NOTE: this is the debug SFML system library; add this library if you are editing your debug configuration (as shown in the image). You can toggle between debug/release configurations at the top of this dialog under Configuration:. If this configuration is the release configuration, use the release library ("sfml-system"). You can optionally add the other libraries as shown. Note that the linking order matters (as explained in the Code::Blocks tutorial).

  3. Add the lib dir to the library search path. Under MinGW C++ Linker > Libraries, click the "plus/add" icon under Library search path (-L) and add "C:\proj\lib\SFML-1.6\lib", again, where "C:\proj\lib\SFML-1.6" is the path of your SFML installation (see image).

  4. Hit Apply to save changes. Perform steps 11 to 14 once more for the Release configuration by first selecting "Release" under Configuration:.

  5. In the code editor, press ctrl+B to build the program. Run it by going to Project Explorer > SFMLHelloWorld > Binaries, right-click on "SFMLHelloWorld.exe" and select Run As > Local C/C++ Application. That should be it! Hopefully this is helpful. I think this is enough to post under the tutorials; if Laurent would feel so inclined, please feel free to add-to/repost as another installation tutorial.

See Tutorial Pictures for further guidance.

  • Linking order for static linking:
    sfml-graphics-s-d
    sfml-window-s-d
    sfml-main-d
    opengl32
    sfml-system-s-d
    winmm
    gdi32
    freetype
    jpeg

-s(static), -d(debug), for release, use only -s flagged libs. Notice, audio is not yet included here.
Mehr zu Dependencies von SFML beim Static Linking, siehe SFML:Link

JavaScript Game Development

C Language notes

Winapi notes

In Cevelop, you need to include following linker flag in MinGW Settings (MinGW C Linker - > Miscellaneous, in Linker flags input field, type: -mwindows This allows to use on system libraries to be linked on compile.