【问题标题】:Can't compile code with CVC4 C++ API无法使用 CVC4 C++ API 编译代码
【发布时间】:2016-12-20 07:24:44
【问题描述】:

我只是想编译这个文件helloworld.cpp

#include <iostream>
#include <cvc4/cvc4.h>
using namespace CVC4;
int main() {
        ExprManager em;
        Expr helloworld = em.mkVar("Hello World!", em.booleanType());
        SmtEngine smt(&em);
        std::cout << helloworld << " is " << smt.query(helloworld) << std::endl;
        return 0;
}

使用g++ helloworld.cpp -lcvc4 -o helloworld -lcvc4 -Wno-deprecated。但它给了我这个错误

/tmp/cc9SFpL4.o: In function `main':
helloworld.cpp:(.text+0xac): undefined reference to `CVC4::ExprManager::mkVar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CVC4::Type, unsigned int)'
collect2: error: ld returned 1 exit status

救命!

我已经安装了CVC4/etc/apt/sources.list 中添加repo 链接,然后调用sudo apt-get install cvc4 libcvc4-dev libcvc4parser-dev

编辑:我打错了g++ helloworld.cpp -lcvc4 ... 我使用了g++ helloworld.cpp -o helloworld -lcvc4 -Wno-deprecated。实际上我使用了所有的组合、排列。

【问题讨论】:

  • 你在安装之前有sudo apt-get update吗?刚刚使用存储库在 Ubuntu 14.04.4 LTS 上安装了 CVC4,示例运行正常。
  • 试试g++ helloworld.cpp -Wno-deprecated -o helloworld -lcvc4。在某些系统上,-l 链接器标志需要出现在最后。

标签: c++ g++ smt cvc4


【解决方案1】:

这似乎是 OP 环境的问题。 r4C9rAyrd6A1 和我都能够在我们的本地机器上编译该示例。具体问题可能是 OP 的编译器希望在其他标志之后使用 -lcvc4 链接器标志,例如g++ helloworld.cpp -Wno-deprecated -o helloworld -lcvc4 在 cmets 中提到。

【讨论】:

  • 你是对的。我在 WSL 上运行了同样的东西并且它有效。所以是的,这似乎是我的环境的问题。不管怎样,谢谢。 :)
  • 啊,我现在看到你的编辑了。太好了,你让它工作了。
猜你喜欢
  • 2014-10-17
  • 2013-02-25
  • 2012-04-01
  • 2013-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-07
  • 2015-07-23
相关资源
最近更新 更多