无论如何,我不再关心隐私了。如果确实有效,保留它的重点是什么?我会稍微更改文件名。这是原始代码。
CXX=g++
CXXFLAGS= -Wall
LDFLAGS=-Wno-deprecated -fPIC -pthread
DIR=Exedir/
EXOoffline=EXOdir/offline/
EXOofflinelib=utilities/misc utilities/database utilities/calib reconstruction analysis/manager analysis/jni analysis/root geant/EXOsim
LIBRARY=-lGui -L/usr/lib/root/5.09 -lMinuit -L/nfs/rabbitybunny/g/exo-software/software/hudson/builds-rhel5/build-id/1077/lib -lEXOUtilities -lEXOSim -lEXOROOT -lEXODBUtilities -lEXOAnalysisManager -lEXOAnalysisJNI -lEXOCalibUtilities -lEXOReconstruction -L/afs/rabbitybunny.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib -lTreePlayer
INCLUDE=-I $(ROOTSYS)/include `root-config --glibs` -I /nfs/rabbitybunny/g/exo/software/builds/current/include
INCLUDE+=$(addprefix -I$(EXOoffline),$(EXOofflinelib))
all: run
run: main.o
$(CXX) main.o -o $(DIR)$@ $(LIBRARY)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
#run: main.cpp
# $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDE) $(LIBRARY) main.cpp -o $(DIR)$@
.PHONY: clean
clean:
rm -rf *.o $(DIR)run
我得到了这个。
rabbitybunny@enigma $ make clean
rm -rf *.o Exedir/run
rabbitybunny@enigma $ make
g++ -Wall -I /afs/rabbitybunny.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/include `root-config --glibs` -I /nfs/rabbitybunny/g/exo/software/builds/current/include -IEXOdir/offline/utilities/misc -IEXOdir/offline/utilities/database -IEXOdir/offline/utilities/calib -IEXOdir/offline/reconstruction -IEXOdir/offline/analysis/manager -IEXOdir/offline/analysis/jni -IEXOdir/offline/analysis/root -IEXOdir/offline/geant/EXOsim -c -o main.o main.cpp
g++: -lCore: linker input file unused because linking not done
g++: -lCint: linker input file unused because linking not done
g++: -lRIO: linker input file unused because linking not done
g++: -lNet: linker input file unused because linking not done
g++: -lHist: linker input file unused because linking not done
g++: -lGraf: linker input file unused because linking not done
g++: -lGraf3d: linker input file unused because linking not done
g++: -lGpad: linker input file unused because linking not done
g++: -lTree: linker input file unused because linking not done
g++: -lRint: linker input file unused because linking not done
g++: -lPostscript: linker input file unused because linking not done
g++: -lMatrix: linker input file unused because linking not done
g++: -lPhysics: linker input file unused because linking not done
g++: -lMathCore: linker input file unused because linking not done
g++: -lThread: linker input file unused because linking not done
g++: -lGui: linker input file unused because linking not done
g++: -lm: linker input file unused because linking not done
g++: -ldl: linker input file unused because linking not done
g++ main.o -o Exedir/run -lGui -L/usr/lib/root/5.09 -lMinuit -L/nfs/rabbitybunny/g/exo-software/software/hudson/builds-rhel5/build-id/1077/lib -lEXOUtilities -lEXOSim -lEXOROOT -lEXODBUtilities -lEXOAnalysisManager -lEXOAnalysisJNI -lEXOCalibUtilities -lEXOReconstruction -L/afs/rabbitybunny.edu/package/cernroot/vol35/52800svn/Linux26SL5_i386_gcc412/lib -lTreePlayer
感谢您的帮助,我真的很感激。 (也许我应该学习使用cmake。)
答案 0 :(得分:0)
我不知道为什么你要创建一个基本上复制现有问题的全新问题,除了示例更整洁。为什么不编辑您现有的问题?
无论如何,问题是规则.cpp.o
是编译代码(将源文件.cpp
转换为目标文件.o
),但是你将链接器标志传递给它(-L$(LIBDIR)
等)。同样,当您链接代码与run
目标时,您不要将链接器标志传递给它。
通常你也 NOT 想要将-c
标志放在CXXFLAGS
变量中,因为通常你想在编译和链接行上使用该变量确保你的旗帜一致。
重写:
CXX = g++
CXXFLAGS = -wall
CPPFLAGS = -I$(INCDIR)
all: run
run: run.o
$(CXX) $(CXXFLAGS) run.o -o $@ -L$(LIBDIR) -lpng
.cpp.o:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
答案 1 :(得分:0)
我认为您的问题来自root-config
宏中的INCLUDE
命令:
INCLUDE=-I $(ROOTSYS)/include `root-config --glibs` ...
如果你运行它,它可能会列出一大堆-lXxx
选项 - 编译器所说的那些选项未使用,因为你在创建目标文件时没有链接。
运行root-config --glibs
并查看输出。然后找到另一个选项来生成包含选项而不是库。