0

My goal is to setup SDL2 environment with vscode. I failed when trying to make a executable file in 64-bits.

However, after I changed those SDL2 libraries, header files and dll to 32-bit version, I succeeded and made a 32-bit executable file.

For your references, followings are my workspace directories:

>SDL2
  >src
    >include  (SDL2 header files)
    >lib      (SDL2 lib)
  >main.cpp
  >Makefile

Makefile:

all:
    g++ main.cpp -I src/include -L src/lib -o main -lmingw32 -lSDL2main -lSDL2

Complains:

PS D:\vscode\SDL2> make
g++ main.cpp -I src/include -L src/lib -o main -lmingw32 -lSDL2main -lSDL2
C:\Users\user\AppData\Local\Temp\ccg3PdH7.o:main.cpp:(.text+0xf): undefined reference to `SDL_Init'
C:\Users\user\AppData\Local\Temp\ccg3PdH7.o:main.cpp:(.text+0x43): undefined reference to `SDL_CreateWindow'
C:\Users\user\AppData\Local\Temp\ccg3PdH7.o:main.cpp:(.text+0x51): undefined reference to `SDL_GetError'
C:\Users\user\AppData\Local\Temp\ccg3PdH7.o:main.cpp:(.text+0x96): undefined reference to `SDL_PollEvent'
C:\Users\user\AppData\Local\Temp\ccg3PdH7.o:main.cpp:(.text+0xb7): undefined reference to `SDL_DestroyWindow'
C:\Users\user\AppData\Local\Temp\ccg3PdH7.o:main.cpp:(.text+0xbc): undefined reference to `SDL_Quit'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:2: all] Error 1

I guess the problem is that I probably use a wrong toolchain(32bit mingw). I will also be grateful if someone can help me check my toolchain.

0 Answers0