这是一个相当初级的问题。基本上,我似乎无法使用SDL2外部库在OSX(Yosemite)上编译基本的Hello World程序。
我正在尝试在控制台上完成此操作,而不需要任何IDE的帮助。我已经安装了SDL 2.0.3,并且它位于/Library/Frameworks/SDL2.framework
路径下。
我的主文件看起来像这样:
#include <SDL2/SDL.h>
#include <stdio.h>
bool init();
void close();
SDL_Window* gameWindow = NULL;
SDL_Surface* gameScreenSurface = NULL;
bool init()
{
...
}
void close()
{
...
}
int main( int argc, char** argv)
{
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
SDL_Delay( 2000 );
}
close();
return 0;
}
我还有一个类似于下面这样的makefile文件(是从某个地方找来的例子):
CC = g++
LDFLAGS = -g -Wall
PROGNAME = doom
SOURCES = main.cpp
INCLUDES =
OBJECTS = $(subst %.cc, %.o, $(SOURCES))
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
ROOTLIBS := $(shell root-config --nonew --libs)
CFLAGS += $(ROOTCFLAGS)
LIBS += $(ROOTLIBS)
all: doom
$(PROGNAME): $(OBJECTS)
$(CC) $(LDFLAGS) -o doom $(OBJECTS) $(LIBS)
%.o : %.cc $(INCLUDES)
$(CC) ${CFLAGS} -c -g -o $@ $<
就是这样了。当我运行make
时,我会收到以下响应:
make: root-config: Command not found
make: root-config: Command not found
make: root-config: Command not found
make: root-config: Command not found
g++ -g -Wall -o doom main.cpp
Undefined symbols for architecture x86_64:
"_SDL_CreateWindow", referenced from:
init() in main-8b6fae.o
"_SDL_Delay", referenced from:
_main in main-8b6fae.o
"_SDL_DestroyWindow", referenced from:
close() in main-8b6fae.o
"_SDL_GetError", referenced from:
init() in main-8b6fae.o
"_SDL_GetWindowSurface", referenced from:
init() in main-8b6fae.o
"_SDL_Init", referenced from:
init() in main-8b6fae.o
"_SDL_Quit", referenced from:
close() in main-8b6fae.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: *** [doom] Error 1
那么,请给我一些指导好吗?我不太清楚从哪里开始。我以前从未在OSX或任何基于Unix的操作系统上编译过程序。
我搜索了一下缺失的root-config,似乎需要安装一个叫做Root的库。我已经安装了它,并将其解压到一个目录中,但不知道接下来该怎么做。
提前感谢。