Merge static library

ruki edited this page Jul 1, 2016 · 1 revision

We not only can add source code files and also add some object(.o)/library(.a) files to the target directly for the api: add_files

It is different with another interface: add_links

  • add_links:It only links library, .e.g -lxxxx and it's target is only binary program and share library.
  • add_files:It will merge the static library into the target.

####Example

target("test")
    
     -- create static library: libtest.a
     set_kind("static")

     -- add source files to the libtest.a
     add_files("src/*.c")

     -- add object files to the libtest.a
     add_files("obj/*.o")

     -- merge static librarys to the libtest.a
     add_files("lib/*.a")

And the target kind also can be binary or shared

target("test2")
    
     -- create a shared library: libtest2.so
     set_kind("shared")

     -- add object files to the libtest2.so
     add_files("obj/*.o")

     -- merge libtest.a to the libtest2.so, but not link
     add_files("lib/libtest.a")

     -- add some source files
     add_files("src/*.c")
Clone this wiki locally
Clone in Desktop
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.