Primeiro, você irá precisar baixar e instalar o compilador MingW, segue o site http://www.mingw.org/
Se estiver tudo certo, basta você chamar o cmd.exe e executar gcc:
C:\Users\cl>gcc
gcc: fatal error: no input files
compilation terminated.
Segundo, você tem que baixar o cmake, baixa e instale, segue p site: https://github.com/Kitware/CMake/releases/download/v3.17.2/cmake-3.17.2-win64-x64.msi
Se o cmake, estiver ok, basta chamar ele no cmd.exe:
C:\Users\cl>cmake
Usage
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
cmake [options] -S <path-to-source> -B <path-to-build>
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Run 'cmake --help' for more information.
Agora, iremos baixar a lib SDL, no link: https://libsdl.org/release/SDL2-2.0.12.zip
Basta extrair em algum diretório, exemplo c:\SDL2\SDL2-devel-2.0.12
Dentro do diretorio do SDL2, procure um arquivo chamado CMakeLists.txt
Edite ele no notepad ou qualquer editor de texto.
Você verá as 3 primeiras linhas, conforme abaixo. Apenas comente, colocando um # no inicio desta 3 linhas e salve o arquivo!
#if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
#endif()
cmake_minimum_required(VERSION 2.8.11)
project(SDL2 C CXX)
....
Agora, via cmd.exe, acesse o diretório da SDL2 e execute o comando:
cmake .
E aguarde todos os testes do mesmo finalizar.... Veja abaixo:
...
-- EXTRA_CFLAGS: -mfpmath=387 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden
-Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-a
liasing -Wall
-- EXTRA_LDFLAGS: -Wl,--no-undefined;-mwindows
-- EXTRA_LIBS: m;user32;gdi32;winmm;imm32;ole32;oleaut32;version;uuid;advapi
32;setupapi;shell32;mingw32
--
-- Build Shared Library: ON
-- Build Static Library: ON
-- Build Static Library with Position Independent Code: OFF
--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/SDL2/SDL2-2.0.12
Tereceiro passo, basta agora você chamar o make do compilador Mingw, assim:
mingw32-make
C:\SDL2\SDL2-2.0.12>mingw32-make
Scanning dependencies of target SDL2-static
[ 1%] Building C object CMakeFiles/SDL2-static.dir/src/SDL.c.obj
[ 1%] Building C object CMakeFiles/SDL2-static.dir/src/SDL_assert.c.obj
[ 1%] Building C object CMakeFiles/SDL2-static.dir/src/SDL_dataqueue.c.obj
[ 2%] Building C object CMakeFiles/SDL2-static.dir/src/SDL_error.c.obj
...
Espere terminar!
...
tick.c.obj
[ 99%] Building C object CMakeFiles/SDL2.dir/src/haptic/dummy/SDL_syshaptic.c.obj
[100%] Building C object CMakeFiles/SDL2.dir/src/sensor/dummy/SDL_dummysensor.c.obj
[100%] Building RC object CMakeFiles/SDL2.dir/src/main/windows/version.rc.obj
[100%] Linking C shared library SDL2.dll
[100%] Built target SDL2
E Pronto!
Assim, irá gerar a sua SDL2.dll. E se deu tudo certo, ela estará linkada estaticamente, com um tamanho aprox de 6MB.
Está lib será útil para os próximos projetos ;)
Ate lá!
Nenhum comentário:
Postar um comentário