SFML community forums

Help => General => Topic started by: Strikerklm96 on October 20, 2014, 09:28:23 pm

Title: Conflicting Libraries
Post by: Strikerklm96 on October 20, 2014, 09:28:23 pm
I am working on a game that can be compiled on my machine, and run on most windows machine as long as you provide the .dll's with it.
I have been trying to get it to compile on my friends computer

The libraries we are using are:
Box2D
SFML
TGUI
JSONCPP

(These are the same steps that I did on my computer):
A friend wanted to join me, so we downloaded the source for each lib on his machine.
Built each set of libraries using CMake, release-shared, and debug-shared.
Tried to compile the project.
It compiles, but when it tries to run it crashes with one of two problems

1. If we don't include libgcc_s_sjlj-1.dll with the exe on his computer, the program crashes in the sfml graphics library (as indicated by the debugger).

2. If we try the libgcc_s_dw2-1.dll with the exe (instead of sjlj), the same crash happens as #1

3. If we include libgcc_s_sjlj-1.dll we get this:
The procedure entry point __gxx_personality_v0 could not be located in
the dynamic link library
(directory to the bin folder)\libBox2D.dll
I have seen this exact error before, but with libstdc++6, and that was due to not having the libstdc++6.dll built with the right exception model (DW2 vs SJLJ). Does anyone have any insight into why this would happen?

Other Details:
In C:\Program Files (x86)\CodeBlocks\MinGW\bin MY computer has libgcc_s_dw2-2.dll AND libgcc_s_sjlj-1.dll, where as HIS computer only has libgcc_s_dw2-1.dll

On my computer, the program requires the extra libraries (ones not created by the 4 I listed):
libgcc_s_sjlj-1.dll
libstdc++-6.dll
libsndfile-1.dll
openal32.dll
(Do I need to rebuild these also?)

We compiled and ran test code for Box2D and SFML separately. Both worked. So this isn't directly Box2D's or SFML's fault. Is there a way I can see which libraries are DW2 vs SJLJ? I'm confused as to how they could be different considering they were all built on his computer, but I was hoping to get some insight into how to fix this.
Title: Re: Conflicting Libraries
Post by: eXpl0it3r on October 20, 2014, 09:36:29 pm
You're using different MinGW versions. Make sure all of you use the same version and have compiled the libraries with the same compiler.
Title: Re: Conflicting Libraries
Post by: Strikerklm96 on October 20, 2014, 09:52:02 pm
But wait, he recompiled every library on his computer, each library works individually, he doesn't use any dll's he got from me. Shouldn't he be able to compile my c++ code and have it run?

How can I check what MinGW version I have?
Title: Re: Conflicting Libraries
Post by: eXpl0it3r on October 20, 2014, 10:04:24 pm
Actually yes if you fully build everything on each machine it should work.

3. If we include libgcc_s_sjlj-1.dll we get this:
The procedure entry point __gxx_personality_v0 could not be located in
the dynamic link library
(directory to the bin folder)\libBox2D.dll
This error means that you've mismatching DLLs, are you certain you've built this application with the compiler which shipped the used libgcc_s_sjlj-1.dll?


Other Details:
In C:\Program Files (x86)\CodeBlocks\MinGW\bin MY computer has libgcc_s_dw2-2.dll AND libgcc_s_sjlj-1.dll
I've only seen this (stupidly) done by the TDM builds, which I can't recommend at all.

Personally I'd suggest you get both the same compiler (for example this one (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.1/threads-posix/dwarf/i686-4.9.1-release-posix-dwarf-rt_v3-rev1.7z/download)) and recompile everything. You then could essentially even just build it once and share the binaries if wanted.
Title: Re: Conflicting Libraries
Post by: Strikerklm96 on October 20, 2014, 10:34:12 pm
Actually yes if you fully build everything on each machine it should work.

