static-libraries

Building static libraries on Mac using CMake and GCC?

浪子不回头ぞ 提交于 2019-11-27 17:37:15
问题 Greetings all, I have a static library which I later link with my application. My development environment is CMake, GCC (Linux, Mac), MinGW (Windows). I can compile the static library without any problem on Linux and Windows. (I can even build shared libraries in my application on Mac). EDIT: I compiled the library as a SHARED library and it worked fine!! I have configured CMakeFile as follows to build the static library: add_library(centi STATIC ${base_srcs} ${crv_srcs} ${node_srcs} ${trnk

How to build an Objective-C static library?

瘦欲@ 提交于 2019-11-27 17:36:17
I have some Objective-C classes, which I am currently using in both a Cocoa application (Mac OS X) and a Cocoa-Touch application (iOS). Currently, when I update those classes, I have to copy those updated .h and .m files to both projects. Not that big of deal, but I'm going to be using them in many more projects. So, I want to build these classes into an Objective-C static library. And then link against that library in all other projects. Is there a way to build a static library such that it works with both Cocoa and cocoa-touch applications? I've tried just building a Cocoa static library

Using a static library in Qt Creator

前提是你 提交于 2019-11-27 17:31:31
I'm having a hell of a time finding documentation which clearly explains how to use a static library in Qt Creator. I've created and compiled my static library using Qt Creator (New=>Projects\C++ Library=>Set type to "Statically Linked Library"). It compiles and spits out a ".a file". The problem I encounter is when I try to use the library. I have another project that would like to use it (#include files in the library, etc) but I don't know the proper way to link with the library or include files from the library. LIBS += -L[path to lib] -l[name of lib] Note! that filename of lib: lib

Trying to include a library, but keep getting 'undefined reference to' messages

旧城冷巷雨未停 提交于 2019-11-27 17:26:21
I am attempting to use the libtommath library. I'm using the NetBeans IDE for my project on Ubuntu linux. I have downloaded and built the library, I have done a 'make install' to put the resulting .a file into /usr/lib/ and the .h files into /usr/include It appears to be finding the files appropriately (since I no longer get those errors, which I did before installing into the /usr directories). However, when I create a simple main making a call to mp_init (which is in the library), I get the following error when I attempt to make my project: mkdir -p build/Debug/GNU-Linux-x86 rm -f build

Release mode static library much larger than debug mode version

风流意气都作罢 提交于 2019-11-27 17:24:32
问题 today i found out that the compiled static library i'm working on is much larger in Release mode than in Debug . I found it very surprising, since most of the time the exact opposite happens (as far as i can tell). The size in debug mode is slightly over 3 MB (its a fairly large project), but in release it goes up to 6,5 MB. Can someone tell me what could be the reason for this? I'm using the usual Visual Studio (2008) settings for a static library project, changed almost nothing in the build

How to build a library for both iPhone simulator and device?

好久不见. 提交于 2019-11-27 17:08:15
I want to build a static library for iphone. I want to give my users the .a library which they can use for both simulator test and device test. Do I have to build two library in simulator mode and device mode? Is there any way to build a single one that can be used for both platforms? Jasarien Compile your library twice. Once using the device SDK, and again using the Simulator SDK. Then use the lipo command line tool to create a "fat" library. lipo -create libdevice.a libsimulator.a -output libcombined.a That should give you what you need. 来源: https://stackoverflow.com/questions/2996235/how-to

g++ linker: force static linking if static library exists?

限于喜欢 提交于 2019-11-27 16:59:52
I've a program which links to many libraries. g++ , by default, prefers to link to shared libraries, even if the corresponding archive exists. How can I change this preference to prefer static archives over dynamic libraries, if a static archive exists? Note, I used -static option, but it tries to find static archive for all libraries which is not what I want. naideflan g++ -Wl,-Bstatic -lz -lfoo -Wl,-Bdynamic -lbar -Wl,--as-needed Will link zlib and libfoo as static, and libbar as dynamic . --as-needed will drop any unused dynamic library. stanthomas When you only want to statically link one

After update to Xcode 5 - ld: symbol(s) not found for architecture armv7 or armv7s linker error

 ̄綄美尐妖づ 提交于 2019-11-27 16:53:37
I just updated my iPhone 4S software to iOS 7 Beta 2 while I was in the middle of putting the final touches on a new app (Phonegap).. not a good idea! After it was done Xcode didn't detect my iPhone so I installed Xcode 5 beta. After tinkering around with it I finally got it to detect my phone. The only problem now is there is an error with the architecture used. Here are the errors being produced: ld: warning: ignoring file /Users/-----------/Library/Developer/Xcode/DerivedData/testtest-bmnbmujiosugcmgeiceofgcfmsec/Build/Products/Debug-iphoneos/libCordova.a, file was built for archive which

How do I include a statically linked library in my Eclipse C++ project?

爷,独闯天下 提交于 2019-11-27 16:44:07
问题 I have an open-source library that's distributed in source form. After I run the Makefile, I end up with a .h file and a .a file that I then want to include in a project that I'm working on. I'm familiar with how I can add these by editing a Makefile manually or by invoking the compiler from the command line, but I'm not sure how I can add these to my Eclipse C++ project, created using the CDT. I'm currently using Eclipse Indigo. I found some instructions for older versions of Eclipse, but

Can I build a shared library by linking static libraries?

我怕爱的太早我们不能终老 提交于 2019-11-27 14:51:01
问题 I have a bunch of static libraries (*.a), and I want to build a shared library (*.so) to link against those static libraries (*.a). How can I do so in gcc/g++? 回答1: You can (just extract all the .o files and link them with -shared to make a .so ), but whether it works, and how well it works, depends on the platform and whether the static library was compiled as position-independent code (PIC). On some platforms (e.g. x86_64), non-PIC code is not valid in shared libraries and will not work