shared-libraries

Profile a C shared library called by Ruby program

柔情痞子 提交于 2019-12-23 22:47:01
问题 I have a program written in Ruby and C. The C portion is a shared library, which is an extension for the Ruby program. I want to profile the C shared library I wrote, using gprof. I compile the shared library like this: gcc -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -march=i686 -O2 -ggdb -pg -fPIC -c extension.c gcc -shared -o extension.so extension.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,

How can I use ctypes to pass a byteArray into a C function that takes a char* as its argument?

孤街浪徒 提交于 2019-12-23 22:33:20
问题 I have created a function in C which takes an int size and a char *buffer as arguments. I would like to use ctypes to call this function from python and pass in a python byteArray. I know that first you must compile the C file into a shared library (.so file) and use ctypes to call that function. Here's the code I have so far. encrypt.c: #include <stdio.h> void encrypt(int size, unsigned char *buffer); void decrypt(int size, unsigned char *buffer); void encrypt(int size, unsigned char *buffer

Having trouble setting library version to stable

一曲冷凌霜 提交于 2019-12-23 22:20:54
问题 I've created a library for use in another apps script, and looking at the Manifest's docs on Google, it says you can set the "version" in the "libraries" section to "stable" if you want it to automatically use the latest available verison dependencies.libraries[].version string The version of the library that is used by the script. This is either a version number or stable, meaning the last version created. In my manifest I have this (with [name] and [ID] filled in): "dependencies": {

Unable to import ssl on linux

天大地大妈咪最大 提交于 2019-12-23 22:10:04
问题 When I try to import ssl on any Python version I get Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ImportError: /lib/x86_64-linux-gnu/libssl.so.1.0.0: symbol X509_chain_up_ref, version OPENSSL_1.0.2 not defined in file libcrypto.so.1.0.0 with link time reference I have compiled Python 3.5 myself with libssl-dev version 1.0.2 . According to aptitude

Strange unordered map situation

心不动则不痛 提交于 2019-12-23 21:19:40
问题 I have a shared library with class: // HPP: class WorldSettings { private: static std::unordered_map<std::string, int> mIntegerStorage; static std::unordered_map<std::string, float> mFloatStorage; static std::unordered_map<std::string, std::string> mStringStorage; public: template <typename T> static T &Get(const std::string &key); template <typename T> static T &Set(const std::string &key, T value); }; // CPP: #define DoReturn(MapName, Key, Type) { \ assert( MapName.find(Key) != MapName.end(

When do Fortran module allocatable arrays go out of scope when loaded as a shared library?

早过忘川 提交于 2019-12-23 18:46:02
问题 I am calling a fortran subroutine from R as part of a more complex optimization problem. Currently, the subroutine is self-contained -- with an input of current parameter values and an output of function evaluation and gradient terms. I now wish to initialize an allocatable array as a shared module variable (prior to the optimization) that will be used (but not modified) by the subroutine during optimization. In this context, when would the shared allocatable array go out of scope or be

Expose only required functions in C

有些话、适合烂在心里 提交于 2019-12-23 16:25:08
问题 I am writing a small API library sort of module in C. I will compile this module and give it to my fellow developers and I will expose some required functions in header file of my module so developers who will use my module know which function to call for required functionality. Now I want to inquire one thing: Can I expose only desired functions in C. e.g. I have test.c having: #include "test.h" void A() { if( some condition is true ) B(); else return; } void B() { //some code here } and in

Illegal Argument exception when adding external library to Android Studio

北战南征 提交于 2019-12-23 13:27:12
问题 I created four libraries in Eclipse that are interdependent. When I add the libraries to my Android project, I get the exception below. After going through a process of elimination, I found that one of the three libraries caused the exception. I successfully use the four libraries in another Eclipse project, so I don't think there is anything wrong with them, the issue must be Android specific. I also added the libraries to a new blank Android project, where they work just fine. What are my

How to create a .dylib C extension on mac os x with distutils and/or setuptools?

邮差的信 提交于 2019-12-23 12:37:20
问题 I need to make a C extension with distutils (and/or setuptools) that can be used BOTH dynamically at runtime, and at compile time (for different purposes). This isn't a problem on Linux, but it's an issue on OS X. By default, distutils creates a "bundle" on OS X (and names it .so), which can be used at runtime, but NOT at compile time. I need to make a .dylib, which can be linked to at compile time, and I need to do it within a setup.py that I can package for PyPI. No matter what I try,

gdb: break in shared library loaded by python

两盒软妹~` 提交于 2019-12-23 08:10:10
问题 I'm trying to debug c/c++ code located in shared libraries which are loaded by ctypes.cdll.LoadLibrary() in python and then specific functions are called from python. The python code forks child processes, so I need to be able to break whether the c function is called from a python parent or child process. A dead-simple example: test.c // j = clib.call1(i) int call1(int i) { return i*2; } test.py import os, sys, ctypes path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "test.so