SFML community forums

General => General discussions => Topic started by: karanchaudhary009 on December 22, 2013, 10:32:07 am

Title: linking .a when dynamically linking sfml
Post by: karanchaudhary009 on December 22, 2013, 10:32:07 am
I wanted to know why do we need to link to *.a library in code::blocks (with mingw) when i copied the .dlls and want to link sfml dynamically.
Title: Re: linking .a when dynamically linking sfml
Post by: Jebbs on December 22, 2013, 12:04:43 pm
Because Windows is silly and requires what's called an import library to link with the dll's. Import libraries contain a list of all symbols found in a particular dll since you don't link to dll's directly on Windows like you would link to shared libraries on Linux. They have the same extension as static libraries(.a for gcc and .lib for VC++) for what ever reason.

Edit:
SFML marks all static libraries with the -s suffix, which helps to prevent one from confusing an import library with a static library on Windows.
Title: Re: linking .a when dynamically linking sfml
Post by: wintertime on December 22, 2013, 12:12:45 pm
You may be able to get away without the implib (though it could be some recent change would prevent it as they dont update that website often):
http://www.mingw.org/wiki/sampleDLL (http://www.mingw.org/wiki/sampleDLL)
Quote
Note:

The import library created by the "--out-implib" linker option is required iff (==if and only if) the DLL shall be interfaced from some C/C++ compiler other than the MinGW toolchain. The MinGW toolchain is perfectly happy to directly link against the created DLL. More details can be found in the ld.exe info files that are part of the binutils package (which is a part of the toolchain).