Skip to content

多dll相互调用如何在前端实现交互? #2

Description

@GongYinliang

新建第一个模块,Test,新建一个c++类,Test,导出为Test.dll,code如下:

#pragma once
#include
#include

// Shared library support
#ifdef WIN32
#define EEXPORT __declspec(dllexport)
#define EIMPORT __declspec(dllimport)
#else
#define EEXPORT
#define EIMPORT
#endif

#ifdef TEST_EXPORTS
#define TEST_API EEXPORT
#else
#define TEST_API EIMPORT
#endif

class TEST_API Test
{
public:
Test() { std::cout << "Test()" << std::endl; }
};

新建第二个模块,Test2,新建一个C++类,Test2,依赖第一个模块,导出为Test2.dll,code如下:

.h
#pragma once
#include "Test.h"
class Test2
{
public:
Test2() { Test test; std::cout << "Test2" << std::endl; }

};

.cpp
#include <pesapi.h>
#include
#include <Binding.hpp>
#include "Test2.h"

UsingCppType(Test2);
void Init() {
puerts::DefineClass()
.Constructor()
.Register();
}

PESAPI_MODULE(Test2, Init)

node测试js Test.dll和Test2.dll都在Bin目录下:

const puerts = require("puerts");

let Test2Object = puerts.load('../Output/Bin/Test2');
const Testobject = Test2Object.Test2;
const obj = new Testobject();

报错信息:
Error: dlopen fail for ..\Output\Bin\Test2.dll, error: Win32 error 126
at Object.load (E:\code\PIE-Cloud\PIE-Earth\PIE-Earth-SDK\PIE-Earth\jni\Runtime\PIEEarth-NodeJS\node_modules\puerts\lib\puerts_node.js:28:38)
at Object. (E:\code\PIE-Cloud\PIE-Earth\PIE-Earth-SDK\PIE-Earth\jni\Runtime\PIEEarth-NodeJS\js\test.js:4:26)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions