static-libraries

Static variable initialization over a library

一个人想着一个人 提交于 2019-11-27 14:50:39
I am working on a factory that will have types added to them, however, if the class is not explicitly instiated in the .exe that is exectured (compile-time), then the type is not added to the factory. This is due to the fact that the static call is some how not being made. Does anyone have any suggestions on how to fix this? Below is five very small files that I am putting into a lib, then an .exe will call this lib. If there is any suggestions on how I can get this to work, or maybe a better design pattern, please let me know. Here is basically what I am looking for 1) A factory that can take

static library, but I still need headers?

心已入冬 提交于 2019-11-27 14:30:07
问题 I have a bunch of projects that all could share a "common" static library of classes. What confuses me is if I make a static library out of these classes and link against it in my projects that I still need the headers of the classes in the static library in my main projects. What is the benefit of the static library then? How do companies like Adobe deal with this? 回答1: Static libraries allow you to create a library and use that library in many projects. The need for header files: Since the

“undefined reference” when linking against a static library

六月ゝ 毕业季﹏ 提交于 2019-11-27 14:27:23
问题 g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 I have the following static library called sdpAPI.a. I am having problems trying to link it with my test application. Just wondering if I am doing something wrong. The static library has been built with g++; My directory is as follows: /projects/unit_test/main.c /projects/unit_test/sdp/inc/sdpAPH.h /projects/unit_test/sdp/lib/sdpAPI.a My source code is this: #include <stdio.h> #include "sdpAPI.h" int main(void) { printf("----- TEST SDP ------\n"); try

Static library loaded twice

ε祈祈猫儿з 提交于 2019-11-27 14:10:20
问题 I have shared object A.so which statically links to libssl.a & another shared object B.so which also statically links libssl.a . A.so & B.so has symbols from libssl.a in GLOBAL scope. I checked this by readelf -s A.so I have an executable a.out which loads A.so and B.so. When a.out terminated I get a double free error in one of the symbols from libssl.a in A.so. Even though libssl.a is statically linked to each shared object, since they are exposed globally is it possible that the same symbol

How do I fix warning MSB8012 in a static library project in Visual C++ 2010?

浪子不回头ぞ 提交于 2019-11-27 14:04:58
I am trying to convert a static library from VC++2008 to VC++2010, and I get these warnings about TargetPath and TargetName. I have had a look into my configuration and I'm not sure how to make these go away. Is it serious or is it really just an ignorable warning, for a static library that I usually build once and rarely rebuild. I think it has something to do with the fact that the project is named itk32, but the debug version of the library is named itk32d.lib, and the old way that this is configured in Visual C++ 6.0 era has resulted in some kind of weird settings staying in the vc2010

CMake: How to create alias for installing different targets?

霸气de小男生 提交于 2019-11-27 13:12:03
问题 Suppose that I've got the following libraries: add_library(myLib_static STATIC ${SRC_FILES}) add_library(myLib SHARED ${SRC_FILES}) # installing header files install(FILES ${H_FILES} DESTINATION ${INSTDIRHEADER}) # installing binaries install(TARGETS myLib_static DESTINATION ${INSTDIRBIN}) install(TARGETS myLib DESTINATION ${INSTDIRBIN}) If I execute the following command, both shared and static libraries will be installed: make install How can I have separate install commands for each of

How to force inclusion of an object file in a static library when linking into executable?

爷,独闯天下 提交于 2019-11-27 12:25:39
I have a C++ project that due to its directory structure is set up as a static library A , which is linked into shared library B , which is linked into executable C . (This is a cross-platform project using CMake, so on Windows we get A.lib , B.dll , and C.exe , and on Linux we get libA.a , libB.so , and C .) Library A has an init function ( A_init , defined in A/initA.cpp ), that is called from library B 's init function ( B_init , defined in B/initB.cpp ), which is called from C 's main. Thus, when linking B , A_init (and all symbols defined in initA.cpp ) is linked into B (which is our

How to load a custom binary resource in a VC++ static library as part of a dll?

不想你离开。 提交于 2019-11-27 12:10:24
I have custom binary resources (animated cursors) that would like to store as resources in a static lib in Visual Studio C++. It turns out that custom binary resources will not get loaded by ::LoadCursor() or found by ::FindResource() if it is a custom resource and in a static library. This question gives some work around. Following its advice, if I add the *.res file to an exe as a "Configuration Property->Linker->Additional Dependency" then the static library will be able to find the resource. BUT if the static library is part of a dll and I link it in as an Additional Dependency it is not

OpenCV as a static library (cmake options)

Deadly 提交于 2019-11-27 12:01:54
I want to use OpenCV library in an embedded system and I need to compile my project using OpenCV as a static library. How can I create the library using cmake options ? To build OpenCV as static library you need to set BUILD_SHARED_LIBS flag to false/off: cmake -DBUILD_SHARED_LIBS=OFF .. But I think it is not enough for your task because you actually need to cross-compile library for you architecture. In case of Android or IOS such port already exists and you can simply use it. In case of another platform you need to create your own cmake toolchain file for cross-compiling and probably make a

Undefined symbols for architecture x86_64 - Mavericks (Yosemite, El Capitan…)

冷暖自知 提交于 2019-11-27 11:50:35
EDIT : If you fall on this post, you may want to jump directly to the answer I sent a post about my confusion earlier this morning machine type (C++ librairies) : i386 vs x86_64 But I guess I did a mistake by being not precise. So I decided to give an example of situations I face and that I can not understand. STEP 1 I build a library on machine A, a 2 years old mac with OS x 10.7.5 (that I guess is 64 bits; my guess being based on the commands you will see below in Additional Info) using the following files. A header SimpleClass.hpp: #ifndef SIMPLECLASS_HPP #define SIMPLECLASS_HPP class