dynamic-linking

Import Library benefit

℡╲_俬逩灬. 提交于 2019-12-14 03:22:45
问题 I understand pros and cons of static and dynamic linking. But what is the benefit of Import Library? 回答1: As it is stated in this answer import library (a.k.a. stub library) is useful when one wants to link executable dynamically but do not want to mess with LoadLibrary and GetProcAddress functions. 来源: https://stackoverflow.com/questions/39401403/import-library-benefit

How to get clang to link against a library without the “lib” prefix?

守給你的承諾、 提交于 2019-12-14 01:40:33
问题 My situation is I have a library that doesn't have a "lib" prefix. I'd like to link against it, and I can't recompile it (it's actually a Python module). Now, if you use the '-l' flag with GCC or clang, then the lib prefix is automatically added and the library is not found. For GCC, I can use '-l:mylib.so' to get it to link against an arbitrary file. However, this doesn't work for clang. Is it possible to get clang to link against a particular library without the 'lib' prefix? 回答1: This

Why do I get “DSO missing” error even when the linker can locate the library?

落花浮王杯 提交于 2019-12-13 19:22:04
问题 I am compiling a program against a shared library I have written. This library in turn relies on Boost::program_options (among other libraries). When I compile my program, I need of course to mention my library, but I get a DSO error: g++ ism_create_conf.cc -o ism_create_conf -lglsim_ol -lglsim -lhdf5 -lgsl /usr/bin/ld.real: /tmp/cc9mBWmM.o: undefined reference to symbol_ZN5boost15program_options8validateERNS_3anyERKSt6vectorISsSaISsEEPSsi' //usr/lib/x86_64-linux-gnu/libboost_program_options

How to run LLVM interpreter with a shared library?

爱⌒轻易说出口 提交于 2019-12-13 14:34:23
问题 I have mylib.c file which has some functions. I want to use those functions from my .c file as external ones in compiled llvm code. I'm playing with LLVM interpreter ( lli-4.0 ) and I wonder how can I tell lli to use functions from my .c file? 回答1: lli has a -load argument so you compile your C file to a dynamic library and then just do lli -load path-to-your-dynamic-library .... 来源: https://stackoverflow.com/questions/44189232/how-to-run-llvm-interpreter-with-a-shared-library

How lazy can C++ global initialization be?

北战南征 提交于 2019-12-13 12:01:17
问题 I'm used to thinking of all initialization of globals/static-class-members as happening before the first line of main(). But I recently read somewhere that the standard allows initialization to happen later to "assist with dynamic loading of modules." I could see this being true when dynamic linking: I wouldn't expect a global initialized in a library to be initialized before I dlopen'ed the library. However, within a grouping of statically linked together translation units (my app's direct

How to use nasm to generate a dynamic linked exe on windows?

孤街醉人 提交于 2019-12-13 06:21:02
问题 Basically I know we can use this to create a static linked exe on windows 32 bit: nasm -fwin32 test.s cl.exe test.obj /link libcmt.lib But how to create a dynamic-linked exe from the obj file nasm generated? 来源: https://stackoverflow.com/questions/21010335/how-to-use-nasm-to-generate-a-dynamic-linked-exe-on-windows

Calling a native C compiled with VS 2005 from C++/CLI Visual studio 2010 - Cannot open .lib file…

拟墨画扇 提交于 2019-12-13 06:08:13
问题 Hi I want to call functions from a C dll to C++/CLI. The C functions are declared extern. I followed this tutorial for linking the dll: http://social.msdn.microsoft.com/Forums/en/Vsexpressvc/thread/84deabaa-ae82-47cc-aac0-592f5a8dfa22 and then in my C++/CLI dll I have the following: // testWrapper.h #pragma once using namespace System; namespace testWrapper { extern "C" int GtoCalcImpliedVolatility2( double premium, int optionType, double underPrice, double strike, double yearsToExpiry,

Linking and loading shared libraries at runtime

喜夏-厌秋 提交于 2019-12-13 05:24:35
问题 I read that you can use the dynamic linker API using dlfcn.h Here's a code example using the API #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int x[2]={1,2}; int y[2]={3,4}; int z[2]; int main(){ void *handle; void(*addvec)(int *,int *,int *,int); char *error; // Dynamically load shared library that contains addvec() handle=dlopen("./libvec.so",RTLD_LAZY); if(!handle){ fprintf(stderr,"%s\n",dlerror()); exit(1); } // Get a pointer to the addvec() function we just loaded addvec

How to create a dynamic library for c++ on linux?

风流意气都作罢 提交于 2019-12-13 05:13:49
问题 I would like to create a dynamic library for c++ program on linux. In c++ program/system I`m using libconfig++ library, libpqxx library, some boost and c++11. My steps: 1) g++ -Wall -I/usr/local/include/ -std=c++0x -lconfig++ -Wall -lpqxx -lpq -fPIC -c ../SourceFiles/DBHandler.cpp ../SourceFiles/ParamServer.cpp ../SourceFiles/Functions.cpp 2) g++ -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 *.o 3) ln -sf libctest.so.1.0 libctest.so.1 4) ln -sf libctest.so.1.0 libctest.so 5) compile g+

Possible to statically link shared object libraries?

这一生的挚爱 提交于 2019-12-13 04:47:13
问题 I'm building a library that needs to be dynamically linked to my project. The output is a .so file, so I think I'm on the right track. I'm concerned by the way it's being linked at compile time - by specifying the location of its makefile and depending on a bunch of macros, which I've never encountered before. Can I assume that since I'm building a .so library (rather than a .a) that I'm in fact dynamically linking? Or is it possible for .so libs to be statically linked, in which case I need