User forums > Using Code::Blocks

C::B doesn't show g++ as a compiler option (MSWindows)

<< < (3/4) > >>

stahta01:
Build using Code::Blocks 13.12 using TDM MinGW GCC 4.71 and Downloaded file from http://www.sfml-dev.org/download/sfml/2.2/ GCC 4.7.1 TDM (SJLJ) - 32-bit the code runs.

The OP needs to learn to program and read directions.
Edit4: FYI: I did NOT do the debug target correctly per these directions in the attached CB Project.

--- Quote ---The settings shown here will result in your application being linked to the dynamic version of SFML, the one that needs the DLL files. If you want to get rid of these DLLs and have SFML directly integrated into your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d" for Debug, and "sfml-xxx-s" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.
--- End quote ---
Edit2: The directions that the OP likely failed to follow.

--- Quote ---Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well. This means that if you are linking sfml-window-s or sfml-window-s-d for example, you will also have to link opengl32, winmm and gdi32. Some of these dependency libraries might already be listed under "Inherited values", but adding them again yourself shouldn't cause any problems.
--- End quote ---

I used the directions as a hint and I got it to work.
I used CB Global Variable to location of Library.
I attached zipped CB project.

Edit3 build log because I cut and pasted the old CB Project instead of the zipped one.

--- Code: ----------------- Clean: Release in SFML (compiler: GNU GCC Compiler)---------------

Cleaned "SFML - Release"

-------------- Build: Release in SFML (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -DSFML_STATIC -O2 -IC:\SourceCode\OpenSourceCode\Libs\GUI\SFML\SFML-2.2-windows-gcc-4.7.1-tdm-32-bit\SFML-2.2\include -c C:\test\SFML\main.cpp -o obj\Release\main.o
mingw32-g++.exe -LC:\SourceCode\OpenSourceCode\Libs\GUI\SFML\SFML-2.2-windows-gcc-4.7.1-tdm-32-bit\SFML-2.2\lib -o bin\Release\SFML.exe obj\Release\main.o  -s  -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lglew -lfreetype -ljpeg -lopengl32 -lgdi32 -lwinmm
Output file is bin\Release\SFML.exe with size 1002.50 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))

--- End code ---

[attachment deleted by admin]

OldFangle:

--- Quote from: stahta01 on January 08, 2015, 11:07:17 pm ---I suggest using the same compiler to build both the library and the code using the library.
...
Do you know which GCC version/toolchain was used to build the library?

--- End quote ---

If you mean the .lib files, the Code::Blocks I'm using is an .exe installation, I didn't build it from source code.
How may I check to see how its library was built?

OldFangle:
> Build using Code::Blocks 13.12 using TDM MinGW GCC 4.71 [snip]

OK

> The OP needs to learn to program and read directions.

I'm finding references to "OP" and "OP CodeBlocks" but not a definition.  What is it?

> FYI: I did NOT do the debug target correctly per these directions in the attached CB Project.

I'm likely having the same problem.  I've been watching for those -s suffix files.  I may have entered SFML_STATIC in the wrong place.  It's in projects > build options > #define .

> when static linking, you will have to link all of SFML's dependencies to your project as well. This means that if you are linking sfml-window-s or sfml-window-s-d for example, you will also have to link opengl32, winmm and gdi32. Some of these dependency libraries might already be listed under "Inherited values", but adding them again yourself shouldn't cause any problems.
//

Yes I did forget to learn more about that.  I forgot to look for those and make sure they're on a link path.

> I used CB Global Variable to location of Library.

I don't know what that means.  If it's a shorthand command I haven't seen it or learned it yet.

> -------------- Clean: Release in SFML (compiler: GNU GCC Compiler)---------------
> Cleaned "SFML - Release"

I still need to learn this.  Whatever was said in a tutorial about Cleaning a Release, didn't impact itself for its meaning or importance at the time.

----------

Thank you for all the pointers and leads.  I'll start with that Code::Blocks 13.12 using TDM MinGW GCC 4.71 installation and then work through the whole of the message that follows.

Thank you again.

stahta01:
OP means Original Poster.
CB means Code::Blocks
GV means Global Variable  http://wiki.codeblocks.org/index.php?title=Global_compiler_variables

Did not see anything I missed; if it still does NOT work after adding the "-s" or "-s-d" to the library post the new build log.

NOTE: Your run-time error was because you where linking to the DLL libs instead of the static libs like the define implied; adding the "-s" or "-s-d" is the proper way to use the static SFML libs.
Note, if you had added the SFML bin folder to the CB Project library search path the error would have changed or maybe even went away.

Tim S.

stahta01:

--- Quote from: OldFangle on January 08, 2015, 11:50:40 pm ---
--- Quote from: stahta01 on January 08, 2015, 11:07:17 pm ---I suggest using the same compiler to build both the library and the code using the library.
...
Do you know which GCC version/toolchain was used to build the library?

--- End quote ---

If you mean the .lib files, the Code::Blocks I'm using is an .exe installation, I didn't build it from source code.
How may I check to see how its library was built?

--- End quote ---

The URL you posted said there was two major choices.
1. Downloading a prebuilt SFML library
2. Building the SFML library yourself.

You need to know which one you did!
If you downloaded a SFML library it needs to match the compiler being used to build the CB Project.

Tim S.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version