I'm developing in C++ on Windows 11 using WSL with an Ubuntu 24.04.2 LTS distribution. For my course projects, I use the SDL2 library. Due to insufficient performance with graphical interfaces under WSL, I installed MinGW-w64 via apt (sudo apt install mingw-w64) to compile my code for Windows. Simple Directmedia Layer
I downloaded the latest version of SDL2 from GitHub, with an option for MinGW. The following test program works when compiled statically (with static libgcc and libstdc++) :
#include <SDL2/SDL.h>
#include <iostream>
int main(int argc, char* argv[]) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
std::cerr << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Window* window = SDL_CreateWindow("Hello SDL2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN);
if (!window) {
std::cerr << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
SDL_Delay(3000); // Display window for 3s
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
However, when compiling dynamically with the following DLLs retrieved via MSYS2 :
libstdc++-6.dll
libwinpthread-1.dll
libgcc_s_seh-1.dll
The program doesn't work, and I receive an error during execution (see attached image): "The procedure entry point _ZSt21ios_base_library_initv could not be located in the dynamic link library path/to/executable.exe" "The procedure entry point _ZSt21ios_base_library_initv could not be located in the dynamic link library path/to/executable.exe".
Interestingly, on my laptop with Ubuntu 22.04.5 LTS, the same setup works perfectly: dynaminc linking with the DLLs works fine.
Here are the versions of x86_64-w64-mingw32-g++ :
Desktop : x86_64-w64-mingw32-g++ (GCC) 13-win32
Laptop : x86_64-w64-mingw32-g++ (GCC) 10-win32 20220113
I suspect the issue is related to the newer mingw-GCC version on my desktop. Has anyone encountered this kind of problem or have any suggestions to resolve it ?
Thank you in advance for your help.
I tried reinstalling everything from scratch, by retrieving the DLLs again and reinstalling MinGW, but none of this worked.
Static linking works on both my PCs, but dynamic linking doesn’t work on my desktop.
PATHenvironment variable on the machine you get this error. My advice is to copy the dlls from your linux cross compilation environment so that you have the exact versions of the dlls you need and put them in the same folder as your application's executable.LD_LIBRARY_PATHis already pointing at libstdc++ , whereas on windows you need to add to yourPATHwherever libstdc++ is installed by mingw, or just copy it to the directory that includes your executable.