shared-libraries

How to hide a global variable, which is visible across multiple files?

橙三吉。 提交于 2019-12-18 05:57:34
问题 I am writing a C (shared) library. It started out as a single translation unit, in which I could define a couple of static global variables, to be hidden from external modules. Now that the library has grown, I want to break the module into a couple of smaller source files. The problem is that now I have two options for the mentioned globals: Have private copies at each source file and somehow sync their values via function calls - this will get very ugly very fast. Remove the static

How to embed version information into shared library and binary?

牧云@^-^@ 提交于 2019-12-18 04:49:17
问题 On Linux, is there a way to embed version information into an ELF binary? I would like to embed this info at compile time so it can then be extract it using a script later. A hackish way would be to plant something that can be extracted using the strings command. Is there a more conventional method, similar to how Visual Studio plant version info for Windows DLLs (note version tab in DLL properties)? 回答1: One way to do it if using cvs or subversion is to have a special id string formatted

Are inline variables unique across boundaries?

孤街浪徒 提交于 2019-12-18 04:31:55
问题 This is a follow up of this question. As mentioned in the comments to the answer: An inline variable has the property that - It has the same address in every translation unit . [...] Usually you achieved that by defining the variable in a cpp file, but with the inline specifier you can just declare/define your variables in a header file and every translation unit using this inline variable uses exactly the same object. Moreover, from the answer itself: While the language does not guarantee

Eclipse on Mac dyld: Library not loaded: Image not found

时光怂恿深爱的人放手 提交于 2019-12-18 04:27:10
问题 All: I have successfully set up two projects (Hello and World) in one workspace (HelloWorld). These are simple projects that are supposed to work together as a main project and a shared library project. This is the structure: HelloWorld Hello src Hello.cpp Debug src Hello - [x86_64/le] World src World.cpp World.h Debug src libWorld.dylib - (x86_64/le] I have followed all instructions and finally was able to get them to compile with no errors. However, when I try to run the Hello project I

How to combine shared libraries?

为君一笑 提交于 2019-12-18 04:14:36
问题 I've got some .so libraries that I'd like to combine into one shared library so that it doesn't depend on the original .so files anymore. The .so files have dependencies to each other. How can I do this? Can I do this? 回答1: This assumes you have the source code to all shared objects: Provided there are no name space conflicts (which there should not be if the two co-exist as it is), it would not be too terribly hard to build them into one shared object. If the shared libraries themselves

cuda shared library linking: undefined reference to cudaRegisterLinkedBinary

主宰稳场 提交于 2019-12-18 04:01:47
问题 Goal: create a shared library containing my CUDA kernels that has a CUDA-free wrapper/header. create a test executable for the shared library. Problem shared library MYLIB.so seems to compile fine. (no problem). Error in linking: ./libMYLIB.so: undefined reference to __cudaRegisterLinkedBinary_39_tmpxft_000018cf_00000000_6_MYLIB_cpp1_ii_74c599a1 simplified makefile: libMYlib.so : MYLIB.o g++ -shared -Wl,-soname,libMYLIB.so -o libMYLIB.so MYLIB.o -L/the/cuda/lib/dir -lcudart MYLIB.o : MYLIB.cu

Creating a custom Document Library in SharePoint

↘锁芯ラ 提交于 2019-12-18 03:47:08
问题 I have a document library in my SharePoint page and there are 10 documents in it. If User A is logged in I want him to only see 5 of those documents in that document library. How can I create some custom document library for this to work? I have MOSS installed. Thanks in advance! 回答1: You could configure different permissions on each document in the document library. Just select the "Manage Permissions" option on each item and break the permission inheritance from the document library level.

C++ shared library undefined reference to `FooClass::SayHello()'

喜你入骨 提交于 2019-12-18 03:05:15
问题 I'm making a C++ Shared Library and when I compile a main exe that uses the library the compiler gives me: main.cpp:(.text+0x21): undefined reference to `FooClass::SayHello()' collect2: ld returned 1 exit status Library code: fooclass.h #ifndef __FOOCLASS_H__ #define __FOOCLASS_H__ class FooClass { public: char* SayHello(); }; #endif //__FOOCLASS_H__ fooclass.cpp #include "fooclass.h" char* FooClass::SayHello() { return "Hello Im a Linux Shared Library"; } Compiling with: g++ -shared -fPIC

Library headers and #define

删除回忆录丶 提交于 2019-12-18 02:55:09
问题 I wasn't sure what to search for for this one. So excuse me if this is simple. But let me outline the scenario and see what answers are out there. Let's say I have a library which defines a structure like this: struct Example { int a; #if B_ENABLED int b; #endif }; This header gets installed as a part of the library's installation as a whole. My question here is that if my library defines B_ENABLED it will have a structure with these two variables included. However if my application does not

Debugging a library with Xcode

百般思念 提交于 2019-12-18 01:11:10
问题 I have a more general question on working with libraries on with Xcode when building iPhone apps. I've created a framework from a project I've been working on to use some parts of it in other apps. That works pretty good, so far. But I have no idea how to debug into the files included in the included framework. I hope to get some kind of 'best practice' on that. Thanks a lot –f 回答1: There have been a lot of discussions of how best to reuse code with static libraries. I've settled on the