0

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.

3
  • 1
    The error means the dll that windows loaded didn't match the one you compiled against. You probably have some other/incompatible version of these dlls in a folder of your PATH environment 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. Commented Apr 27 at 23:32
  • It's even worse than I thought: sometimes, compiling the file under a different name (test.exe, a.exe...) would make the execution error disappear. So, I will switch to my desktop with version 22.04.5 and ignore this issue to finish this assignment and go back to coding personal projects. :) Commented Apr 28 at 0:45
  • 1
    on linux, LD_LIBRARY_PATH is already pointing at libstdc++ , whereas on windows you need to add to your PATH wherever libstdc++ is installed by mingw, or just copy it to the directory that includes your executable. Commented Apr 28 at 5:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.