Questions tagged [unix-ar]

The Unix archiver utility, used primarily for maintaining static libraries. For questions about augmented reality, use [augmented-reality], not this tag.

This tag is for questions about the Unix archiver utility, commonly known as "ar". It is used to maintain groups of files as a single file, known as an archive. Today, it is primarily used to create and maintain static libraries in conjunction with a linker.

For more information on ar, see Wikipedia.

NOTE: Do not use this tag for questions about augmented reality! The tag should be used instead.

181 questions
3
votes
1 answer

How to take only required object files inside a single (.a) archive

Just a simple question but I couldn’t found the answer anywhere. When putting all object files in archive, how to instruct clang++ to only take required objects file for linking in order to avoid undifined symbols errors because of symbols not…
user2284570
  • 2,891
  • 3
  • 26
  • 74
3
votes
2 answers

clang makefile "ar: no archive members specified"

I refactor some C code and I try to compile it as a lib on clang on mac instead of gcc on linux. First of all if I just run make command I got an error at the first file compile: +++ Compiling [sys_msg.c] clang: error: unsupported argument…
3
votes
0 answers

Link with archive that contains other static library archive files

I am trying to use the NBIS library from NIST: http://www.nist.gov/itl/iad/ig/nbis.cfm NBIS is composed of several different related libraries that they compile into multiple archive files. They give you an option when installing it to install…
plasmoidia
  • 604
  • 6
  • 15
3
votes
1 answer

Object files not properly added to archive on mac

I am trying to build an archive from a collection of object files. I am doing this with ar -rs my_archive.a foo.o bar.o other_object_files.o. On a linux machine everything is fine but when I try the very same command on my mac it seems like only…
Manfredo
  • 1,760
  • 4
  • 25
  • 53
3
votes
1 answer

Is there a way to see the functions inside a C/C++ archive (.a)?

We have a situation where (simplified): test() exists in source.c source.c compiles to object.o object.o gets linked into archive archive.a archive.a gets compiled into final binary We are attempting to change the name of test() to something else.…
JoshuaJ
  • 929
  • 1
  • 9
  • 22
3
votes
1 answer

How do I add objects with a custom extension to a cmake library?

I'd like to add some object files to a CMake static library, but they have a custom extension. Here's what I've tried: set(SRCS testfile.cxx jsobj.js) add_library(testlib STATIC ${SRCS}) When made, CMake invokes ar testfile.cxx.o (ie the other file…
Nicholas Wilson
  • 9,435
  • 1
  • 41
  • 80
3
votes
3 answers

Linking static lib with other static libs

I'm writing a static lib that needs to handle XML. I want it to include everything that is necessary out of the box but I don't know how to make other static libs link to it, namely libxml2. I pass the -c flag to gcc to generate .o that ar then uses…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
3
votes
1 answer

libtool vs ar for creating a static library (xcode linker)

Creating a static library on Mac 10.5 with xcode via libtool and with ar via the command line both generate a libMainProject.a file however, when trying to use the one generate by libtool to link into a xcode application I end up with multiple…
Allen
  • 71
  • 1
  • 3
3
votes
2 answers

How do I extract object files from an iOS library (on a Mac)?

I have a third party iOS library that links and runs fine in my app and in the simulator. I am trying to extract the object files from it in order to integrate it with another piece of third party software that repackages the object files with their…
Ian Terrell
  • 10,667
  • 11
  • 45
  • 66
3
votes
1 answer

Android : merging static libraries into single one

I use Android NDK r8 to generate multiple static libraries with include $(BUILD_STATIC_LIBRARY) and I successfully get : lib1.a, lib2.a, lib3.a, etc. Now I would like to merge these static libraries into single one. I try do it with ar.exe from…
TheFrancisOne
  • 2,667
  • 9
  • 38
  • 58
3
votes
0 answers

Trying to merge two static libraries

I have the problem that I want to have a static library of my code because I use the code a lot. It's c++ (otherwise a shared would be an other choice). But that code depends on other static libs. Due to that I came to the point that I can't link a…
Joshua Behrens
  • 818
  • 13
  • 23
3
votes
2 answers

MinGW-w64's ar.exe can't find libraries when trying to build a static library

I've now been trying to get MinGW-w64 to work on my system for several days, mainly because it has a more recent GCC version, but I either set things up wrong or there's some strange problem with MinGW-w64 itself. I've now downloaded…
Lukas
  • 2,461
  • 2
  • 19
  • 32
3
votes
3 answers

specialized member function lost after linking thru ar

Consider the following minimal example which reproduces a problem in a much bigger project: spec.h: #include class A { public: template T test(const std::string& a) { std::cout << "DEFAULT CALLED WITH " <<…
Alex Kremer
  • 1,876
  • 17
  • 18
2
votes
1 answer

GNU Make: Using the wildcard function with implicit rules

I have a project structure that looks something like this: . └── src ├── Module1 │   ├── source1.cc │   ├── source2.cc │   └── source3.cc ├── Module2 │   ├── source1.cc │   ├── source2.cc │   └── source3.cc └──…
John Leuenhagen
  • 576
  • 7
  • 23
2
votes
1 answer

Mix multiple objects files with gcc which have no main function

i try to mix files . For example , if i have file1.o and have file2.o , all of them don't have main function , then le1_file2.o is the result of those files . So i have used 2 things : Using of linker and…
ledoux
  • 91
  • 9