1

I am creating static library with gcc using: ar rcs libMylib.a objA.o objB.o objC.o

  1. How to add shared libraries to the static library, in other words what is the equivalent to the -lcuda -lopencv_core option when creating static library?

  2. what, if any, is the equivalent to gcc option -Wl,--no-undefined when creating static library?

2
  • 5
    1: You cannot. A static library has no place where linking information can be placed until you link it into a final library/executable. 2: Same answer. You must link before you can check if there are any missing symbols. Commented Oct 3, 2019 at 13:15
  • 1
    1. Your build system should carry over static library linker dependencies to its consumers. Commented Oct 3, 2019 at 13:33

1 Answer 1

1

Static library is an archive (collection) of object files. Therefore, external symbols remain unresolved. Same as when creating a single object file.

Only when you create an executable or dynamic shared library, you'll fail (or get a warning) for unresolved symbols.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.