我创建了一个make文件(手动)来构建我自己的OpenGL包装器..
一直说make: *** No rule to make target 'obj/Lin32/Exports.o', needed by 'bin/OpenGL32.so'. Stop.
但是,规则是:$(ObjLinSRC)/$.o: $(SrcDIR)/%.cpp
其中ObjLinSRC = obj/Lin32
和
SrcDIR = src
..
我的make文件有什么问题?做make windows
工作得非常好,但make linux
失败了......我不明白为什么。有什么想法吗?
WinGPP = g++
LinGPP = g++
BinDIR = bin
ObjDIR = obj
SrcDIR = src
BitFLG = -m32
WinOUT = OpenGL$(subst -m,,$(BitFLG)).dll
LinOUT = OpenGL$(subst -m,,$(BitFLG)).so
WinDIR = $(BinDIR)
LinDIR = $(BinDIR)
ObjWinSRC = $(ObjDIR)/Win$(subst -m,,$(BitFLG))
ObjLinSRC = $(ObjDIR)/Lin$(subst -m,,$(BitFLG))
#--------------------------------------------------------------------------------------
WinDEP = -static -static-libgcc -static-libstdc++ -shared -s -Wl,--enable-stdcall-fixup -o
LinDEP = -static-libgcc -static-libstdc++ -shared -s -o
WinARGS = -std=c++11 -Wall -pedantic -O3 -DOPENGL32_EXPORTS -s -c $(BitFLG)
LinARGS = -std=c++11 -Wall -pedantic -O3 -DOPENGL32_EXPORTS -s -c $(BitFLG)
#--------------------------------------------------------------------------------------
CppFiles = \
$(wildcard $(SrcDIR)/*.cpp)
ObjLinFiles = \
$(patsubst $(SrcDIR)/%.cpp,$(ObjLinSRC)/%.o,$(CppFiles))
ObjWinFiles = \
$(patsubst $(SrcDIR)/%.cpp,$(ObjWinSRC)/%.o,$(CppFiles))
#--------------------------------------------------------------------------------------
all:
@echo
@echo " Instructions For Making GLX:"
@echo
@echo " For Windows: make windows"
@echo " For Linux: make linux"
@echo " For Both: make both"
@echo " To Clean Files: make clean"
@echo " Specific Builds: BitFLG=-m32 | BitFLG=-m64"
both: linux windows
linux: $(LinDIR)/$(LinOUT)
@echo
@echo "Finished Building OpenGL32 -- Colour-Only."
windows: $(WinDIR)/$(WinOUT)
@echo
@echo "Finished Building OpenGL32 -- Colour-Only."
clean:
@echo " Cleaning Build Files."
@rm -rf $(BinDIR) $(ObjDIR)
#--------------------------------------------------------------------------------------
$(LinDIR)/$(LinOUT): $(ObjLinFiles)
@echo
@echo "Linking Linux Object Files.."
@mkdir -p $(LinDIR)
@$(LinGPP) -fPIC -shared $(LinDEP) $(LinDIR)/$(LinOUT) $(ObjLinFiles) $(BitFLG)
$(ObjLinSRC)/$.o: $(SrcDIR)/%.cpp
@echo " Compiling Linux: "$<
@mkdir -p $(ObjLinSRC)
@$(LinGPP) $(LinARGS) -o $@ $<
$(WinDIR)/$(WinOUT): $(ObjWinFiles)
@echo
@echo "Linking Object Files.."
@mkdir -p $(WinDIR)
@$(WinGPP) -Wl,--kill-at -d --input-def $(SrcDIR)/OpenGL32.def $(WinDEP) $(WinDIR)/$(WinOUT) $(ObjWinFiles) $(BitFLG) -lgdi32 -lglu32 -lopengl32
$(ObjWinSRC)/%.o: $(SrcDIR)/%.cpp
@echo " Compiling: " $<
@mkdir -p $(ObjWinSRC)
@$(WinGPP) $(WinARGS) -o $@ $<
答案 0 :(得分:1)
你有一个错字:
$(ObjLinSRC)/$.o: $(SrcDIR)/%.cpp
$
中的$.o
应为百分比:
$(ObjLinSRC)/%.o: $(SrcDIR)/%.cpp