shared-libraries

Static Class Variables in Dynamic Library and Main Program [duplicate]

末鹿安然 提交于 2019-11-30 18:00:24
问题 This question already has an answer here : Main Program and Shared Library initializes same static variable in __static_initialization_and_destruction_0 (1 answer) Closed last year . I am working on a project that has a class 'A' that contains a static stl container class. This class is included in both my main program and a .so file. The class uses the default(implicit, not declared) constructor/destructor. The main program loads the .so file using dlopen() and in its destructor, calls

Resource ID In Android Library Project

自闭症网瘾萝莉.ら 提交于 2019-11-30 17:25:18
问题 I wanna include an open-source project in mine. But after check the "is library" option, some thing like "case R.id.menu_search:" can't be compiled. Should I replace them with its contant values, or how can I include it? case R.id.menu_search: // ! case expressions must be constant expressions onSearchRequested(); return true; ... 回答1: As others have pointed out, you need to change your switch() statement to if() / else if() / else statements. R.id.menu_search is not a constant ( static final

Creating shared libraries in C++ for OSX

久未见 提交于 2019-11-30 17:20:59
I just started programming in C++ and I've realized that I've been having to write the same code over and over again(mostly utility functions). So, I'm trying to create a shared library and install it in PATH so that I could use the utility functions whenever I needed to. Here's what I've done so far :- Create a file utils.h with the following contents :- #include<iostream> #include<string> std::string to_binary(int x); Create a file utils.cpp with the following contents :- #include "utils.h" std::string to_binary(int x) { std::string binary = ""; while ( x > 0 ) { if ( x & 1 ) binary += "1";

How can LD_LIBRARY_PATH be changed within CMake?

本小妞迷上赌 提交于 2019-11-30 17:08:59
I have a local shared library which is not in $LD_LIBRARY_PATH. I want to run my executable, but since it cannot find the shared library in the system folders, it outputs "error while loading shared libraries". A possible fix for this is to export a new LD_LIBRARY_PATH containing the local library folder. How can I export automatically this environment variable within CMake? If your shared lib is not build in the same CMake project of your executable, you can use the CMake rpath handling like this: set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) When you will run make install , CMake will

Making R installation self-contained/user-independent

怎甘沉沦 提交于 2019-11-30 16:18:28
问题 I'm trying to get R to ignore c:\users\name\documents and be completely self-contained/portable Here's my directory structure: .../R/R-2.1.2.2/... .../R/r_user/ .../R/libs_site/ I updated my Rprofile.site as follows: # Set the working directory setwd( file.path( R.home() , ".." , "r_user" ) ) # set the home directory Sys.setenv(HOME=file.path( R.home() , ".." , "r_user" ) ) # Set the site library folder .Library.site = file.path( R.home() , ".." , "libs_site" ) when R launches, I run

Intercepting Fortran STOP from C++

[亡魂溺海] 提交于 2019-11-30 15:44:01
问题 I prepared a C++ interface to a legacy Fortran library. Some subroutines in the legacy library follow an ugly but usable status code convention to report errors, and I use such status codes to throw a readable exception from my C++ code: it works great. On the other hand, sometimes the legacy library calls STOP (which terminates the program). And it often does it even though the condition is recoverable. I would like to capture this STOP from within C++, and so far I have been unsuccessful.

Trouble building the Open Asset Import Library (Assimp)

元气小坏坏 提交于 2019-11-30 15:34:08
问题 I have just downloaded the Open Asset Import Library (Assimp) which is an API used to import 3D file formats such as .3DS and .Obj into source code. Doing so allows for much easier rendering of meshes using openGL. The problem is, I can't get the Library to build. It comes with very vague and cryptic directions on how to build it and connect to a compiler such as XCode (which I am using). It says I should use a program called CMake to build the library. I have downloaded CMake and tried to

Intercepting Fortran STOP from C++

…衆ロ難τιáo~ 提交于 2019-11-30 15:28:52
I prepared a C++ interface to a legacy Fortran library. Some subroutines in the legacy library follow an ugly but usable status code convention to report errors, and I use such status codes to throw a readable exception from my C++ code: it works great. On the other hand, sometimes the legacy library calls STOP (which terminates the program). And it often does it even though the condition is recoverable. I would like to capture this STOP from within C++, and so far I have been unsuccessful. The following code is simple, but exactly represents the problem at hand: The Fortran legacy library

Executable shared libraries

蹲街弑〆低调 提交于 2019-11-30 15:10:40
Most of the time, when you compile a shared library, executing it is meaningless and doing so produces nothing useful: $ ./libfoobarbaz.so Segmentation fault However, the folks at GNU have been able to stick in some output when glibc is executed: $ /lib/libc.so.6 GNU C Library (Debian EGLIBC 2.11.2-10) stable release version 2.11.2, by Roland McGrath et al. Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 4.4.5.

How can I use Linux shared libraries in Java?

匆匆过客 提交于 2019-11-30 14:42:13
Is there any way to call the functions which are in a so library from my Java code? Generally, is it possible to use Linux so libraries in Java programs? paulsm4 The answer is "JNI" :) Here are a couple of links: How to compile dynamic library for a JNI application on linux? http://learn-from-the-guru.blogspot.com/2007/12/java-native-interface-jni-tutorial-hell.html http://docs.oracle.com/javase/6/docs/technotes/guides/jni/ Another wayto access libraries form java besides JNI is JNA . I find that in many cases it's easier to use then JNI, but that's just my personal opinion. You cannot use