Consolidated static library of xmake advanced features

2015/12/06 22:08
Reading number 671

The add_files interface of xmake can not only add source code files for compilation, but also directly add *. o/obj object files and *. a/lib library files to the compilation target. This is different from add_links

  • Add_links: Only links can be added, such as - lxxxx. Links can only target executable programs and dynamic libraries, and only link the required code
  • Add_files: directly unpack and repackage all object files in the static library into a new target, which can be a new static library, an executable program, or a dynamic library

For example:

 add_target("test") --Generate static library: libtest. a set_kind("static") --Add Object File add_files("obj/*.o") --Add a static library, repackage the object files in it to libtest. a, and generate a new static library add_files("lib/*.a")

This target module can simply repackage all the static libraries and object files into a new static library without any source code. Of course, it is also possible to add some source files

The type of target is not limited. You can also specify the output as dynamic library: shared, executable program: binary

For example:

 add_target("test2") --Generate dynamic library: libtest2.so set_kind("shared") --Add Object File add_files("obj/*.o") --Add all object files in the static library libtest. a add_files("lib/libtest.a") --Add some source files add_files("src/*.c")

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
zero Collection
zero fabulous
 Back to top
Top