I'm trying to re-learn C++ and I'm working with the Eclipse CDT on Windows with MinGW and I'd like to include an external library without modifying the MinGW installation. Currently, I'm working with SDL2, but this is a more generalized question.
I've successfully compiled and run my test program using the following steps:
- Download the
SDL2-devel-2.0.4.mingw.tar.gz(here) and extract it - Copy files from
SDL2-2.0.4\to myMinGWinstall:- \include\SDL2 to %MinGW%\include\
- \lib\libSDL2.a to %MinGW%\lib\
- \lib\libSDL2.dll.a to %MinGW%\lib\
- \lib\libSDL2.la to %MinGW%\lib\
- \lib\libSDL2main.a to %MinGW%\lib\
- \bin\SDL2.dll to %MinGW%\bin\
- Add the libraries (in order) to the linker via Project->Properties : C/C++ Build->Settings : ("Tool Settings" tab) MinGW C++ Linker->Libraries : "Libraries (-l)" section
- SDL2main
- SDL2
#include <SDL2\SDL.h>in my cpp/h file- Build the program
- Copy
SDL2.dllto the output directory with my .exe - Run
On this particular machine, I'm using the i686-w64-mingw32 build of the SDL2-2.0.4, but I'd like to point the linker to this directly without copying to the MinGW installation in step 2 above. Then I could simply include these files in my repo without expecting a correctly modified MinGW install, or changing the pointer to the x86_64-w64-mingw32 build on a different machine, etc.
On a slightly different note (and probably a separate question), is there a method of automating step 6? I can't seem to find it, and manually copying the dlls on every clean build is rather annoying...