我在这个宣布的错误中苦苦挣扎很多人但是我没有设法解决它看着别人的makefile。 我将首先解释我的目标和我正在做的事情。
g ++ -c ../../src/main.cpp ../../src/DummyGame.cpp -Wall -std = c ++ 11 -DMINGW32 -DUSE_STD -DUSE_SDL -DUSE_SDL_IMAGE -DUSE_OPENGL -DOPENGL32 -I ../../ src -I ../../ include -I ../../../../ libs / include -I .. /../../../MyLib/src -L ../../../../ MyLib / lib -L ../../../../ libs / lib / mingw32 / lib -lmingw32 -lSDL2 main -lSDL2 -mwindows -lSDL2_image -lSDL2_ttf -lopengl32 -lMyLib g ++ -Wall -std = c ++ 11 -DMINGW32 -DUSE_STD -DUSE_SDL -DUSE_SDL_IMAGE -DUSE_OPENGL -DOPENGL32 -I ../ .. / src -I ../../ include -I ../../../../ libs / include -I ../../../../ MyLib / src -L ../ ../../../MyLib/lib -L ../../../../ libs / lib / mingw32 / lib -lmingw32 -lSDL2main -lSDL2 -mwindows -lSDL2_image -lSDL2_ttf -l opengl32 -lMyLib -o Dummy.mingw32.exe ../../../../libs/lib/mingw32/lib/libSDL2main.a(SDL_windows_main.o):在 功能
console_main': /Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/main/windows/SDL_windows_main.c:140: und efined reference to
SDL_main' collect2.exe:错误:ld返回1退出状态 Makefile.mingw:26:目标配方' Dummy.mingw32.exe'失败 mingw32-make.exe:[Dummy.mingw32.exe]错误1 - xcopy / Y Dummy.mingw32.exe" ../../ bin" 找不到文件 - Dummy.mingw32.exe 0文件被复制 Makefile.mingw:34:目标配方'安装'失败 mingw32-make.exe:[安装]错误4 -
这是main.cpp文件的样子:
#include "DummyGame.h"
using namespace Dummy;
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
{
DummyGame *game = new DummyGame("Dummy", 720, 480);
game->run();
return 0;
}
DummyGame.h包含将包含SDL2标头的MyLib标头。
我在文件夹" i686-w64-mingw32"
中使用正确的32位版SDL2这是我的实际makefile:
CP = xcopy /Y
RM = del /F
TARGET = Dummy.mingw32.exe
PROJDIR = ../..
BASEDIR = $(PROJDIR)/../..
SRCDIR = $(PROJDIR)/src
INSTALLDIR = $(PROJDIR)/bin
INCLUDE = -I$(SRCDIR) -I$(PROJDIR)/include -I$(BASEDIR)/libs/include -I$(BASEDIR)/MyLib/src
LIBSPATH = -L$(BASEDIR)/MyLib/lib -L$(BASEDIR)/libs/lib/mingw32/lib
LIBSFLAG = -lmingw32 -lSDL2main -lSDL2 -mwindows -lSDL2_image -lSDL2_ttf -lopengl32 -lHikeGDK
LDFLAGS = $(INCLUDE) $(LIBSPATH) $(LIBSFLAG)
CXXFLAGS = -Wall -std=c++11 -DMINGW32 -DUSE_STD -DUSE_SDL -DUSE_SDL_IMAGE -DUSE_OPENGL -DOPENGL32
LIBS = $(CXXFLAGS) $(LDFLAGS)
MODULES = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(wildcard *.o)
all: $(TARGET)
$(TARGET): $(MODULES)
$(CXX) -c $(MODULES) $(LIBS)
$(CXX) $(OBJS) $(LIBS) -o $@
clean:
$(RM) $(OBJS)
$(RM) $(TARGET)
install:
$(CP) $(TARGET) "$(INSTALLDIR)"
感谢您的帮助。