게임을 만들기 위해 SDL 및 C++을 사용하려고합니다.g ++ 타사 라이브러리를 연결하지 않습니다.
지금까지는 아무 것도 할 수 없었습니다. 나는 Mac 용 지침 (Mac v. 10.12.2)과 http://www.lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php에 g ++를 모두 따라 갔다.
지금은 -l (소문자 L) 옵션으로 지정된 라이브러리를 찾을 수 없다는 링커 오류가 있습니다. 여기 내 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
나는 -lSDL2를 시도했습니다. 나는 -SIL을 시도했다. 나는 -l/usr/local/lib/libSDL2.a를 시도했다. 나는 다양한 방법으로 -L 옵션 (-l 옵션 없음)을 시도했다. /Users/myname/Documents/Code-Libraries/SDL2-2.0.5 그리고이 하나 (/ Users/myname/Documents/Code-Libraries 다른 사람들은 그들이 프로젝트의 헤더를 찾을 수 없습니다 얘기하면서 /SDL2-2.0.5는) ... ...
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
을 나에게 주었다. 나는 정말로 잃어버린 일부 도움을 정말 사랑합니다. 고맙습니다.
EDIT1 :
이이 파일을 /를 ~/문서의 디렉토리입니다/코드 라이브러리/SDL2- : 나는 nm /usr/local/lib/libSDL2.a | grep _SDL_CreateWindow
를하고
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있어
2.0.5/디렉토리 :
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/
여기의 구문은'-l/usr/local/lib/libSDL2.a'가 아닌'-lSDL2' 또는'/ usr/local/lib/libSDL2.a'이어야합니다. – nos
@nos 설명 할 수 있습니까? 나는 g ++가 /usr/local/lib/libSDL2.a를 링크하려고하는 라이브러리로 이해하는 방법을 이해하지 못합니다. 그것은 * .a이기 때문입니까? – astrocat1997
@nos도 작동하지 않았다 :-(. 정크가 많은'Undefined symbols for architecture x86_64 :'가있다. – astrocat1997