Combining static libraries

后端 未结 3 1745
[愿得一人]
[愿得一人] 2020-12-13 07:44

Suppose I have three C static libraries say libColor.a which depends on *libRGB.*a which in turn depends on libPixel.a . The library l

3条回答
  •  忘掉有多难
    2020-12-13 08:09

    1/ Extract ALL of the object files from each library (using ar) and try to compile your code without the libraries or any of the object files. You'll probably get an absolute bucket-load of undefined symbols. If you get no undefined symbols, go to step 5.

    2/ Grab the first one and find out which object file satisfies that symbol (using nm).

    3/ Write down that object file then compile your code, including the new object file. You'll get a new list of undefined symbols or, if there's none, go to step 5.

    4/ Go to step 2.

    5/ Combine all the object files in your list (if any) into a single library (again with ar).

    Bang! There you have it. Try to link your code without any of the objects but with the new library.

    This whole thing could be relatively easily automated with a shell script.

提交回复
热议问题