修改编译脚本
This commit is contained in:
parent
970e87bb03
commit
ff4bd9cd85
@ -38,7 +38,7 @@
|
||||
},
|
||||
"nativeLib": {
|
||||
"debugSymbol": {
|
||||
"strip": true,
|
||||
"strip": false,
|
||||
"exclude": []
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,8 +61,9 @@ find_library(GLES-lib GLESv3)
|
||||
#System so
|
||||
set(SYSTEM_LIBS
|
||||
libace_napi.z.so libnative_window.so
|
||||
hilog_ndk.z ace_ndk.z uv
|
||||
hilog_ndk.z ace_ndk.z uv z
|
||||
)
|
||||
|
||||
# 链接系统库
|
||||
target_link_libraries(opencax PUBLIC ${SYSTEM_LIBS})
|
||||
target_link_libraries(opencax PUBLIC
|
||||
|
||||
@ -142,8 +142,8 @@ static napi_module OpenCAXModel = {
|
||||
.reserved = { 0 }
|
||||
};
|
||||
|
||||
//extern "C" __attribute__((constructor))
|
||||
//void RegisterOpenCAXModule(void)
|
||||
//{
|
||||
// napi_module_register(&OpenCAXModel);
|
||||
//}
|
||||
extern "C" __attribute__((constructor))
|
||||
void RegisterOpenCAXModule(void)
|
||||
{
|
||||
napi_module_register(&OpenCAXModel);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
|
||||
import fs from '@ohos.file.fs';
|
||||
import fileIO from '@ohos.fileio';
|
||||
import { Context } from '@kit.AbilityKit';
|
||||
//import OCCTRender from 'libocctrender.so';
|
||||
//import NaviteOCCT from 'libopencax.so';
|
||||
|
||||
const DOMAIN = 0x0000;
|
||||
const TAG = 'ModelView';
|
||||
@ -19,18 +19,6 @@ export struct ModelView {
|
||||
aboutToAppear() {
|
||||
this.copyRawFileToSandbox();
|
||||
}
|
||||
async loadNativeLibrary() {
|
||||
try {
|
||||
let NaviteOCCT = await import("libopencax.so")
|
||||
console.info(`[NDK] 模块类型: ${typeof NaviteOCCT}`);
|
||||
console.info(`[NDK] 模块值: ${JSON.stringify(NaviteOCCT)}`);
|
||||
console.info(`[NDK] 所有属性: ${Object.keys(NaviteOCCT).join(', ')}`);
|
||||
if (!NaviteOCCT) throw new Error("模块为 undefined");
|
||||
} catch (e) {
|
||||
console.error(`[NDK] 加载失败: ${e.message}`, e);
|
||||
// 此处会触发你看到的错误
|
||||
}
|
||||
}
|
||||
async copyRawFileToSandbox() {
|
||||
try {
|
||||
const context = getContext(this);
|
||||
@ -70,8 +58,17 @@ export struct ModelView {
|
||||
hilog.error(0x0000, 'ModelView', `LoadModel Failed: ${JSON.stringify(e)}`);
|
||||
}
|
||||
})
|
||||
Button('测试模块加载').onClick(async()=>{
|
||||
this.loadNativeLibrary();
|
||||
Button('测试模块加载').onClick(()=>{
|
||||
try {
|
||||
let NaviteOCCT = import("libopencax.so")
|
||||
console.info(`[NDK] 模块类型: ${typeof NaviteOCCT}`);
|
||||
console.info(`[NDK] 模块值: ${JSON.stringify(NaviteOCCT)}`);
|
||||
console.info(`[NDK] 所有属性: ${Object.keys(NaviteOCCT).join(', ')}`);
|
||||
if (!NaviteOCCT) throw new Error("模块为 undefined");
|
||||
} catch (e) {
|
||||
console.error(`[NDK] 加载失败: ${e.message}`, e);
|
||||
// 此处会触发你看到的错误
|
||||
}
|
||||
})
|
||||
Button('测试so是否存在').onClick(()=>{
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user