关于RA编译的一些问题记录

1、使用cygwin下载的SDL库文件,存在错误: "Couldn't initialize SDL: No available video device";这个应该是cygwin的库里SDL与操作系统不匹配造成的。

解决方法:先在cygwin中安装一次,然后在http://www.libsdl.org/download-1.2.php上下载”SDL-devel-1.2.15-mingw32.tar.gz (Mingw32)”这个版本,在cygwin中解压,用make all可安装;再修改SDL_config.h文件的最后几行为:

#else

//#include "SDL_config_minimal.h"
#include "SDL_config_win32.h"
#endif /* platform config */ 

尝试了在g++添加-D _WIN32的方式定义宏,但是会导致cygwin本身错误,遂放弃;


2、修改Makefile文件,否则会导致出现ld错误: couldnot  find -lmingw的错误

#############
# generic application Makefile
# you can probably use this makefile for your app by changing the APPNAME variable
#############
APPNAME=openredalert
TARGET=../bin/$(APPNAME)
VERSION=462
RELEASE=1


#############
# compiler and linker
#############
CPLUSPLUS=g++
LINK=$(CPLUSPLUS)


#############
# SDL
#############
#SDL_INCLUDE=`sdl-config --cflags`
#SDL_LIBS=`sdl-config --libs`
SDL_INCLUDE=-I/usr/include 
SDL_LIBS=-lSDL


#############
# openredalert source and include directories
#############
INC=./src
OPENREDALERT_INCLUDE=-I$(INC)
SRC=./src ./src/audio ./src/game ./src/misc ./src/ui ./src/vfs ./src/vfs/mix ./src/vfs/filesystem ./src/video
DEST=./obj


#############
# compile parameters
#############
DEFAULT_CPPFLAGS=-O2 -fmessage-length=0 -D_FORTIFY_SOURCE=2
#DEFAULT_CPPFLAGS=$(CPPFLAGS)
CPPFLAGS_RELEASE=
CPPFLAGS_DEBUG=-g
ALL_CPPFLAGS=$(DEFAULT_CPPFLAGS) $(SDL_INCLUDE) $(OPENREDALERT_INCLUDE) -o


# Turns on debugging: to enable run "make -DDEBUG=1"
ifeq ($(DEBUG),1)
ALL_CPPFLAGS += -DDEBUG=1
endif


#############
# linker parameters
#############
#DEFAULT_LD_FLAGS= -shared -Wl,-soname,$(TARGET).$(VERSION) -o
DEFAULT_LD_FLAGS=-o 
LDFLAGS=$(SDL_LIBS) -lSDL_mixer $(DEFAULT_LD_FLAGS)


DEP_FILE=$(APPNAME).dep


#############
# tell make where to find the files
#############
vpath %.h $(INC)
vpath %.cpp $(SRC)
vpath %.o $(DEST)


#############
# create object file names from the source file names
#############
src_dirs=$(subst :, ,$(SRC))
source_files=$(foreach dir,$(src_dirs),$(wildcard $(dir)/*.cpp))
header_files=$(foreach dir,src,$(wildcard $(dir)/*.h))
OBJECTS=$(notdir $(patsubst %.cpp,%.o,$(source_files)))


#############
#############
release:
$(MAKE) $(TARGET) CPPFLAGS="$(CPPFLAGS_RELEASE) $(ALL_CPPFLAGS)"


#############
#############
debug:
$(MAKE) $(TARGET) CPPFLAGS="$(CPPFLAGS_DEBUG) $(ALL_CPPFLAGS)"


#############
#############
install:
mkdir -p $(DESTDIR)$(BINDIR)
install -m 755 ${DEST}/$(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
# create links ...


#############
#############
clean:
-rm -rf $(DEST) $(TARGET)


#############
#############
depend:
-makedepend -f- -Y -I$(INC) $(source_files) > $(DEP_FILE)


#############
# internal targets
#############
$(TARGET): $(DEST) $(OBJECTS)
cd $(DEST); $(LINK) $(OBJECTS) $(LDFLAGS) $@


#############
#############
$(DEST):
-mkdir -p $(DEST)


#############
#############
$(OBJECTS): %.o: %.cpp
$(CPLUSPLUS) $(ALL_CPPFLAGS) $(DEST)/$@ -c $<


#############
#############
#include $(DEP_FILE)


3、编译一个sdl文件简单命令为:g++ test_sdl.cpp -I/usr/include -lSDL

#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>


int main(int argc, char* argv[])
{
   
if ( SDL_Init(SDL_INIT_VIDEO) == -1 )
{
printf("init failed: %s\n", SDL_GetError());
return -1;
}
   
    printf("SDL initialized.\n");
    SDL_Quit();
    system("pause");
    return 0;
}


另外:去除cygwin不需要的dll的方法 为:

http://blog.csdn.net/simeone18/article/details/6591240

http://www.360doc.com/content/14/0426/20/14663225_372468300.shtml

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值