All Questions
31
questions
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 ...
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 ...
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
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 ...
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=...
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 ...
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 ...
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 ...
2
votes
1
answer
1k
views
ar on MSYS2 shell receives truncated paths when called from Makefile?
I'm using git-bash.exe from a PortableGit install, with environment variables from a different MinGW. So I have:
WORKGROUP+user@AD-X MINGW32 /z/user/Downloads
$ which ar
//WORKGROUP.EX.COM/Users/user/...
3
votes
1
answer
688
views
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 ...
2
votes
1
answer
1k
views
gcc archives not considered when linking?
Should it make a difference whether a gcc linker links archive files or object files (or both)?
Background:
In an embedded project, an ISR (which is of course not referenced by any other source code)...
0
votes
1
answer
370
views
link a library I wrote with pthread library
This is actually part of an assignment. Basically, we need to write a library, which will be linked against test programs the professor writes, like so:
gcc -o libexample.o -c libexample.c
ar rvs ...
7
votes
2
answers
5k
views
Do I need "ranlib" / "ar -s" for static linking?
I did not find any proper information if and why I need ranlib / ar -s for static linking.
Assume I have an application that consists of multiple modules. Each module has its code files in its own ...
2
votes
1
answer
1k
views
basic use of C archives (libraries) with clang linker
I have a main program:
#include <stdio.h>
extern int a;
int main (int argc, char ** argv) {
int i;
printf ("Hello %p, %p\n", & i, & a);
return 0;
}
and a separate file, foo....
1
vote
1
answer
427
views
trouble compiling against static library
I have created a static library, libstuff.a, with gcc and ar. I've installed the library in /custom/lib/dir/ and the header files in /custom/include/dir/. When I try to compile another application ...