dynamic-linking

How to compile a cpp and then link it to a shared library

﹥>﹥吖頭↗ 提交于 2020-01-28 12:38:49
问题 I want to have the functions which are defined in another .cpp file become available in another simulation tool. I found the following code in this question: -finstrument-functions doesn't work with dynamically loaded g++ shared objects (.so) Trace.cpp #include <stdio.h> #ifdef __cplusplus extern "C" { void __cyg_profile_func_enter(void *this_fn, void *call_site) __attribute__((no_instrument_function)); void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument

How to compile a cpp and then link it to a shared library

二次信任 提交于 2020-01-28 12:38:24
问题 I want to have the functions which are defined in another .cpp file become available in another simulation tool. I found the following code in this question: -finstrument-functions doesn't work with dynamically loaded g++ shared objects (.so) Trace.cpp #include <stdio.h> #ifdef __cplusplus extern "C" { void __cyg_profile_func_enter(void *this_fn, void *call_site) __attribute__((no_instrument_function)); void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument

How to compile a cpp and then link it to a shared library

心不动则不痛 提交于 2020-01-28 12:37:26
问题 I want to have the functions which are defined in another .cpp file become available in another simulation tool. I found the following code in this question: -finstrument-functions doesn't work with dynamically loaded g++ shared objects (.so) Trace.cpp #include <stdio.h> #ifdef __cplusplus extern "C" { void __cyg_profile_func_enter(void *this_fn, void *call_site) __attribute__((no_instrument_function)); void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument

How to compile a cpp and then link it to a shared library

我只是一个虾纸丫 提交于 2020-01-28 12:37:11
问题 I want to have the functions which are defined in another .cpp file become available in another simulation tool. I found the following code in this question: -finstrument-functions doesn't work with dynamically loaded g++ shared objects (.so) Trace.cpp #include <stdio.h> #ifdef __cplusplus extern "C" { void __cyg_profile_func_enter(void *this_fn, void *call_site) __attribute__((no_instrument_function)); void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument

Why specify particular library in Visual Studio if the path to lib is known? [closed]

戏子无情 提交于 2020-01-25 20:26:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . TL/DR: Question start with steps that I've made and that I think are important to mention (let me know if it is not important and I will delete it). The question itself is in the bottom of page. I've posted 3 questions that has the same steps that I've issued before asking the

Call a function in another object file without using PLT within a shared library?

为君一笑 提交于 2020-01-23 20:10:16
问题 I have two assembly codes, code1.s and code2.s and I want to build a relocatable (using -fPIC switch) shared library from these two. I want code2.s call a function, named myfun1 , which is defined in code1.s . When I use call myfun1@PLT in code2.s it finds the function and it works like a charm but it uses PLT section to call this function which is in the same shared library. I want to do this without adhering to PLT section. When I remove @PLT I get the relocation R_X86_64_PC32 against

@rpath for a dynamic library embedded in a framework

喜欢而已 提交于 2020-01-22 14:27:05
问题 I have an app, call it Animal.app . Inside its Contents/Frameworks folder is a framework, say Mammal.framework . And inside the Versions/A/Frameworks folder of the framework, I have dog.dylib . The install name of dog.dylib is @rpath/dog.dylib. For the "Runpath Search Paths" setting of the framework, I have specified @loader_path/../Frameworks . (My reasoning for that last setting is that the "loader" of the dylib would be the binary of the framework, at the path Mammal.framework/Versions/A

Problems with LD_PRELOAD and calloc() interposition for certain executables

ⅰ亾dé卋堺 提交于 2020-01-22 12:51:06
问题 Relating to a previous question of mine I've successfully interposed malloc , but calloc seems to be more problematic. That is with certain hosts, calloc gets stuck in an infinite loop with a possible internal calloc call inside dlsym . However, a basic test host does not exhibit this behaviour, but my system's "ls" command does. Here's my code: // build with: g++ -O2 -Wall -fPIC -ldl -o libnano.so -shared Main.cc #include <stdio.h> #include <dlfcn.h> bool gNanoUp = false;// global //

Linking with -R and -rpath switches on Windows

假如想象 提交于 2020-01-21 12:18:09
问题 I,m using gcc compiler(MinGW) on Windows XP.I created a .dll library libdir.dll than I tried to build a program that is using that library. I don't want to put that .dll file into System or System32 folder nor to set path to it in PATH variable, what i want is to give that information to the program itself. I know there is a -R and -rpath switches available so i was gonna link it with one of them. First -rpath: gcc -L /path/to/lib -Wl,-rpath, /path/to/lib main.o -ldir -o prog Than -R: gcc -L

Linking with -R and -rpath switches on Windows

為{幸葍}努か 提交于 2020-01-21 12:18:08
问题 I,m using gcc compiler(MinGW) on Windows XP.I created a .dll library libdir.dll than I tried to build a program that is using that library. I don't want to put that .dll file into System or System32 folder nor to set path to it in PATH variable, what i want is to give that information to the program itself. I know there is a -R and -rpath switches available so i was gonna link it with one of them. First -rpath: gcc -L /path/to/lib -Wl,-rpath, /path/to/lib main.o -ldir -o prog Than -R: gcc -L