我有些怀疑:
用例:
A static library containing a global variable, static variable, a function
and a class defined
A shared library uses these and hence they are part of the same.
A executable program also uses the same and they are part of the same.
The executable loads the shared library
我有一个共享库,由另一个我无法控制的应用程序使用,它需要*.so对象。我的库使用了需要静态链接的sqlite3 (我绝对需要一个自包含的二进制文件)。
当我试图编译和链接我的库时:
-fpic -flto -pthread -m64
-flto -static -shared
最后会出现以下错误:
/usr/bin/ld: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.1/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when mak
我正在用C++编译一个-static程序,这样我就可以把我的程序带到服务器上运行了。服务器没有安装我要链接的所有库,当试图运行程序时,我得到一个错误,即由于没有安装libopenblas.so.0,所以找不到OpenBLAS:
error while loading shared libraries: libopenblas.so.0: cannot open shared object file: No such file or directory
我需要OpenBLAS作为线性代数库Armadillo,并使用标志进行编译。
-std=c++11 -static -pthread -Ofas
在此之后,我尝试编译stdlib.so以将其他代码与其链接。不幸的是,stdlib.so本身是一个动态链接的二进制:
# ldd /usr/local/go/pkg/linux_amd64_dynlink/libstd.so
ldd: warning: you do not have execution permission for `/usr/local/go/pkg
/linux_amd64_dynlink/libstd.so'
linux-vdso.so.1 (0x00007ffd611d7000)
libpthread.so.0 => /lib64/lib
我想用来自C++ Standard Base 的Linux构建我的程序。程序依赖于Boost库,用gcc 4.4版本构建。编译失败。是否可以使用LSB C++编译器构建Boost库?或者,有没有可能用一些旧的gcc版本来构建Boost库,推荐的版本是什么?我的最终目标是让我的可执行文件和第三方Boost库在大多数Linux发行版上运行。
通常,通过使用Boost库开发C++闭源应用程序,可以为Linux发行版获得更好的二进制兼容性?