Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.0 compiler errors #147

Closed
corymickelson opened this issue Sep 28, 2017 · 10 comments
Closed

1.0.0 compiler errors #147

corymickelson opened this issue Sep 28, 2017 · 10 comments

Comments

@corymickelson
Copy link
Contributor

Hello, just updated to the 1.0 version. I am getting some errors though that I am not sure how should be handled.

[0/1] Re-running CMake...
-- Boost found: 1.64.0 /home/skyslope/CMakeProjects/npdf/boost-cmake/boost/boost_1_64_0
-- Boost found: 1.64.0 /home/skyslope/CMakeProjects/npdf/boost-cmake/boost/boost_1_64_0
-- Found the following ICU libraries:
--   uc (required)
--   dt (required)
--   i18n (required)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/skyslope/CMakeProjects/npdf/build
[2/17] Building CXX object CMakeFiles/npdf.dir/src/NObject.cc.o
FAILED: CMakeFiles/npdf.dir/src/NObject.cc.o 
/usr/bin/clang++  -DBOOST_ALL_NO_LIB=1 -DBOOST_DISABLE_ASSERT -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_PROVIDES_EXECUTORS -DBOOST_THREAD_USES_CHRONO -DBOOST_THREAD_VERSION=4 -Dnpdf_EXPORTS -I/home/skyslope/.cmake-js/node-x64/v8.4.0/include/node -I../node_modules/node-addon-api/src -I../node_modules/node-addon-api -isystem ../boost-cmake/boost/boost_1_64_0 -fPIC -O3 -DNDEBUG -fPIC   -std=gnu++1z -MD -MT CMakeFiles/npdf.dir/src/NObject.cc.o -MF CMakeFiles/npdf.dir/src/NObject.cc.o.d -o CMakeFiles/npdf.dir/src/NObject.cc.o -c ../src/NObject.cc
In file included from ../src/NObject.cc:1:
In file included from ../src/NObject.h:5:
In file included from ../src/Dictionary.h:6:
In file included from ../node_modules/node-addon-api/napi.h:1454:
../node_modules/node-addon-api/napi-inl.h:1207:20: error: use of undeclared identifier 'NAPI_AUTO_LENGTH'
    env, utf8name, NAPI_AUTO_LENGTH, CbData::Wrapper, callbackData, &value);
                   ^
