shared-libraries

Create a valid shared library in C

拈花ヽ惹草 提交于 2019-12-07 09:12:34
I'm doing some test to learn how to create shared library. The template for shared libraries in Code::Blocks is this library.c // The functions contained in this file are pretty dummy // and are included only as a placeholder. Nevertheless, // they *will* get included in the shared library if you // don't remove them :) // // Obviously, you 'll have to write yourself the super-duper // functions to include in the resulting library... // Also, it's not necessary to write every function in this file. // Feel free to add more files in this project. They will be // included in the resulting

unexpected reloc type 0x03

拟墨画扇 提交于 2019-12-07 08:23:43
问题 I'm trying to execute a program compiled with my own library, but when i execute the program I get the following error: ./a.out ./a.out: error while loading shared libraries: ../../lib-arm/libCustomLibrary.so: unexpected reloc type 0x03 That just happens with the Release execution, with the Debug execution all works fine. Where do you think that may be the problem? The CustomLibrary Library is linked with the following arguments: -lSubLibrary -fPIC -Wl,-Bstatic -lboost_system -lboost

How to know which functions of a library get called by a program

不打扰是莪最后的温柔 提交于 2019-12-07 07:32:32
问题 Assume I have binary library (*.so) and a binary program using that library (i.e. I do not own the source code for either). How can I find out which of the library's functions are called at run time. I would like to know their names, but do not need live info. Neither of the binaries includes debugging symbols. 回答1: The objdump command dumps external symbol references from a binary. The typical use case involves running it with the -T option, to dump a binary's external symbol references. For

Writing dependencies in makefile, with makefile

≡放荡痞女 提交于 2019-12-07 07:20:44
问题 Based on some SO questions -- and some further reference found --, I'm trying to build a makefile able to: find, given the directories in $(SRC) , the .cpp files to be compiled; compile the .cpp , producing .o objects; generate .so shared objects from each .o formerly compiled. What the make file is supposed to do to achieve that is: find, given the directories in $(SRC) , the .cpp files to be compiled; build the dependency list for each .cpp using -MM compiler's flag; annotate/add each

create and use shared library with qt

时光毁灭记忆、已成空白 提交于 2019-12-07 06:22:57
问题 I am new to the shared library stuff, so I have question about how to create/use a shared library, I am using Qt Creator with qt 5.4.2 with Microsoft Visual C++ 11.0 Compliler. In my project, I will need to create a dll which call functions from an external library (there are .h, .lib, .dll to use from). To understand how export/import of functions from library work, I tried to create a simple library with one function and use this in another programm first. After reading different tutorials,

When using a dll library, is it necessary to include all of the headers used to build the dll?

一笑奈何 提交于 2019-12-07 04:58:40
问题 I have built a shared library ( .dll ) from a C++ source code. Now when I want to use this library in another program, do I need to include all of the header files that were used originally for building the library, or including just the headers that belong to used functions in my (new) program suffices? There are many functions in the library that are not used directly in my new program, but, needless to say, all of them are used by the functions in the program. (So they are indirectly used

How to load a native shared object, in a jar, from an android application?

喜你入骨 提交于 2019-12-07 04:51:08
问题 I've got a shared object, which I'll call 'libFoo.so', compiled against the NDK. I have a java project (I'll call it 'jarlib') that makes use of that shared object, by calling System.loadLibrary("Foo"); That java project, I export as a jar, and use in an android application. If I comment out all the bits about the shared object, the jar works fine, and I'm able to interact with it perfectly. I can use jarlib, along with the shared object from a Unity android application with the shared object

std::any across shared library bounding in mingw

白昼怎懂夜的黑 提交于 2019-12-07 04:12:32
问题 I stumbled about an issue while using libstdc++'s std::any implementation with mingw across a shared library boundary. It produces a std::bad_any_cast where it obviously should not (i believe). I use mingw-w64, gcc-7 and compile the code with -std=c++1z. The simplified code: main.cpp: #include <any> #include <string> // prototype from lib.cpp void do_stuff_with_any(const std::any& obj); int main() { do_stuff_with_any(std::string{"Hello World"}); } lib.cpp: Will be compiled into a shared

How to set RPATH and RUNPATH with GCC/LD?

為{幸葍}努か 提交于 2019-12-07 03:54:23
问题 I recently encountered this problem after an upgrade of the system: using the GCC -Wl,-rpath= option works differently than before. I used it to set the search paths to some shared libraries that were built in a sub-module of my project. At the time I considered it better than setting LD_LIBRARY_PATH system-wide (I didn't want to set it every time I turned on the computer). Everything worked fine, and these two approaches seemed equivalent. Now it seams that the behavior of -rpath has changed

Python cannot find shared library in cron

随声附和 提交于 2019-12-07 03:04:13
问题 My Python script runs well in the shell. However when I cron it (under my own account) it gives me the following error: /usr/local/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory The first line of the script has: #!/usr/local/bin/python I know I have the following line in my ~/.bashrc file, which explains it works in the shell export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib If I cron it using the following