shared-libraries

Unable to printf floating point numbers from executable shared library

独自空忆成欢 提交于 2019-12-03 06:17:46
I'm developing a shared library which can be executed independently to print it's own version number. I've defined a custom entry point as: const char my_interp[] __attribute__((section(".interp"))) = "/lib64/ld-linux-x86-64.so.2"; void my_main() { printf("VERSION: %d\n", 0); _exit(0); } and I compile with gcc -o list.os -c -g -Wall -fPIC list.c gcc -o liblist.so -g -Wl,-e,my_main -shared list.os -lc This code compiles and runs perfectly. My issue is when I change the parameter of the printf to be a float or double (%f or %lf). The library will then compile but segfault when run. Anyone have

How to share code between multiple projects with angularJS

流过昼夜 提交于 2019-12-03 05:53:48
I was wondering what would be the best practice to share common libraries and own modules between multiple angularJS projects. Let's assume that I'm working on two different projects. Both rely on libraries like angularJS, bootstrap etc. I have a file structure like below: Project 1 index.html css js module A module B lib angular bootstrap Project 2 index.html css js module B module X lib angular bootstrap So I was thinking about just creating another directory with all the shared components so that I get sth. like: Shared angular bootstrap module B Project 1 index.html css js module A Project

How to load a shared library without loading its dependencies?

孤街浪徒 提交于 2019-12-03 05:37:54
Say I have a library libfoo.so.1 , which depends (according to ldd ) on libbar.so.1 . However, libbar.so.1 is not available at the moment. My app needs to call a function in libfoo.so.1 which doesn't require libbar.so.1 at all. Is there a way to load libfoo.so.1 , resolve the function symbol and then call it without having libbar.so.1 to satisfy the dependency? It's a case of "I know what I'm doing, just let me do it already". I tried the RTLD_LAZY flag, but it still tries to load the libbar.so.1 library before not loading the symbols. EDIT Here's the exact situation. We have 3 players: libbar

/usr/bin/ld: cannot find

送分小仙女□ 提交于 2019-12-03 04:55:22
I created a .so file and put it in the location /opt/lib and added this path to LD_LIBRARY_PATH now after this when I try to compile my main program with the following command: g++ -Wall -I/home/alwin/Development/Calculator/ main.cpp -lcalc -o calculator I get the following error: /usr/bin/ld: cannot find -lcalc collect2: ld returned 1 exit status Can someone help me with this. I created the shared library using the code blocks IDE Matias Valdenegro Add -L/opt/lib to your compiler parameters, this makes the compiler and linker search that path for libcalc.so in that folder. otter When you make

what is the difference between .so and .a files?

南笙酒味 提交于 2019-12-03 04:47:57
I am trying to compile a 3rd party library( on linux) and see that it is generating libsomething.a files I have my other libraries which are .so file But it appears that even .a is shared library and can be used just like a .so lib So is there any difference between the two ? or they are just same with different naming convention. But it appears that even .a is shared library Nope, it's a static library. and can be used just like a .so lib If you mean linking to it, then yes. But you can't dlopen() an .a file which you could do with an .so file. You can always ask our old friend Uncle G to

Is there a .def file equivalent on Linux for controlling exported function names in a shared library?

一个人想着一个人 提交于 2019-12-03 04:26:58
问题 I am building a shared library on Ubuntu 9.10. I want to export only a subset of my functions from the library. On the Windows platform, this would be done using a module definition ( .def ) file which would contain a list of the external and internal names of the functions exported from the library. I have the following questions: How can I restrict the exported functions of a shared library to those I want (i.e. a .def file equivalent) Using .def files as an example, you can give a function

nm reports symbol is defined but ldd reports symbol is undefined

烂漫一生 提交于 2019-12-03 04:03:18
I'm having a linking problem. I need to link against a shared library libfoo.so that depends on a function read which I would like to define myself in the file read.c. I compile and link everything together but at runtime I get the error /home/bar/src/libfoo.so: undefined symbol: sread. nm reports the symbol is defined $nm baz | grep sread 00000000000022f8 t sread but ldd reports the symbol is undefined $ldd -r baz | grep sread undefined symbol: sread (/home/bar/src/libfoo.so) What gives? Is there some isse with the fact that libfoo.so is a shared library? First, defining a function called

Configure and Build OpenCV to Custom FFMPEG Install

大城市里の小女人 提交于 2019-12-03 03:19:44
I cannot seem to configure OpenCV to link to a non-/usr/lib set of FFMPEG libraries. My LD_LIBRARY_PATH contains a direct link to the folder for the custom install of FFMPEG: LD_LIBRARY_PATH=/pathto/ffmpeg-0.10.2/lib Additionally, I've configured pkgconfig as: PKG_CONFIG_PATH=/samepathto/ffmpeg-0.10.2/lib/pkgconfig/ Within CMake however I cannot find any setting for path to FFMPEG - either in basic or custom. The only setting related to FFMPEG appears to be WITH_FFMPEG type setting (set to ON). I can build OpenCV but it seems to link to the system libraries for libavcodec - this causes a

nm symbol output t vs T in a shared so library

℡╲_俬逩灬. 提交于 2019-12-03 02:55:12
I have added a new function (fuse_lowlevel_notify_inval_directory) in user space fuse library. The compilation and creation of libfuse.so is finished without error. But when my application tries to use this new function, the linker is throwing error: undefined reference to `fuse_lowlevel_notify_inval_directory' collect2: ld returned 1 exit status When I checked with nm nm ../libfuse.so | grep inval 00000000000154ed T fuse_invalidate **000000000001e142 t fuse_lowlevel_notify_inval_directory** 000000000001e26c T fuse_lowlevel_notify_inval_entry 000000000001e1cb T fuse_lowlevel_notify_inval_inode

Dynamic Shared Library compilation with g++

心已入冬 提交于 2019-12-03 02:51:49
问题 I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with g++. This is just an example so I can learn how to use and write shared libraries. The real code for the library I'm developing will be written in C++. #include <stdlib.h> #include <stdio.h> #include <dlfcn.h> int main(int argc, char **argv) { void *handle; double (*cosine)(double); char *error; handle = dlopen ("/lib/libm.so.6", RTLD_LAZY); if (!handle) { fputs (dlerror(), stderr); exit(1); }