static-libraries

Embed all external references when creating a static library

扶醉桌前 提交于 2020-01-11 13:20:06
问题 I need to create a wrapper library for C code that wraps my C++ library. Is there a way to create that wrapper library in such a way, that the user needs to link only this wrapper library and doesn't have to include all the (C++) libraries on the linker command line as well? The structure of my test project looks like this: . ├── lib │ ├── cpp │ │ ├── print.cc │ │ └── print.h │ ├── lib.cc │ ├── lib.h └── main.c The main.c is an example C application that uses my library. The lib.h and lib.cc

Mixing stdc++ and libc++ in an iOS project

纵饮孤独 提交于 2020-01-11 09:32:08
问题 I am having a difficult time configuring an iOS project which uses a static library linked against the old libstdc++ that gcc used. That library is 32 and 64-bit. There are 6 libraries (libssl.a for example) that are 32-bit and must be updated. If I compile those libraries from source, they will be automatically linked with libc++, which will result in my linker complaining. Therefore, here are my questions: 1) Is there any way to have a single static library inside the project use libstdc++,

How to include C static libraries in CMAKE project on MAC OS X

风格不统一 提交于 2020-01-11 07:39:08
问题 I am trying to learn Core Foundation with C/C++. I use JetBrains CLion that uses CMAKE. The problem is - I dunno how to include proper static libraries in C/C++ Makefile project on Mac. I need to link static library CFNetwork to my project in order to fix linking problems. Could you give me a quick hint? My case: #include <CFNetwork/CFNetwork.h> #include <iostream> int main() { CFStringRef bodyString = CFSTR(""); // Usually used for POST data CFDataRef bodyData =

Why is my static library so huge?

孤人 提交于 2020-01-11 02:15:29
问题 I have a C++ compiled static library of about 15 classes and their member functions and stuff, and compiled, it's almost 14 megabytes. It links to Google's dense hash table library and MPIR, which is like GMP for Windows, but I did that in a plain exe and it was a few kilobytes. Why is it so massive? What can I do to reduce its size? It seems like there's other programs which are far more complicated than mine that are far smaller. Compiled with Visual C++, command line is: /Zi /nologo /W3

C++ global variable not initialized when linked through static libraries, but OK when compiled with source

被刻印的时光 ゝ 提交于 2020-01-09 12:52:11
问题 I have created a system that automatically registers function objects (functors) into a map based on the constructor of an global instance. In each cpp file that defines the functor, there's a global instance of the registrar class instance to register the functor to a singleton std::map<int, std::function<...> > object. This is the definition of registrar class: template < typename map_type, typename handler_type > struct registrar { registrar ( map_type& map_object, boost::uint16_t cmd_code

Static library link issue with Mac OS X: symbol(s) not found for architecture x86_64

孤街醉人 提交于 2020-01-09 11:14:06
问题 I'm trying to generate a static library and link it with an execution binary. This is a library function: #include <stdio.h> int hello() { return 10; } With these commands, I could get a static library. gcc -c io.c ar -crv libio.a io.o With lip -info , I checked it is x86_64 architecture. ar> lipo -info libio.a input file libio.a is not a fat file Non-fat file: libio.a is architecture: x86_64 This is the main function that uses the library. #include <stdio.h> extern int hello(); int main(int

Create a Portable Static Library from a Project Based on OpenCV Static Libraries

时光怂恿深爱的人放手 提交于 2020-01-07 07:59:04
问题 I compiled OpenCV 3.x with the Static Libraries options ( -DBUILD_SHARED_LIBS=OFF ). No I have a project built with few functions which uses OpenCV. I want to build my project as a portable static library. By portable I mean I can share it with others to use my functions in their code without the need to install OpenCV. How can I do that on Windows, macOS and Linux? I would like the process to be done using a Compiler in order to extract only the needed objects (Functions) from all OpenCV

Swift link and build with C/C++ library

岁酱吖の 提交于 2020-01-07 02:57:12
问题 I don't have any prior experience with swift. I have a static library libseriallib.a which was written in C++ but has a C wrapper interface by using extern C . I want to link this library into a swift iOS application. I am creating this application from scratch. There are three libraries that libseriallib.a depends on. These are: libz.a , 'libcrypto.a , libssh.a`. I followed the second method mentioned here (Using module) and tried to build the project. However, I am confused how to link the

How does one Create Managed C++ Static Library in Visual Studio (Error C1189)

老子叫甜甜 提交于 2020-01-07 02:17:05
问题 It seems it is not possible to create a static linked library in managed /CLR generated code. I started by creating a C++ /CLR Library which defaulted to a DLL Library. When I change it to Static library (.lib) I get the error: C1189 "Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]" I don't want to include MFC DLL. I have selected Use Standard Windows Libraries so not sure why it thinks I am building MFC

How to include header from self compiled library?

会有一股神秘感。 提交于 2020-01-06 15:07:19
问题 Okay, so I've compiled a simple logger I wrote into a library so I can include it with other projects. But when I try to include the header for that logger, it fails compilation. Here is my Makefile linking the library: CC= clang++ PROG= ./bin/tetris OBJS= ./src/main.o ./src/Tetris.o ./src/states/BaseState.o ./src/states/MenuState.o \ ./src/states/GameState.o LIBS= allegro-5.0 allegro_dialog-5.0 allegro_font-5.0 allegro_ttf-5.0 allegro_color-5.0 CXXFLAGS= -g -Wall -std=c++11 LDFLAGS= $(shell