0

Our code is linking to a number of libraries. I place a compiled libfoo.a into relative directory libs, and write:

g++ mycode -L libs -lfoo

to my surprise, the executable size does not change. So I ran ldd and found that the original library iss still linked dynamically. It's in /usr/lib/xxx

How do I specify that the static library take precedence over the dynamic one in the system libraries?

Dov
  • 7,218
  • 7
  • 42
  • 64
  • dup of https://stackoverflow.com/questions/6578484/telling-gcc-directly-to-link-a-library-statically (g++ shares options with gcc) – PaulProgrammer Jun 12 '19 at 01:18

1 Answers1

0

Use -static before your linker options

BugSquasher
  • 307
  • 1
  • 13