Ich versuche SDL und C++ zu verwenden, um ein Spiel zu erstellen.g ++ verbindet keine Bibliotheken von Drittanbietern
Bisher konnte ich damit nichts anfangen. Ich befolgte alle Anweisungen für Mac (ich habe einen Mac v. 10.12.2) und g ++ unter http://www.lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php.
Im Moment habe ich Linkfehler, die sagen, dass sie die Bibliothek nicht finden können, die durch die Option -l (Kleinbuchstaben L) bezeichnet wird. Hier ist mein Makefile:
CC = g++
CFLAGS = -g -Wall -std=c++11
SDL_PATH = /Users/myname/Documents/Code-Libraries/SDL2-2.0.5
SDL_INCLUDE = -I$(SDL_PATH)/include
SDL_LIB = -L$(SDL_PATH) -l/usr/local/lib/libSDL2.a
default: SDL01
SDL01: 01_hello_SDL.cpp
$(CC) $(CFLAGS) 01_hello_SDL.cpp $(SDL_LIB) $(SDL_INCLUDE) -o SDL01
clean:
rm -f SDL01 *.o
Ich habe -lsdl2 versucht. Ich habe -lSDL versucht. Ich habe versucht, -l/usr/local/lib/libSDL2.a. Ich habe nur die Option -L (Option no -l) mit verschiedenen Schreibweisen /Users/myname/Documents/Code-Libraries/SDL2-2.0.5 und dieser (/ Users/myname/Documents/Code-Libraries /SDL2-2.0.5) gab mir ...
Undefined symbols for architecture x86_64:
"_SDL_CreateWindow", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_Delay", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_DestroyWindow", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_FillRect", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_GetError", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_GetWindowSurface", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_Init", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_MapRGB", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_Quit", referenced from:
_main in 01_hello_SDL-f65b5c.o
"_SDL_UpdateWindowSurface", referenced from:
_main in 01_hello_SDL-f65b5c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SDL01] Error 1
... während die andere mir gesagt, dass sie nicht die Header für das Projekt finden können. Ich bin wirklich verloren und würde wirklich etwas Hilfe lieben. Vielen Dank.
EDIT1:
ich nm /usr/local/lib/libSDL2.a | grep _SDL_CreateWindow
tat und bekam
0000000000001cb0 T _SDL_CreateWindow
0000000000000f80 T _SDL_CreateWindowAndRenderer
0000000000007620 t _SDL_CreateWindowAndRenderer_DEFAULT
U _SDL_CreateWindowAndRenderer_REAL
0000000000001cc0 T _SDL_CreateWindowFrom
0000000000009e80 t _SDL_CreateWindowFrom_DEFAULT
U _SDL_CreateWindowFrom_REAL
0000000000009e30 t _SDL_CreateWindow_DEFAULT
U _SDL_CreateWindow_REAL
0000000000000060 T _SDL_CreateWindowAndRenderer_REAL
U _SDL_CreateWindow_REAL
U _SDL_CreateWindow_REAL
00000000000030a0 T _SDL_CreateWindowFrom_REAL
0000000000000760 t _SDL_CreateWindowTexture
0000000000002010 T _SDL_CreateWindow_REAL
U _SDL_CreateWindow_REAL
EDIT2:
Dies sind die Dateien/Verzeichnisse in den ~/Documents/Code-Bibliotheken/SDL2- 2.0.5/Verzeichnis:
Android.mk SDL2.spec.in cmake_uninstall.cmake.in
BUGS.txt TODO.txt configure
CMakeLists.txt VisualC/ configure.in
COPYING.txt VisualC-WinRT/ debian/
CREDITS.txt VisualC.html docs/
INSTALL.txt WhatsNew.txt include/
Makefile.in Xcode/ sdl2-config.cmake.in
Makefile.minimal Xcode-iOS/ sdl2-config.in
Makefile.pandora acinclude/ sdl2.m4
Makefile.psp android-project/ sdl2.pc.in
Makefile.wiz autogen.sh src/
README-SDL.txt build/ test/
README.txt build-scripts/
SDL2.spec cmake/
Die Syntax hier sollte '-lSDL2' oder'/usr/local/lib/libSDL2.a' sein, nicht '-l/usr/local/lib/libSDL2.a' – nos
@nos können Sie das erklären? Ich verstehe nicht, wie g ++ /usr/local/lib/libSDL2.a die Bibliothek verstehen würde, die ich verlinken möchte. Liegt es daran, dass es * .a ist? – astrocat1997
@nos auch, es hat nicht funktioniert :-(. Ich habe 'Undefined Symbole für Architektur x86_64:' mit viel Müll. – astrocat1997