shared-libraries

How to create a shared library with cmake?

吃可爱长大的小学妹 提交于 2019-11-28 14:58:51
I have written a library that I used to compile using a self-written Makefile, but now I want to switch to cmake. The tree looks like this (I removed all the irrelevant files): . ├── include │ ├── animation.h │ ├── buffers.h │ ├── ... │ ├── vertex.h │ └── world.h └── src ├── animation.cpp ├── buffers.cpp ├── ... ├── vertex.cpp └── world.cpp So what I am trying to do is just to compile the source into a shared library and then install it with the header files. Most examples that I have found compile executables with some shared libraries but never just a plain shared library. It would also be

Call shared library (.so) methods within Android Studios C files

那年仲夏 提交于 2019-11-28 14:19:33
I'm struggling with this for several days now. At the moment i'm just testing it with a simple C++ project (1 .h & 1 .cpp file) and a minimalistic App including the ndk helloJNI sample code (which worked perfect easily): Target Import existing C/C++ files (project) to Android Studio Approach After trying out some of the (dozens) of different possibilities, i think/thought the following steps would be the best solution for my purpose: Create the shared library (Calculator.so) from Visual Studios 2015 "Create shared library for Android" (or something) [successful] Create jniLibs folder in src

LD_LIBRARY_PATH, the shared lib path in linux

自古美人都是妖i 提交于 2019-11-28 14:12:04
I wrote a shared object, say libsd.so , and I put libsd.so and its header file sd.h in ~/lib . Here is another program using libsd.so , say test.c , then compile it like this: $ gcc -o test test.c -I~/lib -L~/lib -lsd Then I run test like this: $ ./test ./test_sd: error while loading shared libraries: libsd.so: cannot open shared object file: No such file or directory So I set export LD_LIBRARY_PATH=. , then it works. But if I unset LD_LIBRARY_PATH and put LD_LIBRARY_PATH=~/lib in my ~/.bashrc , then source ~/.bashrc , again it doesn't work for ./test , WHY? export LD_LIBRARY_PATH=~/lib is

Binary compatibility over what range of machines?

好久不见. 提交于 2019-11-28 13:42:43
I wrote a simple program in C and compiled it using GCC on Ubuntu. Will this file work on another machine? What are the contents of the output binary, and its external dependencies? Can it be run on other Linux distributions, and under what circumstances? Can it be run on other operating systems? There are several levels/sources of binary incompatibility. Firstly, addressing library incompatibility Normally, if you're running a binary on another machine, with a different version of the "same OS" (whatever that means...), then it will run fine. Completely. The issue isn't with code not working,

Debugging shared libraries with gdbserver

好久不见. 提交于 2019-11-28 13:38:28
I am using gdbserver on target and CodeSourcery IDE. My hardware is a gumstix with a omap3530. I can step through code in my main application but if I attempt to step into a function in a shared library I get memory address and a debugger terminates. This is my library that is compiled and copied to the /lib folder on the target system.(it does have debug symbols) I have attempted to use the .gbdinit file to set solib-absolute-prefix /lib Here are the warnings from the gdb trace: 903,056 13-gdb-set sysroot-on-target /lib 903,065 13^done 903,065 (gdb) 903,065 14-target-select remote 192.168.1

Linking shared library in Android project

筅森魡賤 提交于 2019-11-28 13:08:18
I need to import a single function written in a C file in an android studio project. This function call others functions located in anothers files (50+ C files and headers in total). This project already contains a single C++ file as I am using NDK to compile OpenCV4android. I've used Mingw and GCC to compile a shared libraries (libfinal.so) but once i try to import them thanks to NDKbuild i got this meaningless error : Error:Execution failed for task ':app:ndkBuild'. > Process 'command 'C:/SDK/ndk-bundle/ndk-build.cmd'' finished with non-zero exit value 2 Here is the Android.mk file : LOCAL

Trouble installing pygame using pip install

自古美人都是妖i 提交于 2019-11-28 12:16:00
I tried: c:/python34/scripts/pip install http://bitbucket.org/pygame/pygame and got this error: Cannot unpack file C:\Users\Marius\AppData\Local\Temp\pip-b60d5tho-unpack\pygame (downloaded from C:\Users\Marius\AppData\Local\Temp\pip-rqmpq4tz-build, conte nt-type: text/html; charset=utf-8); cannot detect archive format Cannot determine archive format of C:\Users\Marius\AppData\Local\Temp\pip-rqmp q4tz-build Please if anyone have any solutions please feel free to share them! I also tried pip install --allow-unverified , but that gave me an error as well. kstenger This is the only method that

How to create static linked shared libraries

穿精又带淫゛_ 提交于 2019-11-28 12:08:14
For my master's thesis i'm trying to adapt a shared library approach for an ARM Cortex-M3 embedded system. As our targeted board has no MMU I think that it would make no sense to use "normal" dynamic shared libraries. Because .text is executed directly from flash and .data is copied to RAM at boot time I can't address .data relative to the code thus GOT too. GOT would have to be accessed through an absolute address which has to be defined at link time. So why not assigning fixed absolute addresses to all symbols at link time...? From the book "Linkers and Loaders" I got aware of "static linked

Passing pointer argument in MATLAB to a C-DLL function foo(char**)

情到浓时终转凉″ 提交于 2019-11-28 11:29:22
I am writing a C-DLL to be called from MATLAB. Is it possible to call a function with const char ** parameter? e.g. void myGetVersion( const char ** ); The C code would be: const char *version=0; myGetVersion( &version ); What would be corresponding MATLAB-Code (if it is possible at all)? Thank you very much! P.S.: I think this is the help page , but I couldn't find my case :-( Amro The answer is to build a pointer to a c-string using the LIBPOINTER function as @JonasHeidelberg suggested. Let me expand his solution with a working example.. First lets build a simple DLL: version.h #ifndef

How can I remove a symbol from a shared object?

假装没事ソ 提交于 2019-11-28 11:08:27
Using GCC, how can I remove a symbol from a shared object after I've created the shared object? If I have three files in C manipulating symbol foo() like: // a.c int foo() { return 0xdead; } int baz() { return 1; } and // b.c int foo() { return 0xbeef; } int bar() { return 0; } and // c.c #include "stdio.h" extern int foo(); extern int bar(); extern int baz(); int main() { printf("0x%x, 0x%x, 0x%x\n",foo(),bar(),baz()); return 0; } Then I compile and run like: % gcc a.c --shared -fPIC -o a.so % gcc b.c --shared -fPIC -o b.so % setenv LD_LIBRARY_PATH . # export LD_LIBRARY_PATH=. for bash