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
1
vote
2 answers

Is it not allowed create a static library without a .c file in it?

I have two files -> fact.h and main.c in the /home/snyp1/new folder. main.c has the main function which calls the fact(int x) function in fact.h. I am creating a .a archive with the ar command -> snyp1@Snyp:~/new$ ar -r -s libfact.a fact.o ar:…
Andariel
  • 133
  • 4
  • 9
1
vote
1 answer

Issue including library C++

I have a very simple C++ file Multiplier.cpp with the corresponding header file, from which I have created a library using the following commands $ g++ -o Multiplier.o -c Multiplier.cpp $ ar cr libMultiplier.a Multiplier.o In a new directory, I…
luketorjussen
  • 3,156
  • 1
  • 21
  • 38
0
votes
2 answers

g++ combining libraries

So, I'm trying to incorporate the libpthread.a library into my own library. But its giving me linker problems when I try and compile the code that uses it. I compile it by doing the following: g++ foo.cpp foo.o ar x /usr/lib/libpthread.a ar rcs…
poy
  • 10,063
  • 9
  • 49
  • 74
0
votes
2 answers

Include static lib in shared object?

I would like to compile a bunch of static libs into a shared object. So far I have g++ -Wl -shared -fPIC -o myshared.so objs/*.o Where the objs/*.o above contains all the object files extracted from the various static libs using ar. UPDATE:…
chriskirk
  • 761
  • 1
  • 11
  • 22
0
votes
1 answer

Trouble compiling a program using an archive (.a)

When I try to compile my file using a library (.a), I get 'fatal error: URLInputStream.h: No such file or directory compilation terminated. '. I'm still pretty new to C++, and this seems so simple but I can't get it to work. Compilation commands…
Levi Morrison
  • 19,116
  • 7
  • 65
  • 85
0
votes
2 answers

Native toolchain issue on Macos 10.6.8 (Snow Leopard)

Below is the description of the issue. I marked it all as a code to avoid the implicit formatting that StackOverflow does. That is pretty annoying to have to deal with the Wiki-like markup language when I know exactly myself how I want to format my…
0
votes
0 answers

Codelite C++ build suddenly not working. ar can't find GL

I've been writing a mediocre game engine using SFML and OpenGL. Up until recently it has been building without difficulties, except for my own typos, bad code, etc. I'm building it as a static library, so (as I understand it, please correct me if…
Hal Gee
  • 65
  • 2
0
votes
1 answer

Converting .o file into static library in linux and make it usable in terminal

I want to create a simple library and after compilation and ar command I can get resulting .a file. Now I want to add this file as a static library and use it in terminal, I dont know if its possible. but idea is from other library named Ctypes.sh…
user786
  • 3,902
  • 4
  • 40
  • 72
0
votes
1 answer

How to update shared library file

I'm trying to add a .lo object file compiled through libtool with clang into a shared library file. $ libtool --tag=CC --mode=compile clang -c newobject.c -shared Is there an equivalent command to $ ar r libmylib.a newobject.o for shared…
wyphan
  • 216
  • 3
  • 12
0
votes
0 answers

Static library with MinGW doesn't update correctly when building executables

I made a little makefile to build a static library made of several object files. Then I made a test program test.exe and I built it with the same makefile. Executable is made of test.c and the static library to test. When I change one function in…
MaxC
  • 885
  • 7
  • 21
0
votes
1 answer

problem with ar, linking and undefined reference

I have a software package consisting of some 500+ fortran .f files. It is rather well organized into various subfolders, and there is one high level compile script which calls the various Makefile's within the subfolders. Using the PGI compiler, I…
ron
  • 967
  • 6
  • 23
0
votes
0 answers

Makefile runs an unspecified command

I have a makefile that compiles C source files into corresponding object files and then archives those object files. This is what the makefile looks like:- .PHONY = all clean fclean re SRC = ./src/ INC = ./inc CC = gcc CFLAGS = -I${INC} -Wall…
mubu43
  • 1
0
votes
1 answer

How to handle lib dependency while compiling?

Let's say that I have two static libraries : libA and libB and that libB uses libA. For each library libX let's say that hX is libX's headers's directory and dX is libX's file's directory. Now what happen when a user of libB wants to compile a…
Dadam42
  • 65
  • 6
0
votes
0 answers

How to merge libraries in linux

Recently I wanted to build a game engine using C++ and glfw3. I want to create a static library libengine.a and link it with libglfw3.a and its dependencies. My question is how can I replace this: # add paths. use pkg-config --static --libs glfw3 to…
Dragomir
  • 43
  • 1
  • 6
0
votes
0 answers

NDK build issue: aarch64-linux-android-ar.exe xxx.cpp.o: No such file or directory

Background: I'm building a gradle project with linked C++ project (external native build). In that procedure, an unexpected error happened:…
zwcloud
  • 4,546
  • 3
  • 40
  • 69