compiler error with windows 8 sfml and codeblocks - c++

Trying to pick up a 2D library, SFML was my choice.
But, I can't get it to link properly.
When I try to build and run it I get the following error:
the procedure entry point gxx personality v0 could not be located in the dynamic link library sfml-graphics-d-2.dll
btw IDE is Code::Blocks 12.11 and compiler is MinGW(default)
I've extracted the library to c:\SFML-2.0
I've set the compiler search directories for compiler to C:\SFML-2.0\include
and Linker: C:\SFML-2.0\lib
And in the project that I've started I've added in the linker settings-> link libraries:
Debug:
sfml-graphics-d
sfml-window-d
sfml-system-d
Release:
sfml-graphics
sfml-window
sfml-system
I've also copied the dll files from C:\sfml-2.0\bin to the location of the project.
I've tried using the static linking without success.
watched some sfml tutorials and followed them, googled but nothing seems to work for me.
Also reinstalled code::blocks.
Ideas?

You need to use the correct SFML package. Errors with gxx_personality_v0 usually indicate a runtime library mismatch. If you're really using Code::Blocks 12.11 with the compiler they ship with, then you'll have the TDM 4.7.1 compiler, which uses the SJLJ exception model. Thus the matching compiler from the SFML download page would be GCC 4.7 TDM (SJLJ) - 32 bits.
Keep in mind that there's a newer Code::Blocks version (13.12), which uses a newer version of TDM, but for which SFML doesn't provide binaries/pre-compiled packages, thus you'd have to build SFML yourself.
While the TDM compiler is easy to install, I wouldn't recommend it, since it breaks the standard way of using GCC-like compilers. Instead you might want to look at Stephan T. Lavavej's build over at nuwen.net or go with MinGW Builds - for each you'll have to recompile SFML.

If you still get the error, I fixed mine by:
In the Compiler settings dialog:
In the left-hand menu, verify Global compiler settings is selected,
Select the Toolchain executables tab,
Select the Additional Paths tab, and
Press the Add button, find the bin folder of SFML (C:\CodeBlocks\sfml\bin), and add it without keeping relative paths.

Related

How do I setup a Codeblocks project on Windows 10 to compile and link a static SFML project?

