目录

Quick Link to a Pre-built Library

Hvigor provides the quick link feature for you to use the native-related .so library and .h or .hpp interface file in a dependent module in your project.

Header Files

Pre-built Library

If the .so library in a shared package or local dependent module is referenced in your project, Hvigor will generate CMake config-file packages during compilation and automatically import the .so library through CMake find_package. You only need to declare the library link in ${moduleName::soName} format in the CMakeLists.txt script, where moduleName indicates the dependent module name and soName indicates the .so library name.

For example, in the oh-package.json5 file, add the dependency on the curl shared package that contains libcurl.so:

// oh-package.json5
"dependencies": { 
  "curl": "1.0.0" 
}

Declare the link in the CMakeLists.txt script of the project:

// CMakeLists.txt
add_library(entry SHARED napi_init.cpp)
# ${moduleName::soName}.
target_link_libraries(entry PUBLIC curl::curl)

For a local module, an HAR exposes only the .so libraries built by the module, while an HSP exposes not only the .so libraries built by the module but also those on which the module depends.