install a library on mingw in linux vps

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Delaney martin
    Senior Member
    • Jun 2022
    • 157

    install a library on mingw in linux vps

    Hi, I am trying to compile my C++ code.

    but I get #include <SDL2/SDL.h> which I don’t get when compiling with g++.

    How can I install these libraries for mingw on linux VPS?
  • Clay Page
    Senior Member
    • Sep 2022
    • 112

    #2
    Follow these steps:

    1. Install MinGW-w64 on Your Linux VPS


    If you haven't installed MinGW-w64, install it using the package manager:

    sudo apt update

    sudo apt install mingw-w64


    2. Install SDL2 Development Libraries for MinGW:

    Download and Manually Install SDL2 for MinGW
    1. Download the precompiled SDL2 MinGW binaries:

    Extract the downloaded .zip files:

    unzip SDL2-devel-*.zip -d ~/mingw-libs/

    unzip SDL2_image-devel-*.zip -d ~/mingw-libs/

    unzip SDL2_ttf-devel-*.zip -d ~/mingw-libs/


    Copy the necessary files to your MinGW-w64 directory:

    cp -r ~/mingw-libs/SDL2-*/x86_64-w64-mingw32/include/* /usr/x86_64-w64-mingw32/include/

    cp -r ~/mingw-libs/SDL2-*/x86_64-w64-mingw32/lib/* /usr/x86_64-w64-mingw32/lib/


    3. Compile Your Code with MinGW-w64

    Now, compile your program with the correct SDL2 include and library paths:

    x86_64-w64-mingw32-g++ main.cpp -I/usr/x86_64-w64-mingw32/include/SDL2 -L/usr/x86_64-w64-mingw32/lib -lSDL2 -lSDL2_image -lSDL2_ttf -o windows32.exe

    4. Ensure SDL2 DLLs are Included in Your Windows Build


    For your compiled windows32.exe to run on Windows, make sure to copy the SDL2.dll, SDL2_image.dll, and SDL2_ttf.dll from the downloaded SDL2 binaries into the same directory as your .exe file.

    Comment

    Working...
    X