1

Edit

My question is not about the undefined reference errors but about the Toolchain "MinGW GCC" is not detected. error in Eclipse, and whether those two are linked.


I am trying to set up an SDL environment. I have Eclipse C++ 2018-2019 (v4.8) and the 64bit MinGW compiler.

I have downloaded the files from the website (header files and libraries) and put them respectively in the following folders in my MinGW installation directory:

C:\Program Files (x86)\mingw-w64\mingw32\include\SDL2
C:\Program Files (x86)\mingw-w64\mingw32\lib

Then I create a New C++ Project (Executable > Hello World C++ Project), and deselect "Show project types and toolchains only if they are supported on the platform" in order to be able to select the MinGW Toolchain as seen in this image.

Then I use Properties > C/C++ Build > Settings and added the libraries

mingw32
SDL2main
SDL2

and also added the Includes path

C:\Program Files (x86)\mingw-w64\mingw32\include\SDL2

Then at the top of the window I noticed a warning that said

Toolchain "MinGW GCC" is not detected.

After some Googling, i found that this is probably because the PATH variable is not correctly set. I searched for the variable and i found out it consisted of a long list of paths, including

C:\Program Files (x86)\mingw-w64\mingw32\bin;

which was what every solution I found said i should add, yet the warning was still there.

I then built the project and copied SDL2.dll to the same folder as the executable.

When i tried to build the following code

#include <iostream>
#include <SDL.h>
using namespace std;

int main(int argc, char *argv[]) {

    if(SDL_Init(SDL_INIT_VIDEO) < 0) {
        cout << "SDL init failed." << endl;
        return 1;
    }

    cout << "SDL Init succeeded." << endl;

    SDL_Quit();

    return 0;

}

to see if I had done everything properly, I got the following error in CDT Build Console:

Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
g++ -o SDLTest.exe "src\\SDLTest.o" -lmingw32 -lSDL2main -lSDL2 
src\SDLTest.o: In function `Z8SDL_mainv':
C:\Users\ilias\Desktop\eclipse-workspace\SDLTest\Debug/../src/SDLTest.cpp:15: undefined reference to `SDL_Init'
C:\Users\ilias\Desktop\eclipse-workspace\SDLTest\Debug/../src/SDLTest.cpp:22: undefined reference to `SDL_Quit'
C:/Program Files (x86)/mingw-w64/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x39): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status

I am not really sure if I get this error because of this "Toolchain "MinGW GCC" is not detected." error or because i messed up something else.
What is it and how can i fix it?

liakoyras
  • 1,101
  • 12
  • 27
  • @πάντα ῥεῖ My question had two parts, but the question you linked to seems to answer only one of them. It contains nothing about this error at Eclipse and if this could be the cause of the undefined reference error – liakoyras Nov 01 '18 at 14:40
  • 1
    "i686-w64-mingw32" doesn't sound like "64bit compiler". It is quite likely you have wrong libraries, headers, or both. `Z8SDL_mainv` mangled name is especially weird - SDL_main.h declares it as (if in c++ mode) `extern "C" int SDL_main(int argc, char *argv[])`, so either your installation is broken or you're doing something unusual that you forgot to mention. Can we see compilation command and its output in addition to linking phase? – keltar Nov 01 '18 at 16:33
  • @keltar You were right, the installation was broken. I reinstalled Eclipse and it worked just fine. – liakoyras Nov 01 '18 at 17:20

0 Answers0