node-clips icon indicating copy to clipboard operation
node-clips copied to clipboard

Build error on Clang: variable length array of non-POD element type

Open mattc opened this issue 12 years ago • 3 comments

When running "npm install node-clips" on Mac OS X Mavericks with the standard Apple command line developer tools:

../src/clips_environment.cc:215:20: error: variable length array of non-POD element type 'Local<v8::Value>'
   Local<Value> argv[argc];

Compiler: Apple LLVM version 5.0 (clang-500.2.79)

Looks similar to Sannis/node-mysql-libmysqlclient#127, except the array bounds in this context are already a const int.

Thanks for releasing this!

mattc avatar Dec 29 '13 20:12 mattc

There were a few other issues, too. I hacked around them to get things mostly running. These are not well thought-out fixes and are not what I would consider proposing as a patch, but here they are...

The error in the issue description above

Define argv on the heap instead.

no matching function for call to 'uv_queue_work'

../src/clips_environment.cc:624:5: error: no matching function for call to 'uv_queue_work'
    uv_queue_work(uv_default_loop(), &baton->req, CLIPSWork, CLIPSCleanup);

CLIPSCleanup doesn't match the signature that uv_queue_work expects. Remove the second argument ("status") from the definition of CLIPSCleanup - it was ignored anyway.

lazy symbol binding failed: Symbol not found

dyld: lazy symbol binding failed: Symbol not found: __Z17CreateEnvironmentv
   Referenced from: node_modules/node-clips/build/Release/node_clips.node
   Expected in: dynamic lookup

This is a runtime error. That specific message was triggered during env.initialize, but other methods trigger similar errors. Methods exported by CLIPS don't have their names mangled, while the binding expects them to have C++ name mangling. Those methods need to be defined with 'extern "C"' when compiled from C++. I got around this by just replacing all instances of "#define LOCALE extern" in CLIPS headers with:

#ifdef __cplusplus
#define LOCALE extern "C"
#else
#define LOCALE extern
#endif

Error in README example: Invalid arguments on env.run

The example doesn't work. env.run raises an "Invalid arguments" exception. It expects the first argument to be an integer indicating a run limit, before the callback. Adding a number or using "env.run(" with "env.evaluate("(run)"," does fix it.

However, I still haven't gotten animal.clp to run to completion. Even just evaluating (run) always aborts after about three questions. Not there yet.

mattc avatar Dec 30 '13 06:12 mattc

The CLIPSCleanup function signature matches the uv_after_work_cb signature. I'm not sure how this error comes for you. Which version of node are you using ? Also removing the status argument seems to trigger the symbol binding error for me.

I've fixed the original error you reported and tested it with clang. It seems to compile fine on ubuntu. Let me know if this issues persists after pulling the changes.

atrniv avatar Jan 05 '14 08:01 atrniv

I seem to be hitting the same error with the lazy binding. I've done a replacement of the '#define LOCALE extern'

However, the error now returns: dyld: lazy symbol binding failed: Symbol not found: __Z17CreateEnvironmentv Referenced from: /Documents/Node/nodeC/node_modules/node-clips/build/Release/node_clips.node Expected in: dynamic lookup

dyld: Symbol not found: __Z17CreateEnvironmentv Referenced from: /Documents/Node/nodeC/node_modules/node-clips/build/Release/node_clips.node Expected in: dynamic lookup

were you hitting the the "Symbol not found" when you replaced all the instances of '#define LOCALE extern'?

dkengaroo avatar Jul 09 '14 17:07 dkengaroo