shared-libraries

how can I link a shared object in C?

瘦欲@ 提交于 2019-12-12 20:00:42
问题 I made a simple program that uses a shared object, opening it with dlopen() . I also compiled and linked the shared object like below: gcc -o libmylib.so libmylib.c -shared -fPIC -Wall gcc -o program program.c -L. -lmylib -ldl -Wall When I tried to run the program for the first time it said something like cannot open libmylib.so: no such file or directory so I searched the internet and found that I have to copy my shared object to /lib/i386-linux-gnu/ in order for the program to run. So I did

How to load a dynamic library on demand from a C++ function/Qt method

我怕爱的太早我们不能终老 提交于 2019-12-12 19:19:45
问题 I have dynamic library created as follows cat myfile.cc struct Tcl_Interp; extern "C" int My_Init(Tcl_Interp *) { return 0; } 1) complile the cc file g++ -fPIC -c myfile.cc 2) Creating a shared library g++ -static-libstdc++ -static-libgcc -shared -o libmy.so myfile.o -L/tools/linux64/qt-4.6.0/lib -lQtCore -lQtGui 3) load the library from a TCL proc then I give command tclsh and given command % load libmy.so is there any C++ function/ Qt equivalent to load that can load the shared library on

GDB can't insert internal breakpoint

♀尐吖头ヾ 提交于 2019-12-12 19:12:20
问题 I added two breakpoints in functions of one shared library (.so) and ran gdb 7.4 and attached it to a process. Gdb hit the breakpoint and I ran n for several steps, and gdb reported the following errors(with bold text): (gdb) b [function name] Breakpoint 1 at 0xf1f28a49: file ../../../../../[file name].cpp, line 167. Breakpoint 2 at 0xf1f2dae5: file ../../../../../[file name].cpp, line 60. warning: Multiple breakpoints were set. Use the "delete" command to delete unwanted breakpoints. (gdb) c

Sharing classes between Server and Client projects in Silverlight

一笑奈何 提交于 2019-12-12 18:22:56
问题 Problem: Class B is a subclass of Class A. RIA service returns a list of object Bs. Class A and B are both necessarily defined on the server-side. They serialize fine, and I can use them in the primary client project. I have two other libraries, organized as client libraries. One is for custom controls, and the other is for classes that are shared between custom controls and the actual client project. I need Class A to be accessible from the Classes library clientside (so that the custom

Sharing a Netbeans project

懵懂的女人 提交于 2019-12-12 18:05:53
问题 I have a java project that I developed in Netbeans. Because I was the only developer and it's a simple project (one source file, but it needs several specialty libraries) I didn't use source control. I'm no longer going to be working on the project, and want to hand it over to someone else in case they need to make changes to it in the future. I don't think it will be sufficient to just zip up the project folder and send it to her, as the project points to libraries located elsewhere

Dynamic Linking of Shared Libraries with Dependencies

 ̄綄美尐妖づ 提交于 2019-12-12 18:05:10
问题 Is there a way to dynamically link shared libraries that have dependencies? For example, I have two libraries, libA.so and libB.so. libB.so calls functions defined in libA.so. In my main program, I wish to load the two libraries with dlopen. However, if I try: dlopen(libA.so); dlopen(libB.so); Then the second dlopen will fail as libB has unrecognized symbols. I can think of a few workarounds such as building all the object files into a single shared library, or to have libB.so call dlopen on

Find location of loaded shared library, from in that shared library?

痞子三分冷 提交于 2019-12-12 17:57:55
问题 From a function in a shared library, inside a running process (written in C), how do I discover where that shared library was loaded from? All of the answers I've found involve using things such as ldd at the command line, or by peeking in /proc/self/maps . On Win32, I'd just use GetModuleFileName(GetModuleHandle("foo.dll"), szPath, COUNTOF(szPath)) . What's the Linux equivalent? Bonus question: I need the same information in OS X. 回答1: You could use dl_iterate_phdr to iterate all loaded

Seg fault when app & shared lib built with -static-libstdc++

痞子三分冷 提交于 2019-12-12 17:22:41
问题 If I build a C++ app with -static-libstdc++ which loads a shared lib (via dlopen) which was also built with -static-libstdc++ , then the app seg faults during dlopen. BUT--this only happens in some setups: GCC 4.7.4, 32-bit: pass GCC 4.8.3, 32-bit: pass GCC 4.8.4, 64-bit: pass GCC 4.9.2, 64-bit: pass GCC 4.9.3, 32-bit: FAIL (unless RTLD_DEEPBIND is specified) GCC 4.9.3, 64-bit: pass Findings: If -static-libstdc++ is not used when building for either the shared lib or the app, it works. If (

does dynamic library shared global variable in linux

混江龙づ霸主 提交于 2019-12-12 16:51:25
问题 As we know, linux call ldconfig to load all *.so libraries and then link the applications who use the shared library. However, I am confused how the global variable is working in this case. Since there is only one copy of shared library across all these application, do they share the global variables in the shared library? If yes, then how they synchronize? Thanks, 回答1: No it is not shared - the code/text section of the library is shared - the data portion is unique to each process that uses

find_library or link_directories or find_package? What is better way? Error - Link libraries using cmake

假装没事ソ 提交于 2019-12-12 16:24:36
问题 Given The file /usr/lib/gstreamer-0.10/libgstffmpeg.so is present Making changes in CMakeLists.txt Approach 1 find_library() find_library(GST_FFMPEG NAMES gstffmpeg PATHS /usr/lib/gstreamer-0.10/ ) ... target_link_libraries( MyLibraryOrMyExecutable ${GST_FFMPEG} ) When I run make with above configuration(approach 1), I get the following errors /bin/ld: warning: libvpx.so.1 , needed by /usr/lib/i386-linux-gnu/libavcodec.so.53, not found (try using -rpath or -rpath-link) /bin/ld: warning: