链接到静态编译的z3需要Linux上的附加库

链接到静态编译的z3需要Linux上的附加库,z3,static-linking,Z3,Static Linking,我使用CMake编译z3的静态版本,使用: cmake -DBUILD_LIBZ3_SHARED=false -DCMAKE_INSTALL_PREFIX=/opt/z3-devel -G "Unix Makefiles" ../ 现在,当我静态链接库和C++程序时,说Z3例子的这个小变化: #include"z3++.h" using namespace z3; int main(int argc, char** argv) { config conf; context c(con

我使用CMake编译z3的静态版本,使用:

cmake -DBUILD_LIBZ3_SHARED=false -DCMAKE_INSTALL_PREFIX=/opt/z3-devel -G "Unix Makefiles" ../

现在,当我静态链接库和C++程序时,说Z3例子的这个小变化:

#include"z3++.h"
using namespace z3;

int main(int argc, char** argv) {
  config conf;
  context c(conf);
  expr x = c.int_const("x");
  expr y = c.int_const("y");
  expr z = c.int_const("z");
  goal g(c);
  g.add( ((2*x)+y)+z == 4);
  g.add( (x+(2*y))+z == 4);
  g.add( x+y == 4);
  std::cout << g << "\n";
  tactic t(c, "fm");
  apply_result r = t(g);
  std::cout << r << "\n";
  return 0;
}
我收到一长串未定义的引用链接错误。解决这个问题的方法是添加
-lgomp-pthread-lrt-ldl
作为附加库。链接器输出以下警告:

/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/libgomp.a(target.o): in function `gomp_target_init':
(.text+0x32c): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
尽管如此,该程序在我自己的机器和Starexec上运行良好


这种静态和动态链接的结合是我能做的最好的吗?这些库不应该已经静态链接到libz3.a吗?我在系统上提供了gomp、pthread和rt的静态版本。

一个直接的想法:我记得至少在Windows上,OpenMP不是静态形式的,因此构建脚本可以设置为使用动态库,而不管目标是什么。从链接器发出的警告消息来看,它在您的平台上看起来很相似。这很有可能-如果我正确理解cmake标志,这只是表示静态库比动态库更受欢迎。在github存储库中提出一个问题可能是有意义的——我只是想确保这不是一个只发生在我身上的特定问题。一个直接的想法是:我记得至少在Windows上,OpenMP不是静态形式的,因此,可以将构建脚本设置为使用动态库,而不考虑目标。从链接器发出的警告消息来看,它在您的平台上看起来很相似。这很有可能-如果我正确理解cmake标志,这只是表达了静态库优于动态库的偏好。在github存储库中提出一个问题可能是有意义的——我只是想确保这不是一个只发生在我身上的特定问题。
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/libgomp.a(target.o): in function `gomp_target_init':
(.text+0x32c): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking