How to configure C ++ SFML library in codeblocks or dev c ++?

1

I have managed to configure the SFML library in codeblocks but once I move the .exe file to another place it does not work anymore.

My configuration is as follows:

download CODEBLOCK: http://www.codeblocks.org/downloads/binaries
download SFML: https://www.sfml-dev.org/download/sfml/2.4.2/
version: GCC 4.9.2 TDM (SJLJ) - 32-bit
uncompress: c:\SFMLtdm

Open codeblocks and create a new project with console options.
Settings -> Compiler
    Toolchain executables
        Additional Paths
            C:\SFMLtdm\bin

    Search directories
        Compiler
            C:\SFMLtdm\include
        Linker
            C:\SFMLtdm\lib

    Linker settings
        sfml-graphics
        sfml-window
        sfml-system

    Compiler settings
        #defines
            SFML_STATIC

1 [2] [3]

Annex the source code:

link

    
asked by Pedro Quiñonez 02.08.2017 в 18:11
source

1 answer

1

I consulted with the stars and sacrificed a whole unsigned variable to the supreme gods of C ++, all in order to be able to use divination powers ... deep voices of the low bits have whispered to me binarily in my ear. And they have told me the following:

Linked binaries do not match your SFML configuration.

It seems that you intend to statically link SFML, so you define SFML_STATIC :

But according to the Code :: Blocks configuration tutorial , when you configure the static link you must use the static binaries, which have the suffix -s : sfml-xxx-s-d for Debug and sfml-xxx-s for Release, you are linking with the dynamic linking binaries:

Linker settings
    sfml-graphics
    sfml-window
    sfml-system

And therefore, when the executable does not have access to the dynamic libraries (for example, when changing routes) it stops working because it lacks them. Change the linking properties to use the static libraries:

Linker settings
    sfml-graphics-s
    sfml-window-s
    sfml-system-s
    
answered by 03.08.2017 в 09:57