My advance appologies for being hopeless at Windows development. I am by no means a Windows developer and my understanding of how to write, compile and link C++ code on a Windows system is limited to say the least.
I am having difficulty trying to compile and link a SFML project on a Windows 10 system with the CodeBlocks IDE.
I am trying to link this project with static linking, not dynamic linking. Again I have virtually no idea how the two different methods work in detail, I just know that if I ship a static linked binary to another Windows 10 user it is much more likely to "just work" on their system.
List of things I did:
Downloaded the latest version of CodeBlocks with MINGW integration.
Installed, default options
Downloaded the latest version of SFML (32bit MINGW version)
Extracted the zip file (SFML) to my home directory
Created a new codeblocks project (console application) and followed the instructions to set the compiler and linker options
https://www.sfml-dev.org/tutorials/2.5/start-cb.php
It works fine for dynamic linking, but requires me to copy the .dll files to the same dir as the produced executable file (produced from compilation of my C++ code).
I tried to change to static linking, changing the names of the linker libs with the -s or -s-d suffix, and adding the define SMFL_STATIC option to global (release and debug) options. I also added the opengl32, freetype, winmm and gdi32 link libs, before their respective sfml link libs.
When trying to compile I get the following linker errors
cannot find -lfreetype
cannot find -lsfml-graphics-s-d
cannot find -lsfml-window-s-d
cannot find -lsfml-system-s-d
in Release mode, similar errors are produced.
What am I doing wrong?
My hunch would be that you either have the wrong compiler (see below) or you haven't defined the library directory as mentioned in the linked tutorial.
There are four common things to consider when using SFML (and essentially any other C++ library) on Windows.
Compiler versions have to fully match
Make sure to not mix x86 and x64
Settings need to be specified for the correct configuration
When linking libraries statically, you also need to link the dependencies
Compiler versions have to fully match
Since C++ doesn't have a standardized ABI, the generated libraries will never be reusable between compilers. Yes, sometimes "it works", but it can break at any point and there's no guarantee.
We strongly recommend to either use the compilers linked on the SFML Download page or build SFML from source with your current compiler.
If you got the latest stable Code::Blocks version with MinGW as stated, you should also be able to get a snapshot build of SFML, which should be using the same compiler.
Note: One exception to this rule is Visual Studio, where VS 2017 binaries are compatible with VS 2019 (and maybe VS 2022?).
Make sure to not mix x86 and x64
When you download a 32-bits (x86) version of SFML, you also need a 32-bits version of your compiler. When you download a 64-bits (x64) version of SFML, you also need a 64-bits version of your compiler.
Make sure you double check your compiler configuration that you've selected the correct bit-ness.
Note: For Visual Studio you need to select the correct compiler architecture in the IDE, usually positioned right next to the run button.
Settings need to be specified for the correct configuration
Project configurations are usually spread across the matrix built from the types:
Debug / Release / All
x86 / x64 (for VS)
Make sure when you add the settings for library paths and include paths that it's not just set for debug or release and ends up missing in either or the other configuration.
Also make sure you're not setting up debug libraries (with the -d suffix) in release mode or release libraries (without any suffix) in debug mode.
When linking libraries statically, you also need to link the dependencies
The SFML static libraries don't contain any symbols of any of its dependencies, that means, in your final application you have to link static SFML and all its dependencies.
As a short summary you can think of static libraries like an archive of object files. These object files will directly be linking into your application, like you link your own source file object files. As such, the SFML static libraries only contain object files of SFML itself and not of other libraries as well.
Troubleshooting
If nothing seems to help, then you should enable verbose compiler & linker output, that we you see exactly which commands are invoked and one can quickly spot the missing statements.

Setting SFML up with NetBeans in Windows

Hi I am having problems with trying to get sfml going with netbeans. Here is a short video of what I have done. video
After listening to HEKTO I now downloaded the MSYS. I removed the static libraries and get this error now:
The application failed with exit code -1073741515 (0xc0000135).
This could indicate that no required .dll was found in the PATH.
Please try to start the following command from the command shell (cmd.exe).
This may give some additional information.
C:\Users\david\Documents\NetBeansProjects\tester\dist\Debug\MinGW_1-Windows\tester.exe
RUN FAILED (exit value -1,073,741,515, total time: 58ms)
After adding system path.. heres new img:
system path img
The SFML developers recommend the exact match between your MinGW version and your SFML version - please see this page, especially these three lines:
The compiler versions have to match 100%!
Here are links to the specific MinGW compiler versions used to build the provided packages:
TDM 5.1.0 (32-bit), MinGW Builds 7.3.0 (32-bit), MinGW Builds 7.3.0 (64-bit)
Your MinGW compiler is 8.2.0 - it doesn't match. So you'll need to download the MinGW using links from this page and install it manually.
Also you try to link with static libraries (with suffix _s). In this case you have to add other libraries to the linker setup - please see here. If to use dynamic libraries then you won't need any additional libraries, however the SFML directory with its DLLs will need to be added to the system path.
UPDATE. Your question has been rewritten many times, so my answer has become irrelevant - this is not good, the question can be updated to improve it, but please not to rewrite it completely following additional information given to you in comments. References to videos and pictures aren't welcomed here also. Your question must be self-contained and potentially helpful for others, looking for help in similar situations.
That said I'll add two tips for future generations:
Don't use relative paths for include and lib directories in the NetBeans compiler and linker setup - use only absolute paths.
MinGW distributions, referenced on the SFML downloading page, don't contain the MSYS (small collection of Unix tools, which includes make.exe). You'll need to download and install the MSYS separately, for example using the MinGW installer with msys-base package only.

lapack complains about libgcc_s_sjlj-1.dll