../node_modules/node-addon-api/napi-inl.h:1271:24: error: no matching function for call to 'napi_make_callback'
  napi_status status = napi_make_callback(
                       ^~~~~~~~~~~~~~~~~~
/home/skyslope/.cmake-js/node-x64/v8.4.0/include/node/node_api.h:324:25: note: candidate function not viable: requires 6 arguments, but 7 were provided
NAPI_EXTERN napi_status napi_make_callback(napi_env env,

this error just repeats over and over for each objectwrapper
Here is the class that the above is erroring out with

#include "Dictionary.h"
#include "ErrorHandler.h"
#include <napi.h>
#include <podofo/podofo.h>

using namespace Napi;
using namespace PoDoFo;

class NObject : public ObjectWrap<NObject>
{
public:
  explicit NObject(const CallbackInfo&);
  ~NObject() {}
  static Napi::FunctionReference constructor;
  static void Initialize(Napi::Env& env, Napi::Object& target)
  {
    HandleScope scope(env);
    Function ctor = DefineClass(
      env,
      "Object",
      { InstanceAccessor("stream", &NObject::GetStream, nullptr),
        InstanceMethod("getDictionary", &NObject::GetDictionary),
        InstanceMethod("setDictionary", &NObject::SetDictionary),
        InstanceAccessor("type", &NObject::GetDataType, nullptr),
        InstanceAccessor("length", &NObject::GetObjectLength, nullptr) });
    constructor = Napi::Persistent(ctor);
    constructor.SuppressDestruct();
    target.Set("Object", constructor);
  }
  Napi::Value GetStream(const CallbackInfo&);
  Napi::Value GetDictionary(const CallbackInfo&);
  void SetDictionary(const CallbackInfo&);
  Napi::Value GetObjectLength(const CallbackInfo&);
  Napi::Value GetDataType(const CallbackInfo&);
  const PdfObject GetObject() { return obj; }

private:
  PdfObject obj = *new PdfObject();
};

sing namespace Napi;
using namespace PoDoFo;
using namespace std;

class Dictionary : public ObjectWrap<Dictionary>
{
public:
  explicit Dictionary(const CallbackInfo&);
  ~Dictionary() {}
  static FunctionReference constructor;
  static void Initialize(Napi::Env& env, Napi::Object& target)
  {
    HandleScope scope(env);
    Function ctor = DefineClass(
      env,
      "Dictionary",
      { InstanceMethod("getKey", &Dictionary::GetKey),
        InstanceMethod("getKeys", &Dictionary::GetKeys),
        InstanceMethod("hasKey", &Dictionary::HasKey),
        InstanceMethod("addKey", &Dictionary::AddKey),
        InstanceMethod("removeKey", &Dictionary::RemoveKey),
        InstanceAccessor(
          "immutable", &Dictionary::GetImmutable, &Dictionary::SetImmutable),
        InstanceMethod("clear", &Dictionary::Clear) });

    constructor = Napi::Persistent(ctor);
    constructor.SuppressDestruct();
    target.Set("Dictionary", constructor);
    //    target.Set("Dictionary", ctor);
  }

  void AddKey(const CallbackInfo&);
  Napi::Value GetKey(const CallbackInfo&);
  Napi::Value GetKeys(const CallbackInfo&);
  Napi::Value RemoveKey(const CallbackInfo&);
  Napi::Value HasKey(const CallbackInfo&);
  Napi::Value Clear(const CallbackInfo&);
  void SetImmutable(const CallbackInfo&, const Napi::Value&);
  Napi::Value GetImmutable(const CallbackInfo&);

private:
  //    PdfDictionary* _dict;
  const PdfObject* _obj;
  PdfDictionary dict = PdfDictionary();
  //  PdfDictionary _dict = *new PdfDictionary();
};

Thanks, and thanks for taking the time to write this, it has been an overall very pleasant experience for writing native node addons with.

@jasongin
Copy link
Member

The 1.0 release requires node 8.6.

@corymickelson
Copy link
Contributor Author

oh, ok, thats simple enough. Thank you

@corymickelson
Copy link
Contributor Author

@jasongin yup that worked. I had to change my addon.cc NODE_API_MODULE from

void init(Env, Object, Object)

to

Object init(Env env, Object exports)
{
    class::initialize(env, exports)
    return exports
}

but other than that it seems to be good.

@jasongin
Copy link
Member

Yes, that was a recent breaking change.

As indicated by the 1.0 version number, we're not planning to make any more breaking changes going forward.

@sandeepmistry
Copy link

The 1.0 release requires node 8.6.

What's the recommend path for those targeting older Node.js releases? The readme still states:

This package contains header-only C++ wrapper classes for the ABI-stable Node.js API (N-API), along with library code that enables backward-compatibility with use with older versions of Node.js that do not have N-API built-in.

@jasongin
Copy link
Member

The intention is that this package can use its external copy of the N-API implementation when built with versions of node that don't have it built-in. That should include 8.0 - 8.5.x, 6.x, and 4.x versions. (The disadvantage of that back-compat support is that you have to recompile when switching between older versions, just as with any classic node native addon.)

However, there are some issues currently with that older-version support. @gabrielschulhof is looking into that, it's tracked by #142

@mhdawson
Copy link
Member

mhdawson commented Oct 2, 2017

I think this can probably be closed now as the original issue was resolved ? @sandeepmistry

@mhdawson mhdawson closed this as completed Oct 2, 2017
@mhdawson mhdawson reopened this Oct 2, 2017
@mhdawson
Copy link
Member

mhdawson commented Oct 2, 2017

Sorry just meant to ask the question not close, @sandeepmistry please close if you agree.

@sandeepmistry
Copy link

@mhdawson yes, this can be closed, as @jasongin mentioned above my concern is tracked in #142.

@mhdawson
Copy link
Member

mhdawson commented Oct 3, 2017

Thanks, closing.

@mhdawson mhdawson closed this as completed Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants