如果通过源码编译会在build文件夹下得到一系列的.a库,但是onnxruntime默认将其链接成动态链接库,可以通过如下方式生成静态链接库
在build文件夹里创建文件merge.mri
create libonnxruntime.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_common.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_framework.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_graph.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_mlas.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_optimizer.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_providers.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_session.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime_util.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/onnx/libonnx.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/onnx/libonnx_proto.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/lib/libgmock.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/lib/libgtest.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/external/nsync/libnsync_cpp.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/external/re2/libre2.a
addlib /workspace/ygao/software_backup/onnxruntime/build/Linux/RelWithDebInfo/external/protobuf/cmake/libprotobuf-lite.a
save
end
之后在build里执行
ar -M < ./run.mri
即可得到libonnxruntime.a