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
5
votes
1 answer

Linking to thin archive on Snow Leopard

I am attempting to link a thin archive that combines two archive libraries to a C program. I constructed two simple hello world functions and built an archive with the commands: ar rcs lib1.a lib1.o ar rcs lib2.a lib2.o The two archives are then…
Eldila
  • 15,426
  • 23
  • 58
  • 62
4
votes
1 answer

Merge multiple static libraries into one GCC scons

I'm building this library, libmyproject.a I want it to include several other static libraries (libone.a and libtwo.a), so that the application that links with libmyproject doesn't have to link with libone and libtwo as well. I'm new to the GCC…
Florin
  • 2,891
  • 4
  • 19
  • 26
4
votes
1 answer

What does it mean to 'add an index to an archive file'?

My C textbook creates an archive using the -s command line option which adds an index to the following archive file. ar -rcs libfile.a file1.o file2.o However, I don't understand what an index is or it's purpose?
duper21
  • 399
  • 3
  • 10
4
votes
1 answer

Make a multi architecture static library in C

I'm working on Ubuntu and I've made a static c library following the instructions on this site. But the resulting .a package works only on the machine where it has been compiled. I know that an .a archive contains object files (only one in my case),…
Lucide
  • 69
  • 1
  • 10
4
votes
1 answer

Attempting to compile with my own static C library

I compiled a static library. I have two files. mylib_1.c with function foo1 in it mylib_2.c with function foo2 in it. Both #include "mylib.h". I compiled a library like so: gcc -c mylib_1.c -o mylib_1.o gcc -c mylib_2.c -o mylib_2.o ar cr mylib.a…
DEADBEEF
  • 525
  • 1
  • 5
  • 19
4
votes
1 answer

Building GCC-4.9.2 on OS X Yosemite

Ok, I'm having trouble building gcc-4.9.2 on Apple's new OS X Yosemite. I'm not sure if I need to be building a gnu-gcc compiler on OS X, as most other software has compiled fine, apart from tesseract-3.0.1 and some of my own wxWidgets applications.…
Python Kid
  • 313
  • 2
  • 7
  • 19
4
votes
1 answer

Limiting the scope of global symbols from linked objects

I have a C library in an archive file, clib.a. I've written a C++ wrapper for it, cpp.o, and would like to use this as a static library: ar cTrvs cppwrap.a clib.a cpp.o Code which links to this won't be able to use the stuff from clib.a directly…
CodeClown42
  • 11,194
  • 1
  • 32
  • 67
4
votes
1 answer

cmake os x failure ar no archive members specific

I have a simple cmake project going that I can't get to compile on OS X 10.8.4. The cmake/make process works great on Linux but on OS X I am getting this error: Linking CXX static library libImageFilter.a ar: no archive members…
jmerkow
  • 1,811
  • 3
  • 20
  • 35
4
votes
1 answer

Detect whether static library is a thin archive

When linking a static library as a thin archive the .o-files are not copied into the archive, but rather they are referenced with their relative path from the .a file. How can I check if a given .a file is a thin archive or not?
vidstige
  • 12,492
  • 9
  • 66
  • 110
4
votes
1 answer

How to resolve the GHC error "Unknown PEi386 section name `.idata$4' " on Windows?

I recently found out that instructions I had written to compile HDBC-postgresql on Windows were no longer working with Haskell Platform 2012.2.0.0. The library builds alright, but when attempting to link the built library, cabal fails with: Loading…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
4
votes
2 answers

When making a library on unix, is anything but "ar rcs" necessary?

I have a number of source files I want to agglomerate into a .a file. I make the library with the command ar rcs libcathat.a thing1.o thing2.o fish.o I then attempt to link to this library with the same compiler I used to make the .o files (g++): …
Dan
  • 12,157
  • 12
  • 50
  • 84
3
votes
1 answer

ar introduces undefined reference

I'm trying to figure out how to use static libraries, but the most trivial example fails: //foo.c int func(int i) { return i+1; } //main.c int func(int i); int main() { return func(41); } Compiling foo.c and main.c works: gcc -Wall -o foo.o -c…
bitmask
  • 32,434
  • 14
  • 99
  • 159
3
votes
1 answer

hit roadblock while trying to compile lua for emscripten usage, using windows, "unable to find ar rcu"

i've been stuck on this problem for hours, without finding any solutions. I'm currently trying to compile lua 5.3.4 for Emscripten for use in my project. ive hit a roadblock thought, I need to compile it to a liblua.a file which ill later use when…
Free Renca
  • 83
  • 1
  • 7
3
votes
1 answer

How to combine multiple static libraries when the library name contains a space?

I am working on various flavors of Linux and I need to combine multiple static libraries such as foo1.a foo bar.a foo2.a into one single combo static library (note that the second file has a space in it's name). I've seen stackoverflow articles…
John Rocha
  • 1,656
  • 3
  • 19
  • 30
3
votes
1 answer

ar command does not produce index when combining static libraries

I am trying to follow the answer given here to combine multiple static libraries into a single archive under MinGW64. Specifically, I use CMake and specify the following command: add_custom_command( OUTPUT ${COMBINED_CORE_LIB_NAME} …
Egor
  • 779
  • 5
  • 20
1 2
3
12 13