提示のコマンドラインのコードですがなぜ以下のディレクトリ構造で以下のコマンドで未定義参照というエラーが出るのでしょうか?原因がわかりません。
ダウンロードしてきたファイル
Github: https://github.com/libsdl-org/SDL/releases/tag/release-2.24.1
ダウンロードファイル: SDL2-devel-2.24.1-mingw.zip
環境
OS windows10
エディタ Vscode
コンパイラ: g++
フォルダ構成
sdlディレクトリ内にlib(.libファイル)ディレクトリ、SDL2(インクルード)ディレクトリがあります。Main.cppソースファイルもsdlディレクトリ内にあります。
コマンド
C:\Users\yw325\Desktop\sdl>g++ -I. Main.cpp -Llib/ -lSDL2 -lSDL2main c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\yw325\AppData\Local\Temp\ccJaJxMJ.o:Main.cpp:(.text+0xe): undefined reference to `SDL_Init' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\yw325\AppData\Local\Temp\ccJaJxMJ.o:Main.cpp:(.text+0x13): undefined reference to `SDL_Quit' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status C:\Users\yw325\Desktop\sdl>
ソースコード
cpp
1#include <iostream> 2#include "SDL2/SDL.h" 3//#include <SDL2/SDL.h> 4 5 6int main() 7{ 8 SDL_Init(SDL_INIT_EVERYTHING); 9 10 SDL_Quit(); 11 12 return 0; 13} 14
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
退会済みユーザー
2022/10/18 07:34
2022/10/18 07:51
2022/10/18 08:11
退会済みユーザー
2022/10/18 09:07
2022/10/18 09:36
退会済みユーザー
2022/10/18 10:08