【发布时间】:2016-02-28 10:44:35
【问题描述】:
几天来,我一直在尝试在我的 mac 上编译一个开源 C++ 库 (QuantLib-1.7),但我似乎遇到了某种 C++11 兼容性问题。
当我从终端运行 make && sudo make install 时,编译似乎可以正常工作,除了一堆表单错误
Making all in BermudanSwaption
g++ -DHAVE_CONFIG_H -I. -I../../ql -I../.. -I../.. -I/opt/local/include -g -O2 -MT BermudanSwaption.o -MD -MP -MF .deps/BermudanSwaption.Tpo -c -o BermudanSwaption.o BermudanSwaption.cpp
In file included from BermudanSwaption.cpp:22:
In file included from ../../ql/quantlib.hpp:43:
In file included from ../../ql/experimental/all.hpp:25:
In file included from ../../ql/experimental/volatility/all.hpp:21:
In file included from ../../ql/experimental/volatility/zabr.hpp:31:
In file included from ../../ql/math/statistics/incrementalstatistics.hpp:35:
In file included from /opt/local/include/boost/accumulators/statistics/stats.hpp:14:
In file included from /opt/local/include/boost/accumulators/statistics_fwd.hpp:12:
/opt/local/include/boost/mpl/print.hpp:50:19: warning: in-class initialization
of non-static data member is a C++11 extension [-Wc++11-extensions]
const int m_x = 1 / (sizeof(T) - sizeof(T));
^
1 warning generated.
我猜这与 g++ 没有为 C++11 正确配置有关。我熟悉可以通过使用g++ -std=c++11 编译来调用 C++11 的事实。但是,尽管进行了很多谷歌搜索,但我找不到修改 makefile 的方法,以便在运行 make && sudo make install 时调用 -std=c++11。
任何帮助将不胜感激。
这是我认为相关的 makefile 部分:
BOOST_INCLUDE = -I/opt/local/include
BOOST_LIB = -L/opt/local/lib
BOOST_THREAD_LIB =
BOOST_UNIT_TEST_DEFINE = -DQL_WORKING_BOOST_STREAMS
BOOST_UNIT_TEST_LIB = boost_unit_test_framework-mt
BOOST_UNIT_TEST_MAIN_CXXFLAGS = -DBOOST_TEST_DYN_LINK
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPP = gcc -E
CPPFLAGS = -I/opt/local/include
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
CXXFLAGS = -g -O2
这是运行“g++ -v”的输出:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
Makefile.am:https://www.dropbox.com/s/v5j7qohwfup81od/Makefile.am?dl=0
Makefile.in:https://www.dropbox.com/s/t92hft9ea2ar1zw/Makefile.in?dl=0
QuantLib-1.7 目录:https://www.dropbox.com/sh/ulj0y68m8x35zg8/AAA-w7L2_YWIP8_KnwURErzYa?dl=0
完整的错误日志:https://www.dropbox.com/s/g09lcnma8skipv7/errors.txt?dl=0
【问题讨论】:
-
为什么不
brew install quantlib? -
好的,现在试一试。
-
g++ -I/opt/local/include/ -I/opt/local/include/boost BermudanSwaption.cpp \ > -o bermudanswaption -L/opt/local/lib/ -lQuantLib后跟./bermudanswaption现在似乎运行成功。这一切似乎都很混乱。有没有什么地方可以读到关于 quintib 的头文件和 cpp 文件是如何在文件系统中组织的?谢谢。 -
为什么不直接编辑显示“CXX = g++”的行使其显示为“CXX = g++ -std=c++11”?