static-linking

How can I find a library name of .so file?

[亡魂溺海] 提交于 2019-12-01 11:18:44
For example, I have libprofiler.so file. How can I get name of this shared object like this: getname /usr/lib/libprofiler.so I want to do it because it is required for CMakeLists.txt in target_link_libraries(MyProject name_of_library) Th. Thielemann Do the following steps to link an existing lib to your target: Inform you which lib do you need: here profiler. Build the name of the lib. CMake does not really needs this but it is worth to know: Example on Unix/Linux lib + NAME + [.so|.a] [VERSION]. Here: libprofiler.so . In your CMakeLists.txt: find_library(LIB_PROFILER NAMES profiler

Memory Allocation in Static vs Dynamic Linking of C Runtime

孤人 提交于 2019-12-01 11:08:12
My program's architecture involves plugins (dlls) and the exe (obviously). We are the only plugin provider. I was told that allocating memory in a plugin and then freeing it in the exe code was a potential problem if we statically linked the c runtime. However, if we dynamically linked it, there was just one heap and the c runtime had access to all of it. We switched to dynamic linking on the basis of this advice, but all we've seen from the switch is headaches and trouble related to distribution and installation of the new runtimes. (Don't know what we avoided in terms of memory allocation

Rewriting symbols in static iOS libraries

安稳与你 提交于 2019-12-01 09:40:04
I am working on an iOS app which links several static libraries. The challenge is, those linked libraries define same method names with different implementations. Oddly, I don't get any duplicate symbol definition errors; but, to no surprise, I end up with access to only one implementation of the method. To be more clear, say I have libA and libB and they both define a global C method called func1() When I link both libA and libB, and make a call to func1(), it resolves to either libA's or libB's implementation without any compilation warning. I, however, need to be able to access both libA's

How to call a lib written in C++ from C?

﹥>﹥吖頭↗ 提交于 2019-12-01 08:19:24
问题 It seems to me like a no-brainer, but I cannot find any information against or for it. From the point of view of demangling etc, I don't suppose this to be a big problem, but I can't figure out, how I can write a little tiny C program which calls a function from a little tiny C++ library. I am on linux right now, trying with static binding. This must be something many people are running into or many books cover, but I feel like a blind gump sitting in front of this problem. Interestingly,

How can I find a library name of .so file?

为君一笑 提交于 2019-12-01 08:15:30
问题 For example, I have libprofiler.so file. How can I get name of this shared object like this: getname /usr/lib/libprofiler.so I want to do it because it is required for CMakeLists.txt in target_link_libraries(MyProject name_of_library) 回答1: Do the following steps to link an existing lib to your target: Inform you which lib do you need: here profiler. Build the name of the lib. CMake does not really needs this but it is worth to know: Example on Unix/Linux lib + NAME + [.so|.a] [VERSION]. Here:

Memory Allocation in Static vs Dynamic Linking of C Runtime

﹥>﹥吖頭↗ 提交于 2019-12-01 08:11:01
问题 My program's architecture involves plugins (dlls) and the exe (obviously). We are the only plugin provider. I was told that allocating memory in a plugin and then freeing it in the exe code was a potential problem if we statically linked the c runtime. However, if we dynamically linked it, there was just one heap and the c runtime had access to all of it. We switched to dynamic linking on the basis of this advice, but all we've seen from the switch is headaches and trouble related to

C - Compile with dependencies included

南笙酒味 提交于 2019-12-01 04:45:54
I have some code which I want to run on a machine which I do not have root access to. That machine does not have some of the libraries needed to run this code. Is there any way to include all dependencies when I compile? I realize the resultant file may be quite large. Alec Bennett What you're looking for is static compiling. Performing static compilation includes all of the libraries into the executable itself, so you don't have to worry as much about dependency chains on a specific system, distribution, etc. You can do this with: gcc -Wl,-Bstatic -llib1 -llib2 file.c The -Wl passes the flags

C++ Visual Studio: linking using pragma comment

百般思念 提交于 2019-12-01 03:06:04
I came across a piece of code which uses #pragma comment(lib, "libraryname"). Why this type of usage as opposed to just linking the library from the properties menu? In what situations is this usage called for? I am in windows using C++ Visual Studio 2010 . It would be nice to see an example which calls for this type of usage. Alex F The library writer can place a #pragma comment(lib, ...) command in the public header (.h) file. In this case, the client doesn't need to add this library to the linker dependencies list. By including an h-file in the program, the client is automatically linked to

C++ Visual Studio: linking using pragma comment

落花浮王杯 提交于 2019-11-30 23:02:20
问题 I came across a piece of code which uses #pragma comment(lib, "libraryname"). Why this type of usage as opposed to just linking the library from the properties menu? In what situations is this usage called for? I am in windows using C++ Visual Studio 2010. It would be nice to see an example which calls for this type of usage. 回答1: The library writer can place a #pragma comment(lib, ...) command in the public header (.h) file. In this case, the client doesn't need to add this library to the

How to add static libraries to a Visual studio project

时间秒杀一切 提交于 2019-11-30 21:36:08
I am trying to add static libraries to my project. To add the static library I am following Microsoft's instructions: http://msdn.microsoft.com/en-us/library/ms235627.aspx . My problem is I that am not able to see the dependent library while adding the reference to my project. In the tutorial mentioned above, they have mentioned that the dependency (ie. static library), should be added to the solution. The tutorial you have provided refers to a case in which you create your own static library - in this case you may want to add it to your solution and thus make it an integral part of the