最近我尝试运行一个简单的 QUESO 库示例,以下是有关该库的信息:
http://www.quest-scidac.org/software/queso/
我按照用户手册编写了自己的 Makefile 并尝试运行示例,这是我的 Makefie:
QUESO_DIR = /project/xfu/apps/queso-0.56.1
BOOST_DIR = /share/apps/boost-1.57
GSL_DIR = /project/cacds/apps/gsl/1.16
INC_PATHS = -I$(QUESO_DIR)/include -I$(BOOST_DIR)/include/boost -I$(GSL_DIR)/include/gsl
LIBS = \
-L$(QUESO_DIR)/lib -lqueso \
-L$(BOOST_DIR)/lib -lboost_program_options \
-L$(GSL_DIR)/lib -lgsl
CXX = mpic++
CXXFLAGS += -g -Wall -c
default : all
.SUFFIXES : .o .C
all : example_sip
clean :
rm -f *~
rm -f *.o
rm -f simple_sip_example
example_sip : example_main.o example_likelihood.o example_compute.o
$(CXX) example_main.o \
example_likelihood.o \
example_compute.o \
-o simple_sip_example $(LIBS)
%.o: %.C
$(CXX) $(INC_PATHS) $(CXXFLAGS) $(LIBS) $<
这是用户手册上的Makefile:
我按照用户手册进行操作,仅更改了库路径。但是当我输入 make -f Makefile_1
时,我收到了这些错误:
mpic++ -I/project/xfu/apps/queso-0.56.1/include -I/share/apps/boost-1.57/include/boost
-I/project/cacds/apps/gsl/1.16/include/gsl -g -Wall -c
-L/project/xfu/apps/queso-0.56.1/lib -lqueso -L/share/apps/boost-1.57/lib
-lboost_program_options -L/project/cacds/apps/gsl/1.16/lib -lgsl example_main.C
In file included from /project/xfu/apps/queso-0.56.1/include/queso/Environment.h:38,
from example_compute.h:28,
from example_main.C:25:
/project/xfu/apps/queso-0.56.1/include/queso/ScopedPtr.h:44: error: ISO C++ forbids declaration of 'unique_ptr' with no type
/project/xfu/apps/queso-0.56.1/include/queso/ScopedPtr.h:44: error: typedef name may not be a nested-name-specifier
/project/xfu/apps/queso-0.56.1/include/queso/ScopedPtr.h:44: error: expected ';' before '<' token
In file included from example_compute.h:28,
from example_main.C:25:
/project/xfu/apps/queso-0.56.1/include/queso/Environment.h:380: error: 'Type' in class 'QUESO::ScopedPtr<QUESO::GetPot>' does not name a type
make: *** [example_main.o] Error 1
您可以看到这些错误来自库的头文件。源文件来自库,我只写了Makefile。我在学校集群中运行这个示例,图书馆应该不会有任何问题,因为 IT 安装了它。所以我猜问题可能出在我的Makefile上,但我只是按照用户手册操作。 非常感谢!
最佳答案
问题解决了。这是因为 C++11 标准。
看来QUESO默认是用C++11构建的,但是我的gcc版本不支持C++11。更新gcc并重建库后,确保使用-std=c++11
,不存在此问题。
关于linux - 我的 Makefile 有问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41813959/