Skip to content

Instantly share code, notes, and snippets.

@quicquid
Last active June 21, 2018 10:12
Show Gist options
  • Save quicquid/4cd68be397ff2c7f2286e29acf3ae4fd to your computer and use it in GitHub Desktop.
Save quicquid/4cd68be397ff2c7f2286e29acf3ae4fd to your computer and use it in GitHub Desktop.
cvc4 linking problem
only there to have a better name in the overview
#include <cvc4/cvc4.h>
int main() {
CVC4::ExprManager _manager;
CVC4::SmtEngine _engine(& _manager);
_engine.setLogic("UFLIA");
CVC4::Integer i = CVC4::Integer(1000);
_manager.mkConst(i);
return 0;
}
CC=g++
CFLAGS=-I /opt/cvc4-devel/include
LFLAGS=-L /opt/cvc4-devel/lib
LIBS=-lcvc4 -lgmp
all : inter
inter : inter.o
$(CC) $(LFLAGS) -o inter inter.o $(LIBS)
inter.o : inter.cc
$(CC) -c $(CFLAGS) inter.cc
clean :
rm inter
rm *.o
@quicquid
Copy link
Author

Compilation is accepted, but linking is not:

make 
g++ -c -I /opt/cvc4-devel/include inter.cc
g++ -L /opt/cvc4-devel/lib -o inter inter.o -lcvc4 -lgmp
inter.o: In function `main':
inter.cc:(.text+0x75): undefined reference to `CVC4::Expr CVC4::ExprManager::mkConst<CVC4::Integer>(CVC4::Integer const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: inter] Error 1

I believe this is due to the declaration of a generic mkConst in expr_manager.h :

  /** Create a constant of type T */
  template <class T>
  Expr mkConst(const T&);

even though the template is not instantiated for the Integer class. The actual libcvc4.so only contains the instantiated templates which would explain that the error only occurs at the linking stage.

@quicquid
Copy link
Author

CVC4::Rational covers both integers and rationals, the proper call would be mkConst(CVC4::Rational(1000)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment