dynamic-library

How to pass arguments to a method loaded from a static library in CPP

淺唱寂寞╮ 提交于 2019-12-04 15:40:49
I'm trying to write a program to use a static library of a C++ code into another C++ code. The first C++ code is hello.cpp : #include <iostream> #include <string.h> using namespace std; extern "C" void say_hello(const char* name) { cout << "Hello " << name << "!\n"; } int main(){ return 0; } The I made a static library from this code, hello.a , using this command: g++ -o hello.a -static -fPIC hello.cpp -ldl Here's the second C++ code to use the library, say_hello.cpp : #include <iostream> #include <string> #include <dlfcn.h> using namespace std; int main(){ void* handle = dlopen("./hello.a",

Building and Using a DYLIB in Xcode

混江龙づ霸主 提交于 2019-12-04 14:50:42
I'm trying to build a .dylib in Xcode. Currently the .dylib builds, but when I drag the .dylib into another project and try to #import one of the headers (Seeker.h) in the .dylib, I get this error: *: No such file or directory Seeker.h: No such file or directory The project is available as an Xcode project here . I can confirm the header is indeed in a path alongside the .dylib once built, but as for what to do with it I have no idea. My only experience with .dylib files is frameworks built into Mac OS X, like libsqlite3.dylib, which works perfectly. All the tutorials I can find on .dylib

OS X: Any way to DELAY loading of a DEPENDENT library (.dylib)?

◇◆丶佛笑我妖孽 提交于 2019-12-04 11:13:45
A C++ dependent library .dylib resides in a bundle located in the app package's Content/Frameworks. I'd like to DELAY the loading of that dependent library until I've completed some specific initialization. Is there any way OTHER THAN to create a Runtime-Loaded Library? Would using weak linking options prevent the .dylib from being loaded until first referenced? You mean lazy linking: ld -o test test.o -lazy_library /usr/lib/libz.dylib ld -o test test.o -lazy-lz Both load the Zlib compression library when a routine from it is first run. The problem is not to run the routines from your custom

Compiling Lua - create .so files?

痴心易碎 提交于 2019-12-04 06:24:18
I am compiling Lua 5.2.3 on Centos 6.5, and the compilation / install works fine. However, I also need the development libraries for another program to compile. I would usually install these by doing this : yum install lua-devel Problem is that installs the Lua 5.1 shared libraries, not the 5.2.3 ones. I could just run with Lua 5.1 from the Centos repo, but if it's a simple-ish thing (for someone who knows) to make the latest version work then I'd be grateful for someone showing me the way. For me the Linux makefiles are still a little bit er, well, you know... EDIT I found this site - http:/

How to create a Dynamic Library in D?

被刻印的时光 ゝ 提交于 2019-12-04 06:00:54
I want to create a Dynamic library (cross-platform) in D, so I did some Googling. After some time I found this page. I am absolutely stunned by how much complexities there are in writing, compiling and even linking to a DLL. Isn't there a uniform way of creating a shared library like you would in C? (just leave out the main function and pass some flags to the linker) Well, I decided to spend some time today messing with this and I kinda sorta have something that works, at least if the main program is also written in D (on Linux, I think it will work from C too on Windows. The reason is I didn

Load a Mac binary as a dynamic library

江枫思渺然 提交于 2019-12-03 17:01:02
问题 I am doing some reverse engineering with a binary executable without sources. On Windows what I can do is load an executable file (EXE) with LoadLibrary, just as it was a DLL file. If the loaded file is not relocatable I can simply relocate my loader code to "make space" for the other module. When I have the binary loaded, I can call it's functions (assuming I where where they are, of course), and do other stuff. Is there some way to do the same or similar on Mac? I have a mach-o executable,

Singleton class in a static library

北慕城南 提交于 2019-12-03 09:59:22
问题 Suppose I have a singleton class S in a static library, this could be linked with the other dynamic libraries D1 D2 D3, So from what I understand the class S will have a separate instance in each D1, D2 and D3 and this would be true even if it is not a singleton (like global) Is there any way to prevent multiple copies of class S? I cannot put the singleton S in another Dynamic library. Executable / | \ \ D1 D2 D3 D4 | | | S S S EDIT: The singleton S is in a separate static library that links

Load a Mac binary as a dynamic library

强颜欢笑 提交于 2019-12-03 05:58:51
I am doing some reverse engineering with a binary executable without sources. On Windows what I can do is load an executable file (EXE) with LoadLibrary, just as it was a DLL file. If the loaded file is not relocatable I can simply relocate my loader code to "make space" for the other module. When I have the binary loaded, I can call it's functions (assuming I where where they are, of course), and do other stuff. Is there some way to do the same or similar on Mac? I have a mach-o executable, and I'd like to load it as it was a dynamic library (DYLIB). Or is there some way to convert an

How to debug dylib with Xcode?

流过昼夜 提交于 2019-12-03 03:27:00
I have a Xcode project for library arith. I could build it with debug configuration, and I need to debug it. How can I do that? The ideal method would be to set up a test code to build an execution in a project file, and then set a breakpoint in a source code in arith library. However, it seems that Xcode arith project doesn't allow to add another use_arith project that uses the arith library. What method people use to debug a dynamic library in Xcode? ADDED I googled and found some ways to debug dll. Attaching to a running process can be one way of debugging dynamic library. And, for iPhone

LD_LIBRARY_PATH failing while trying to run Qt app

走远了吗. 提交于 2019-12-02 03:49:40
I want to run a Qt 5 based application usind dynamic libraries on Linux. In summary, a script will copy the executable and other relevant files, including all required .so inside a lib folder, to the desired destination and a script calling gksudo will work as caller to the app. Till now everything works fine till I call the executable script: the app doesn't run. When I ask to run with sudo , it tells me that a library (Qt5SerialPort...) is missing. Running ldd over the actual executable I discover that the app is getting the required libs not from within the lib folder, but some apparent