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.
unix-ar
180
questions
1
vote
1
answer
251
views
Combining two static libraries into one dynamic library whilst avoiding multiple definitions
Note: This is not a duplicate question, because no other answer considers multiple definition challenges.
I am trying to combine two static libraries into one. (This works).
Then convert that static ...
1
vote
1
answer
986
views
'illegal option -- U' when running the ar command from a Makefile compiling C code
I am running macOS X Catalina and trying to run the 'Make' file, but it tells me the following:
(base) charliesharpe@MacBook-Pro alterbbn_v2.2 % make
AlterBBN v2.2 - A. Arbey, J. Auffinger, K. ...
0
votes
0
answers
184
views
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,...
0
votes
1
answer
280
views
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....
3
votes
1
answer
341
views
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 ...
0
votes
1
answer
955
views
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
$...
0
votes
0
answers
65
views
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 ...
0
votes
1
answer
2k
views
How set CMAKE_STATIC_LINKER_FLAGS immediately after the executable file? [tcc -ar]
How set CMAKE_STATIC_LINKER_FLAGS in CMakeLists.txt immediately after the executable file?
for example:
I need:
tcc.exe-arqc staticRun.lib CMakeFiles/staticRun.dir/utils/system.c.obj
but cmake ...
0
votes
1
answer
728
views
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 ...
3
votes
1
answer
267
views
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
│ ...
0
votes
0
answers
26
views
Makefile runs an unspecified command [duplicate]
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/
...
5
votes
1
answer
7k
views
Archive has no index; run ranlib to add one (when linking with a .a containing a MachO64 object file on Linux)
I tried to create a library and test it, but an error occurred.
error code:
./libasm.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
I ...
1
vote
2
answers
248
views
How do I partially-expose object contents in an object library?
I'm compiling some C++ code into a library. Suppose my source files are mylib.cpp and util.cpp. The code in util.cpp is used in the library implementation, but is not part of the library in the sense ...
0
votes
1
answer
81
views
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 ...
1
vote
1
answer
762
views
Combine static libraries in a Makefile using ar [duplicate]
I have a bunch of static libraries and I need to combine into a single file using ar in Makefile.
For example,
ar -M <<EOM
CREATE app.a
ADDLIB lib1.a
ADDLIB lib2.a
ADDLIB lib3.a
....
....
....
...
0
votes
0
answers
32
views
How to merge libraries in linux [duplicate]
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:
# ...
1
vote
1
answer
2k
views
How to force static library to include it dependencies?
I build my own static library with gcc and ar like this.
g++ \
... list of library sources ... \
... a lot of -L -l -I -D options etc... \
-c \
&& ar crf ./lib/libpackager.a *....
1
vote
1
answer
1k
views
How to create one static library from several others static libraries in C on Linux? [duplicate]
For example,
we have three following libraries:
1.1.......................lib_A.a
1.2.......................lib_B.a
1.3.......................lib_C.a
Now I want to create one library ...
2
votes
1
answer
258
views
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 ...
0
votes
0
answers
2k
views
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:
D:\jenkins_node\workspace\new_build_android2\...
6
votes
1
answer
6k
views
Multiple definition within static library
I have a question that is very closely related to Linker does not emit multiple definition error when same symbol coexists in object file and static library, but concerns a slightly different ...
0
votes
0
answers
142
views
CMake execute archiver for each object separately
I want to create a library with a archiver (from arduino, esp8266) in cmake.
add_library(arduino_core STATIC ${CORE_ASM_ITEMS} ${CORE_C_ITEMS} ${CORE_CXX_ITEMS})
These options I have set, specially ...
1
vote
0
answers
289
views
Link OpenSSL FIPS compliant (libcrypto.a) with another static library
I am using OpenSSL 1.0.2t with FIPS Object Module 2.0.16. I have taken the source code and complied both and I have libcrypto.a and libssl.a generated.
In my use case I need libcrypto.a. I have a ...
1
vote
2
answers
619
views
How to remove path to C files and other meta data from static library
I am making a static library from bunch multiple objects placed across directories.
When I run strings on the finally created static library I find that the names of the C files used to create the ...
4
votes
1
answer
1k
views
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 ...
0
votes
0
answers
256
views
Different ways to generate a shared library
I have a source code which depends on some boost libraries like filesystem, system, datetime. I want to create a shared library(libapi.so). Since this so will be given to clients, I don't want a ...
1
vote
0
answers
303
views
Different ways of linking archive
I have an archive named libapi.a which is being generated by makefile.
This libapi.a depends on some of the boost libraries like libboost_system.a, libboost_filesystem.a and libboost_datetime.a
Now in ...
0
votes
1
answer
41
views
Unable to identify issue GNU archiver. Compiling with *.o works but libname.a dosen't
I'm trying to make a static library (.a) but facing issues that I'm unable to understand. So in brief compiling with *.o succeeds but archiving them using ar and then using the .a file to compile ...
1
vote
1
answer
141
views
ar: not keeping file modification times
I have a docker instance running Ubuntu 16.4 LTS. I'm doing C++ builds and using ar/ranlib to produce my .a files. This is losing file modification times.
This is my Makefile rule to manage the ...
0
votes
0
answers
164
views
While building rocket-tools dir (in Rocket Chip setup), getting "ar: illegal option combination" Error
I am new to Rocket chip and trying to install rocket chip and execute simulation but while Creating rocket tool dir in Rocket chip setup as per README.md file, I am getting following error:
ar: ...
3
votes
1
answer
560
views
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 ...
2
votes
0
answers
99
views
C++: ar -x loss symbols
I am not sure if I have some misunderstanding on ar -x command, here's how to repeat the problem:
Step 1. make sure there are symbols are there:
$ nm librocksdb.a | c++filt | grep -s 'rocksdb::...
1
vote
1
answer
357
views
Creating static archives with ar or libtool fails on jailbroken iOS
I'm trying to build and run Go on a self-hosted jailbroken iOS device (Corellium virtual devices). Go bootstraps and can build and run regular binaries. However, Go archives fail to build because ar ...
2
votes
1
answer
467
views
Compiling Poly/ML on MobaXterm: the ar u option
I am to compile the Poly/ML Standard ML compiler on the MobaXterm v11.1 cygwin-based distribution. Upon make, I get
/bin/sh ./libtool --tag=CC --mode=link gcc -O3 -fomit-frame-pointer -fstrict-...
0
votes
0
answers
681
views
When I compiling llvm, /usr/local/bin/ar has too many threads, taking up too much memory
My computer: 4G memory + 4G swap
My cmake parameter:
cmake -G "Ninja" \
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-8.3.0 \
-DCMAKE_CXX_COMPILER=/usr/local/bin/g++-8.3.0 \
-DCMAKE_INSTALL_PREFIX=/usr/...
3
votes
1
answer
1k
views
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:
...
0
votes
1
answer
2k
views
How to split large .a static library?
Is there a possibility to split large .a files into multiple smaller ones?
I'm currently having an issue with a .a file being multiple GiB large and GCC raises an error even with the flag -mcmodel=...
1
vote
1
answer
977
views
hint the dynamic library dependencies in the archive file
In my c/c++ mixed project, I'm building the source files of individual folders, archiving them with ar into their own .a files and then linking them all together at the final stage. So far so good. ...
-1
votes
1
answer
164
views
Why does the linker complain “file was built for archive which is not the architecture being linked” when the architecture is correct?
When trying to build a binary (see MWE below) that links a static library using clang I am getting the following error message:
⟩⟩⟩ clang -o test bar.a test.o
ld: warning: ignoring file bar.a, file ...
1
vote
2
answers
546
views
Override command for make from outside
I have several dirs with files stamp1.txt and stamp0.txt, and i want override cat command. I need it for example to suppress 'stamp1' files from archiving into library.
So i wrote little filter ...
-1
votes
1
answer
3k
views
How to limit the visibility of an exported symbol? [closed]
I'm compiling and archiving a library (call it libbar.a). The key translation units in that library use a function void foo() defined (non-statically) in a foo.cpp which also gets compiled and put in ...
5
votes
2
answers
4k
views
CMake append objects from different CMakeLists.txt into one library
I would like to create a single library from objects from multiple sub-directories, each one containing their own CMakeLists.txt with OBJECT library trick to have multiple targets with different ...
2
votes
1
answer
565
views
deterministic mode in ranlib in gnu utilities
i was reading about ranlib that update the index or generates an index of contents of an archive
here
in the option that you can provide to ranlib there is -D
and -U
i read the definition but i ...
0
votes
1
answer
423
views
Can compile and link use different compilers when cross-compile?
I'd like to know if I can use different compilers for compile and link.
For example ,I have two files ,a.c and b.c,
I use clang to compile a.c and b.c:
clang -c a.c -o a.o
clang -c b.c -o b.o
and ...
3
votes
1
answer
3k
views
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 ...
0
votes
0
answers
431
views
Cygwin ar requires elevation
I am using Eclipse Oxygen.2 Release (4.7.2) x64, Cygwin 2.9.0 x64 on Windows 7 Enterprise x64 (I'm at work).
When trying to compile a simple hello-world project all works fine, so having verified ...
45
votes
1
answer
17k
views
what is the difference between ranlib, ar, and ld for making libraries
To make libraries in c++/unix from *.o files, I have noticed two different ways in my project (legacy code):
ar qc libgraphics.a *.o
ranlib libgraphics.a
and
ld -r -o libgraphics.a *.o
What is the ...
6
votes
1
answer
2k
views
Autoconf uses wrong AR on OS X
I'm testing on OS X. We have a configure.ac and Makefile.am. Autotools is selecting the wrong AR and ARFLAGS for the platform. It happens with (and without) AM_PROG_AR in Makefile.am:
$ egrep 'AR =|...
2
votes
1
answer
1k
views
How to determine where 'ar' is being called in Makefile?
I'm trying to build Git on OS X. Git depends on libidn2. libidn2 2.0.0 fails:
make all-am
make[3]: Entering directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
CC idna.lo
CC ...
13
votes
1
answer
7k
views
building static library that depends on another static library
I have a case where there are two libraries lib1 and lib2. lib2 has dependencies on lib1. In my case lib2 is basically a high level wrapper around the functions inside lib1.
The final application is ...