This error means that you've mismatching DLLs, are you certain you've built this application with the compiler which shipped the used libgcc_s_sjlj-1.dll?
In what way are they mismatched? Compiler version, or EH model? And is there a way to see those attributes of a library? (If it was built with DW2 or SJLJ, and what Compiler built it?)


I am fine with getting this new compiler, but I have never set up a new compiler. Do I just replace the MinGW folder in CodeBlocks? Do I put it alongside? Do I rename it? I don't want to break my computer ideally :)
Title: Re: Conflicting Libraries
Post by: eXpl0it3r on October 20, 2014, 10:41:23 pm
In what way are they mismatched? Compiler version, or EH model?
Doesn't really matter in what way. Some library or your application has been linked to a different libgcc version, which is now conflicting with the DLL you provide. Whether the other one had a different EH model or not doesn't matter, when the libraries aren't the same it will mismatch hopefully sooner than later. :D

I am fine with getting this new compiler, but I have never set up a new compiler, do I just replace the MinGW folder in CodeBlocks? I don't want to break my computer ideally :)
You could remove the MinGW directory and simply place your new one there. You could also place it somewhere else. In any case you need to change the compiler settings in Code::Blocks.
For example I've setup my compiler(s) in C:\Dev and thus my Settings->Compiler... looks like this:

(https://i.imgur.com/udGKEJB.png)
Title: Re: Conflicting Libraries
Post by: Strikerklm96 on October 20, 2014, 11:23:13 pm
Ok, I have Codeblocks able to compile programs, but now cmake has problems, I point it to the mingw32-make.exe, but it then gives this error:

cc1.exe - System Error
The program can't start because libwinpthread-1.dll is missing from your computer. Try reinstalling the program to fix this problem.

I am on Windows 7, Cmake 2.8.11.2
I see that file in my mingw32/bin folder, do I need to add that to the system Path? Or is it the wrong version?
Title: Re: Conflicting Libraries
Post by: eXpl0it3r on October 20, 2014, 11:29:37 pm
To use CMake effectively your compiler should be found in PATH. If you don't want to add the MinGW directory in the global PATH, you can open a new command line (cmd) and add it to that command line "session" with:
set PATH=C:\Path\To\Your\MinGW\bin;%PATH%

Note that it has to point to the bin directory of your MinGW install. Then you can run CMake, if it's in PATH you can just enter cmake-gui otherwise you'll have to specify the full path.

Keep in mind that libwinpthread-1.dll is located in your MinGW\bin directory and if you ever use std::thread you'll also need to ship it (maybe even in other cases).

Btw. CMake's newest version is 3.0.x. ;)
Title: Re: Conflicting Libraries
Post by: Strikerklm96 on October 20, 2014, 11:37:23 pm
Cool, and thanks. Everything seems to work for both of us, so thank you very much!
If you want see my game project (note it has not been updated with this stuff yet):
https://github.com/Strikerklm96/Alpha

It's not quite presentable yet, which is why I haven't posted it here before.
Title: Re: Conflicting Libraries
Post by: Strikerklm96 on October 20, 2014, 11:42:28 pm
It turns out this problem was happening because (for some reason) his C::B compiler was referencing ANOTHER MinGW folder that was different (not the CB one). We only found this when we went to setup the new compiler we downloaded. It seems like an obvious thing to check now, but that should have never happened, 20/20 hindsight.
Title: Re: Conflicting Libraries
Post by: eXpl0it3r on October 21, 2014, 12:19:53 am
I'm glad it worked out!
Yeah a misconfigured setting can happen fast often even more annoying is a misconfigured PATH or a misplaced DLL in a directory which is in PATH. :D
Title: Re: Conflicting Libraries
Post by: Strikerklm96 on October 21, 2014, 12:38:46 am
So it turns out that it wasn't actually working all the way, now me AND my friend consistently have the program crash in one spot, and after testing each Library independently, it turns out it is TGUI, so I have started a thread there
https://forum.tgui.eu/index.php?topic=250.new#new