在Mac OS的架构x86_64上找不到符号时,节点gyp构建失败

时间:2018-08-10 04:12:12

标签: c++ node.js macos ethereum node-gyp

所以我要构建的是一个cpp文件的dylib。

发布如下所示的binding.gyp文件

{
    "targets": [
        {
            "target_name": "loginclient",
            "type": "shared_library",
            "sources": [ "LoginClient.cpp" ],
            'cflags!': [ '-fno-exceptions' ],
            'cflags_cc!': [ '-fno-exceptions' ],
            'conditions': [
                ['OS=="mac"', {
                    'xcode_settings': {
                        'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
                    }
                }]
            ]
        }
    ]
}

我遇到的错误是

Undefined symbols for architecture x86_64:
  "SecureComm::encryptAndSendData(bool, unsigned char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*, unsigned short)", referenced from:
      LoginClient::sendProfile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, unsigned short) in LoginClient.o
  "PackageUtils::toJSON(unsigned char const*, unsigned long, bool, bool, int, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >*)", referenced from:
      LoginClient::sendProfile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, unsigned short) in LoginClient.o
  "KeyServerClient::addKey(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      LoginClient::publishKey(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "KeyServerClient::KeyServerClient(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)",referenced from:
      LoginClient::LoginClient(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "IOUtils::readFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, unsigned long&)", referenced from:
      LoginClient::sendProfile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, unsigned short) in LoginClient.o
  "Session::awaitResponse()", referenced from:
      LoginClient::createAccount(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
      LoginClient::login(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "Session::Session(int, int, KeyServerClient&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const*)", referenced from:
      LoginClient::createAccount(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
      LoginClient::login(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "Session::~Session()", referenced from:
      LoginClient::createAccount(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
      LoginClient::login(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "KeyUtils::loadPublicKey(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      LoginClient::generateKeys(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "KeyUtils::generateKeyPair(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      LoginClient::generateKeys(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
  "KeyUtils::publicKeyToString(evp_pkey_st*)", referenced from:
      LoginClient::generateKeys(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in LoginClient.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/loginclient.dylib] Error 1

我曾尝试将node-gyp降级到1.0.3,这实际上并没有帮助我构建dylib,以便我使用dylib文件是node app 这是文件 https://nodeaddons.com/calling-native-c-dlls-from-a-node-js-web-app/

0 个答案:

没有答案