shared-libraries

CMake: how create a single shared library from all static libraries of subprojects?

你说的曾经没有我的故事 提交于 2019-11-27 10:31:53
I have the following layout: top_project + subproject1 + subproject2 Each of subproject1 and subproject2 creates a static library. I would like to link these static libraries in a single shared library at the top_project level. The information I gathered so far is: Either compile using -fPic (necessary on everything but Windows) in order to create position-independent code which will allow linking the static libraries into a single shared library or decompress all static libraries (e.g. using ar ) and re-link them into a shared library (which I think is an inelegant & non-portable solution)

ctypes error: libdc1394 error: Failed to initialize libdc1394

北慕城南 提交于 2019-11-27 10:23:24
I'm trying to compile my program to a shared library that I can use from within Python code using ctypes. The library compiles fine using this command: g++ -shared -Wl,-soname,mylib -O3 -o mylib.so -fPIC [files] `pkg-config --libs --cflags opencv` However, when I try and import it using ctypes from ctypes import * mylib = CDLL("/path/to/mylib.so") print mylib.test() // Expected output: Hello World I get the following error: libdc1394 error: Failed to initialize libdc1394 What's going on? Very frustrating that nobody actually shows a concrete solution. I had this issue after installing OpenCV.

What's the difference between .so, .la and .a library files?

a 夏天 提交于 2019-11-27 09:58:41
I know an .so file is a kind of dynamic library (lots of threads can share such libraries so there is no need to have more than one copy of it in memory). But what is the difference between .a and .la ? Are these all static libraries? If dynamic libs have big advantages over static ones, why there are still lots of static libraries? I also want to know the underlying mechanism to load libraries (both kinds) and how a piece of code in a lib is invoked when it is used somewhere. Which part of the kernel should I study? And what related Linux command/utility should I know in order to know how a

Shared libraries and .h files

耗尽温柔 提交于 2019-11-27 09:53:59
问题 I have some doubt about how do programs use shared library. When I build a shared library ( with -shared -fPIC switches) I make some functions available from an external program. Usually I do a dlopen() to load the library and then dlsym() to link the said functions to some function pointers. This approach does not involve including any .h file. Is there a way to avoid doing dlopen() & dlsym() and just including the .h of the shared library? I guess this may be how c++ programs uses code

How to list library dependencies of a non-native binary?

青春壹個敷衍的年華 提交于 2019-11-27 09:28:27
问题 When developing for native platform, I can use ldd to list all the shared libraries (.so files) a binary executable I build will try to load upon start-up. But when cross-compiling, I don't know how to get the same information. The ldd is not a normal binutils utility, like strip or ar , that can be built alongside gcc for cross compiling, but instead, it is a cryptic shell script that apparently can only run on native platform. So, using the cross-target binutils tools, is there any way to

Load 32-bit shared library from 64-bit application?

别来无恙 提交于 2019-11-27 09:14:25
I have a shared library that is compiled as 32-bit. Can I use it from a 64-bit application or do I need to compile the shared library as 64-bit as well? No, you cannot load a 32-bit library in a 64-bit application through conventional means. There are some clever hacks out there such as having a 32-bit application which loads the library and exports the functions through an IPC interface, but if you have the option to compile the library as 64-bit, then that is by far the best choice. cdiggins You cannot load dynamically or statically a 32-bit library from a 64-bit application or vice versa.

Compile with older libc (version `GLIBC_2.14' not found)

那年仲夏 提交于 2019-11-27 08:12:55
I have to compile a program on a current ubuntu (12.04). This program should then run on a cluster using CentOS with an older Kernel (2.6.18). I cannot compile on the cluster directly, unfortunately. If I just compile and copy the program without any changes I get the error message "kernel too old". The way I understood it, the reason for this is not so much the Kernel version, but the version of libc that was used for compilation. So I tried to compile my program dynamically linking the libc from the cluster and statically linking everything else. Research There are already a lot of questions

Error loading shared libraries of boost

ぃ、小莉子 提交于 2019-11-27 08:07:40
问题 I am working on centos. I installed boost version 1.45.0 on my system. The programs are compiled correctly but whenever I type command to see output it gives following error: ./a.out: error while loading shared libraries: libboost_thread.so.1.45.0: cannot open shared object file: No such file or directory 回答1: How did you install the boost libraries? The problem you're likely having is that the linker can not find the libraries, and when you built your program, you had to manually specify

Convert a Static Library to a Shared Library (create libsome.so from libsome.a): where's my symbols?

有些话、适合烂在心里 提交于 2019-11-27 08:07:25
the title of this question is an exact dupe , but the answers in that question don't help me. I have a bunch of object files packed in a static library: % g++ -std=c++98 -fpic -g -O1 -c -o foo.o foo.cpp % g++ -std=c++98 -fpic -g -O1 -c -o bar.o bar.cpp % ar -rc libsome.a foo.o bar.o I'd like to generate libsome.so from libsome.a instead of the object files, but the library is really barebones: % g++ -std=c++98 -fpic -g -O1 -shared -o libsome.so libsome.a % nm -DC libsome.so 0000xxxx A _DYNAMIC 0000xxxx A _GLOBAL_OFFSET_TABLE_ w _Jv_RegisterClasses 0000xxxx A __bss_start w __cxa_finalize

Without root access, run R with tuned BLAS when it is linked with reference BLAS

狂风中的少年 提交于 2019-11-27 07:59:11
问题 Can any one tell me why I can not successfully test OpenBLAS's dgemm performance (in GFLOPs) in R via the following way? link R with the "reference BLAS" libblas.so compile my C program mmperf.c with OpenBLAS library libopenblas.so load the resulting shared library mmperf.so into R, call the R wrapper function mmperf and report dgemm performance in GFLOPs. Point 1 looks strange, but I have no choice because I have no root access on machines I want to test, so actual linking to OpenBLAS is