0

I am just trying to compile this file 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;
}

using g++ helloworld.cpp -lcvc4 -o helloworld -lcvc4 -Wno-deprecated. But it is giving me this error

/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

Help!

I have installed CVC4 adding repo link in /etc/apt/sources.list and then calling sudo apt-get install cvc4 libcvc4-dev libcvc4parser-dev.

EDIT: I mistyped g++ helloworld.cpp -lcvc4 ... I used g++ helloworld.cpp -o helloworld -lcvc4 -Wno-deprecated. Actually I used all combinations, permutations.

Striezel
  • 3,693
  • 7
  • 23
  • 37
rnbguy
  • 1,369
  • 1
  • 10
  • 28
  • Did you do `sudo apt-get update` before the install? Just installed CVC4 on Ubuntu 14.04.4 LTS using the repository and the example worked. – r4C9rAyrd6A1 Aug 15 '16 at 23:37
  • Try `g++ helloworld.cpp -Wno-deprecated -o helloworld -lcvc4`. On some systems the `-l` linker flags need to appear last. – Douglas B. Staple Aug 16 '16 at 12:54

1 Answers1

2

This seems to be a problem with the OP's environment. Both r4C9rAyrd6A1 and I were able to compile the example on our local machines. The specific issue might have been that the OP's compiler wanted the -lcvc4 linker flag after the other flags, e.g. g++ helloworld.cpp -Wno-deprecated -o helloworld -lcvc4 as mentioned in the comments.

Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58