gpt4 book ai didi

c++ - 你如何用cling加载一个库?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:00:33 25 4
gpt4 key购买 nike

这甚至可能不是一个固定问题,我是 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?

最佳答案

Cling 需要知道您要使用的结构/函数的语法以及执行的二进制代码。

对于语法你必须添加包含,例如像这样:

#include "myfile.hpp"

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

#pragma cling load("myfile.so.9.220.0")

关于c++ - 你如何用cling加载一个库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37671030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com