I have Class xxx.cpp
which can be converted to a static library instead of creating a shared object to improve the performance of the system. Hence please provide the steps to convert it from .so
to .a
.
Asked
Active
Viewed 3,349 times
0

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

trunks
- 11
- 1
- 2
-
4If you have the source, can't you just compile it as a static library? – Cornstalks May 08 '16 at 05:07
-
There is no "converter" from *shared* to *static* libraries. They are different ways of *compiling* a library. A *static* library is created with e.g. `ar -cvq foobar.a foo.o bar.o`. A shared library is created via `gcc -shared ...`. The steps to covert is simply to recompile as a static lib. – David C. Rankin May 08 '16 at 06:40
1 Answers
1
No conversion
is required here since you have the source file xxx.cpp
You may
Create the library first
g++ -static -c xxx.cpp -o xxx.o # use g++ instead of gcc ar -rcs libxxx.a xxx.o
Link to the library like below
g++ -static somefile.cpp -o somefile.elf -L/path/to/libxxx.a -lxxx

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

sjsam
- 21,411
- 5
- 55
- 102