繁体   English   中英

SDL2 未定义对“SDL_CreateWindowAndRenderer”的引用

[英]SDL2 undefined reference to `SDL_CreateWindowAndRenderer'

这是我的 class 代码:

#include <SDL2/SDL.h>

#include "graphics.h"

/* Graphics class
 * Holds all information dealing with graphics for the game
 */

Graphics::Graphics() {
    SDL_CreateWindowAndRenderer(640, 480, 0, &this->_window, &this->_renderer);
    SDL_SetWindowTitle(this->_window, "Cavestory");

}


Graphics::~Graphics() {
    SDL_DestroyWindow(this->_window);
}

这是错误:

g++ "-LC:\\MinGW\\lib" -o cavestory-developement.exe "source\\src\\cavestory-developement.o" "source\\src\\graphics.o" -lmingw32 -lSDL2main -lSDL2 
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: source\src\graphics.o: in function `ZN8GraphicsC2Ev':
C:\Users\John Park\eclipse-workspace\cavestory-developement\Debug/../source/src/graphics.cpp:10: undefined reference to `SDL_CreateWindowAndRenderer'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\John Park\eclipse-workspace\cavestory-developement\Debug/../source/src/graphics.cpp:11: undefined reference to `SDL_SetWindowTitle'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: source\src\graphics.o: in function `ZN8GraphicsD2Ev':
C:\Users\John Park\eclipse-workspace\cavestory-developement\Debug/../source/src/graphics.cpp:17: undefined reference to `SDL_DestroyWindow'
collect2.exe: error: ld returned 1 exit status

19:06:06 Build Failed. 5 errors, 0 warnings. (took 223ms)
______________________________________________________________________________________________________

不确定为什么当我用鼠标 hover 在 SDL_SetWindowTitle 上被识别时(显示函数的参数和详细信息),但 SDL_CreateWindowAndRenderer 和 SDL_DestroyWindow 不是。

它在 Fedora 32 x86_64 上编译得很好,既可以作为本机程序,也可以作为 Windows 程序:

echo 'struct Graphics { Graphics(); ~Graphics(); SDL_Window *_window; SDL_Renderer *_renderer; } g;int main(int argc,char **argv){return 0;}' >graphics.h;g++ -o sdl2 sdl2.C -Wall -g $(pkg-config --cflags --libs sdl2);sudo dnf install mingw64-SDL2 mingw64-gcc-c++;x86_64-w64-mingw32-c++ -o sdl2.exe sdl2.C -Wall -g $(/usr/x86_64-w64-mingw32/sys-root/mingw/bin/sdl2-config --cflags --libs);(d=$PWD;cd /usr/x86_64-w64-mingw32/sys-root/mingw/bin;wine64 $d/sdl2.exe)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM