无法使用 CVC4 C++ 编译代码 API
Can't compile code with CVC4 C++ API
我只是想编译这个文件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 link 然后调用 sudo apt-get install cvc4 libcvc4-dev libcvc4parser-dev
.
编辑:我打错了 g++ helloworld.cpp -lcvc4 ...
我用了 g++ helloworld.cpp -o helloworld -lcvc4 -Wno-deprecated
。其实我用了所有的组合,排列。
这似乎是OP环境的问题。 r4C9rAyrd6A1 和我都能够在我们的本地机器上编译这个例子。具体问题可能是 OP 的编译器希望在其他标志之后使用 -lcvc4
链接器标志,例如g++ helloworld.cpp -Wno-deprecated -o helloworld -lcvc4
如评论中所述。
我只是想编译这个文件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 link 然后调用 sudo apt-get install cvc4 libcvc4-dev libcvc4parser-dev
.
编辑:我打错了 g++ helloworld.cpp -lcvc4 ...
我用了 g++ helloworld.cpp -o helloworld -lcvc4 -Wno-deprecated
。其实我用了所有的组合,排列。
这似乎是OP环境的问题。 r4C9rAyrd6A1 和我都能够在我们的本地机器上编译这个例子。具体问题可能是 OP 的编译器希望在其他标志之后使用 -lcvc4
链接器标志,例如g++ helloworld.cpp -Wno-deprecated -o helloworld -lcvc4
如评论中所述。