Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Installing SFML on Windows without an IDE  (Read 13490 times)

0 Members and 1 Guest are viewing this topic.

kaikalii

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Installing SFML on Windows without an IDE
« on: July 21, 2015, 02:03:01 am »
I want to install SFML on Windows, where I use only the mingw gcc compiler and no IDE. There is a great tutorial on how to do this on Linux, but for Windows, the only installation tutorials available are for Visual C++ and Code::Blocks, neither of which I wish to use. Assuming I already have gcc installed, and only gcc, how can I install SFML on Windows so that it compiles in a way similar to the Linux tutorial?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Installing SFML on Windows without an IDE
« Reply #1 on: July 21, 2015, 07:34:45 am »
You don't have to "install" SFML. Just unzip it somewhere on your PC and use the usual -I, -L and -l flags of gcc. If you use it like you do, I assume that you know this very basic stuff ;) otherwise, then go learn it first, this has nothing to do with SFML (you can also have a look at the Linux tutorial, the use of gcc is the same).
Laurent Gomila - SFML developer

DT

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Installing SFML on Windows without an IDE
« Reply #2 on: July 22, 2015, 11:22:21 am »
Hmm, trying to help:

It seems you have problem installing SFML, quote: "I want to install SFML on Windows", to do so you should download the correct version of SFML libraries: http://www.sfml-dev.org/download/sfml/2.3.1/

If you've already installed the correct libraries, skip steps 1 and 2.


To Install SFML, you should download the latest SFML (many version, the steps below should help):

1) Knowing which version of gcc you're using:
As you can see, it will require that you know what version of gcc you're on. To determine that, in windows command prompt, type "gcc --version", this should output you what version of gcc you have. If it is an invalid command, you may want to install gcc (MinGW), plenty of tutorials out there. Make sure mingw's bin is inserted in the windows environmental variable pathing - this enables you to use gcc directly from command prompt. Or include the pathing everytime.

2) Download the correct distribution of SFML: http://www.sfml-dev.org/download.php
If gcc is working, the gcc version should be provided, and you can Download the correct 32bit/64bit SFML library. If not, go download mingw (gcc's distributor) and redo step 1.
After you've downloaded the library, extract it somewhere and then follow the guide

3) Example linux 2.3.1 guide: http://www.sfml-dev.org/tutorials/2.1/start-linux.php
Follow the lower half-page of instructions, the compilation guides; gcc is implemented in the same manor.

Make sure to link against the includes directories if you are using a non-standard paths: using -I as stated in the linux guides and the additional libs using -l(lower case L). Else add the pathing to your windows environmental pathing.


My Example:
Windows command line: compilation of object file and executable:

4) Now you should be able to execute a code like in the linux examples, my example of non-standard compilation from the command line:

Using code from the "Getting started" guides provided by SMFL's website and the commands below:

g++ -IC:\SFML\include -c main.cpp -o main.o
g++ -LC:\SFML\lib -o main.exe -o main.o -lsfml-graphics -lsfml-window -lsfml-system

The above was assuming your SFML folder was located in your c: drive.

And, that should produce an executable.
To execute, you may need to have three dependencies to be located where the executable is.
They can be found in the .\SFML\bin folder and will be DLL's; for the above code, use the DLL's without "-d".

Or link, statically by adding adding the "-s" behind every lib in the command line.
Example:
g++ -LC:\SFML\lib -o main.exe -o main.o -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -ljpeg -lgdi32 -lwinmm
If you are linking against the static libs, make sure to include their sub-dependencies!

"Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well", stated half way down the page in the C::B installers guide.
http://www.sfml-dev.org/tutorials/2.3/start-cb.php

It wouldn't be impossible to make a guide on installing MinGW and compiling with windows command line, but probably unnecessary; the steps/examples above, pretty much, hints the process.

Hopefully this can be of some help.

 

anything