0

I'm following Lazy Foo's tutorials, using CLion to develop SDL2 programs. When I build executable files in CLion, it worked well and ran correctly. But when I tried to run the exe file in the cmd, it showed me an 0xc000007b error. The same error occurred when i double-clicked it in the file explorer.

Im using windows10 21H2 64bit, CLion 2022.3.1 64bit with mingw 64bit, The SDL release is 2.26.2, I copied the 64bit version to the mingw directory.

I've tried several methods to solve the problem, including but not limited to revise my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.24)
project(SDL_project)
set(CMAKE_CXX_STANDARD 17)

include_directories(SDL)

add_executable(SDL_project main.cpp)

target_link_libraries(SDL_project mingw32 SDL2 SDL2main)

#link_directories(${SDL2_DIR})
#set(SDL2_DIR E:/programming/SDL_project/SDL2-2.26.2/x86_64-w64-mingw32)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
#set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

The lines i commented out were those i tried.

I've also read the questions about this issue on stackoverflow. Most of the answers suggest checking the lib or dll to ensure using the correct bit version (64bit or 32bit). I did checked, only to find that my SDL2/mingw/clion/OS are all 64bit.

I've tried using the Dependency Walker. After analysis, it reported that my LIBGCC_S_DW2-1.DLL LIBSTDC++-6.DLL LIBWINPTHREAD-1.DLL SDL2.DLL are 32bit. I'm sure that i copied the 64bit version SDL2.dll to the mingw directory, but other dlls - how can i change them to 64bit version?

Is my installation method of SDL2 incorrect? Or is my mingw settings incorrect? Another confusing detail is that it worked pretty well in the CLion IDE, but failed in the cmd/file explorer. By the way, im just using SDL2.h, not using SDL_Image or other expand libs.

genpfault
  • 51,148
  • 11
  • 85
  • 139
CrazyAuF3
  • 1
  • 1
  • Copy the DLLs your program uses (ignoring anything other than the the ones shipped with the compiler and `SDL2.dll`) next to it. You don't need to modify compiler flags. – HolyBlackCat Jan 05 '23 at 04:44

0 Answers0