I am trying to write a program that uses armadillo in Visual Studio. I downloaded Prebuilt libraries for lapack and blas from http://icl.cs.utk.edu/lapack-for-windows/lapack/. I also downloaded MinGW and added C:/MinGW/bin to my System PATH. C:/MinGW/bin has libgfortran-3.dll and libgcc_s_dw2-1.dll which are what the lapack documentation states is needed. However, when I attempt to run my program I get a runtime error stating that the program can't run because libgcc_s_sjlj-1.dll is missing. This dll does not come with MinGW and I tried downloading multiple versions. How can I get rid of this error?
The MinGW-w64 project have something called "personal builds". One of them is "sjlj". The library is built using a gcc compiler from this personal build.
Assuming that it was used the current latest version (6.3.0) and win32 threads the you can find the toolchain binaries here. If not, you can check some other versions.
You can either extract the dll you need or extract it and add it to your system path.

SFML linker error with XCode and C++ 11

I'm trying to get SFML set up on OSX, and I'm running into problems linking the library. I've downloaded and installed the dylibs and have linked them with my project in Xcode, but when I try to compile, I get this error:
dyld: Library not loaded: #rpath/libsfml-graphics.2.3.dylib
Referenced from:/Users/Adam/Documents/Programming/CPP/SFML/Build/Products/Debug/SFML
Reason: image not found
I've tried googling around, but I haven't really found an answer. I saw someone say to change the version of C++ in the project settings, but the version I've downloaded and installed is supposed to be compatible with C++ 11.
Could it be I'm not using clang? I'm not very well versed in the intricacies of different compilers. My project settings under the heading of "Apple LLVM 6.1 - Language - C++" are as follows:
C++ Language Dialect: GNU++11 [-std=gnu++11]
C++ Standard Library: libc++ (LLVM C++ standard library with C++11 support)
Enable C++ Exceptions: Yes
Enable C++ Runtime Types: Yes
Are you following the tutorial at?:
http://www.sfml-dev.org/tutorials/2.2/start-osx.php
Also, make sure your libraries are loaded in the "Build Phases" for your target, also make sure that your C++ 11 configurations are also changed on your target and not just in your project (double check). While at that also check the "Library search paths" value on your target "Build Settings"
This looks more like a missing library than a C++11 problem.
For even more details check the "Report navigator" for the latest build attempt, make sure to activate the "All messages" option, you can expand the errors and get valuable information, like where is it looking for the libraries.
Figured it out.
I needed to copy the contents of the extlibs folder in the SFML download into my /Library/Frameworks folder.

Why am I getting a procedure entry point error for this simple C++ code?

I'm writing an SFML game and when I try to run the code this is the error I get:
The procedure entry point _gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll
I've linked to all the libraries correctly and the include files are correct. I've even tried what other answers suggested by putting the libstdc++-6.dll inside the directory of my exectable but still nothing.
Another answer said to put the MinGW/bin directory before any other directory in the PATH environment variable, which I did as well and it still didn't work.
Note: I get this error only when I try to use SFML code. It runs successfully when I comment it out.
OK, the note you added tells me that the SFML stuff was compiled with another compiler version/configuration, newer one if memory serves right.
You need to make sure that SFML and your code are compiled by the same compiler (versions/configuration) or at least compatible compiler (versions/configuration).
I see that the latest binary packages of SFML use GCC 4.7, and the latest Code::Blocks (mingw) comes with the TDM GCC 4.7 build, so it might be enough to upgrade Code::Blocks and make sure you use the SFML GCC 4.7 TDM (SJLJ) package (and use the gcc that comes with Code::Blocks, of course).
Otherwise, you should probably install the TDM-GCC 4.7 compiler build manually, or if nothing works, compile SFML yourself.
This is just a PATH ordering issue.
Most likely you'll have multiple libstdc++-6.dll files loaded in your path. You can check by running where libstdc++-6.dll in your command prompt.
What you do is to make sure your MinGW bin folder is loaded before everything else. Try moving it to the first one in your global PATH.