cmake工作正常(我猜!我刚开始使用cmake)没有错误,所以mingw32-make。我想编译和链接正确完成。但是当我打开程序(graphics.exe)时它会立即停止工作。 (顺便说一句,我没有错过SDL2.dll)什么错了?
编辑: 当使用32位库和32位dll以及" -m32"时,它工作得很好。但是当使用64位内容时它会崩溃。
CMakeList.txt:
cmake_minimum_required(VERSION 3.8)
project(graphics)
set(CMAKE_C_STANDARD 11)
set(SOURCE_FILES main.c)
set(DEPS ${CMAKE_CURRENT_SOURCE_DIR}/Deps)
include_directories("${DEPS}/include")
add_executable(graphics ${SOURCE_FILES})
#find sdl2 libraries
find_library(SDL2MAIN_LIB SDL2main ${DEPS}/lib)
find_library(SDL2_LIB SDL2 ${DEPS}/lib)
message("SDL2main found at: ${SDL2MAIN_LIB}")
message("SDL2 found at: ${SDL2_LIB}")
target_link_libraries(graphics ${SDL2MAIN_LIB})
target_link_libraries(graphics ${SDL2_LIB})
main.c中:
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc,char** argv) {
if(SDL_Init(SDL_INIT_EVERYTHING) == 0)
printf("SDL2 up and running\n");
else
printf("Could not initialize SDL2");
SDL_Quit();
return 0;
}