5

这甚至可能不是一个棘手的问题,我是 C++ 新手。

我正在尝试在 cling REPL 中使用一个名为 QuantLib 的库。

我可以通过这样做在 GCC 中加载库

#include "ql/quantlib.hpp"

然后用-lQuantLib.

在坚持中,我一直在尝试以下 3 行的排列:

.I "ql/quantlib.hpp"
#include "ql/quantlib.hpp"
.L QuantLib

如果我运行第#include一个,我会得到一个很长的错误,包括像

You are probably missing the definition of
QuantLib::AbcdAtmVolCurve::accept(QuantLib::AcyclicVisitor&) Maybe you
need to load the corresponding shared library?

但如果我跑

.I "ql/quantlib.hpp"
#include "ql/quantlib.hpp"

那么一切似乎都很好。

.L Quantlib结果是

input_line_4:1:10: fatal error: 'QuantLib' file not found
#include "QuantLib"

无论何时运行。

在 kfsone 发表评论后,我尝试了以下操作

.L /usr/lib/libQuantLib.so
#include "ql/quantlib.hpp"

这给出了一个简短的错误!

IncrementalExecutor::executeFunction: symbol '_ZN8QuantLib5ErrorC1ERKSslS2_S2_' unresolved while linking function '__cxx_global_var_init34'!
You are probably missing the definition of QuantLib::Error::Error(std::string const&, long, std::string const&, std::string const&)
Maybe you need to load the corresponding shared library?
4

1 回答 1

4

Cling 需要知道你想使用的结构/函数的语法和执行的二进制代码。

对于必须添加包含的语法,例如:

#include "myfile.hpp"

对于二进制代码,您必须像这样加载库:

#pragma cling load("myfile.so.9.220.0")
于 2018-05-11T11:51:33.410 回答