shared-libraries

Linker in second Docker layer doesn't find shared OpenCV libraries built in previous layer, but files exist

爷,独闯天下 提交于 2020-04-18 05:35:55
问题 I'm trying to create a docker image with OpenCV 4.3 and my own C++ program linked against OpenCV, both built for Linux. Because building OpenCV takes quite a while and the resulting docker image is pretty large and I only need libopencv_core.so and libopencv_calib3d.so , I tried to create the following two layers : Build OpenCV from source and build my own C++ program that links against OpenCV Copy the shared OpenCV libraries and my compiled program created in the first build layer to the

Static member variable for class that is dynamically loaded

强颜欢笑 提交于 2020-03-19 19:52:39
问题 If I were to load up some symbols using something like dlopen in C++ while other classes in that translation unit had static member variables what exactly is the behavior of those static member variables. Do they get initialized or no because the library isn't really loaded just the symbols that you looked up (which I'm thinking the latter is not true because if the symbol you looked up needs those they need to be loaded too)? 回答1: In short, there's no guarantee that static variables that

Static member variable for class that is dynamically loaded

余生颓废 提交于 2020-03-19 19:51:07
问题 If I were to load up some symbols using something like dlopen in C++ while other classes in that translation unit had static member variables what exactly is the behavior of those static member variables. Do they get initialized or no because the library isn't really loaded just the symbols that you looked up (which I'm thinking the latter is not true because if the symbol you looked up needs those they need to be loaded too)? 回答1: In short, there's no guarantee that static variables that

How to load a c++ dll file into Matlab

喜你入骨 提交于 2020-02-23 09:37:09
问题 I have a C++ dll file that uses a lot of other c++ librarys (IPP, Opencv +++) that I need to load into matlab. How can I do this? I have tried loadlibrary and mex. The load library does not work. The mex finds the linux things (platform independent library) and tries to include them. And that does not work. Does anyone have any good ideas? 回答1: loadlibrary should work. I use it all the time to call functions from dlls written in C++ with C wrappers. What errors are you getting when you try to

Missing a library in ldd after using gcc -l

不羁岁月 提交于 2020-02-20 07:13:06
问题 I'm compiling an executable called "interrogate" with: g++ -o built/bin/interrogate -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib \ built/tmp/interrogate_composite1.o built/tmp/interrogate_composite2.o \ -lp3cppParser -lp3dtool -lp3dtoolconfig -lp3pystub -pthread -ldl After the compilation, when i try to execute the executable: $ LD_LIBRARY_PATH=built/lib built/bin/interrogate built/bin/interrogate: symbol lookup error: built/lib/libp3dtool.so.1.8: undefined symbol: _Py_NoneStruct This symbol is

Missing a library in ldd after using gcc -l

风流意气都作罢 提交于 2020-02-20 07:12:22
问题 I'm compiling an executable called "interrogate" with: g++ -o built/bin/interrogate -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib \ built/tmp/interrogate_composite1.o built/tmp/interrogate_composite2.o \ -lp3cppParser -lp3dtool -lp3dtoolconfig -lp3pystub -pthread -ldl After the compilation, when i try to execute the executable: $ LD_LIBRARY_PATH=built/lib built/bin/interrogate built/bin/interrogate: symbol lookup error: built/lib/libp3dtool.so.1.8: undefined symbol: _Py_NoneStruct This symbol is

Referencing global symbols from shared library loaded with dlopen

坚强是说给别人听的谎言 提交于 2020-02-15 18:01:54
问题 I have a shared library which I want to access symbols from the main program. For example: main.c #include <stdio.h> void bar(void) { puts("bar"); } extern void foo(void); int main(void) { foo(); return 0; } foo.c #include <stdio.h> extern void bar(void); void foo(void) { puts("foo"); bar(); } I compile and run like: gcc -c -fpic foo.c gcc -shared -o libfoo.so foo.o gcc -L$(pwd) -o test main.c -lfoo ./test And I get the output I expect: foo bar However, I must use dlopen() and dlsym() because

Referencing global symbols from shared library loaded with dlopen

别说谁变了你拦得住时间么 提交于 2020-02-15 17:57:07
问题 I have a shared library which I want to access symbols from the main program. For example: main.c #include <stdio.h> void bar(void) { puts("bar"); } extern void foo(void); int main(void) { foo(); return 0; } foo.c #include <stdio.h> extern void bar(void); void foo(void) { puts("foo"); bar(); } I compile and run like: gcc -c -fpic foo.c gcc -shared -o libfoo.so foo.o gcc -L$(pwd) -o test main.c -lfoo ./test And I get the output I expect: foo bar However, I must use dlopen() and dlsym() because

How to link with libstdc++_pic.a with GCC?

喜夏-厌秋 提交于 2020-02-06 11:27:37
问题 I have a libstdc++_pic.a on my system (Ubuntu 12.04, gcc 4.6.3), presumably this is the version of libstdc++ created with -fPIC. I also have a libstdc++.a. I see the following error when I try to statically link libstdc++ with a shared library via the -static-libstdc++ link flag: :-1: error: /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_exception::~bad_exception()' can not be used when making a shared object; recompile with -fPIC So I'm

How to link with libstdc++_pic.a with GCC?

前提是你 提交于 2020-02-06 11:22:09
问题 I have a libstdc++_pic.a on my system (Ubuntu 12.04, gcc 4.6.3), presumably this is the version of libstdc++ created with -fPIC. I also have a libstdc++.a. I see the following error when I try to statically link libstdc++ with a shared library via the -static-libstdc++ link flag: :-1: error: /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_exception::~bad_exception()' can not be used when making a shared object; recompile with -fPIC So I'm