Skip to content

Instantly share code, notes, and snippets.

@kirbysayshi
Created June 9, 2011 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirbysayshi/1016045 to your computer and use it in GitHub Desktop.
Save kirbysayshi/1016045 to your computer and use it in GitHub Desktop.
attempt at using node-ffi, but node-ffi cannot find the symbols
#include <stdint.h>
#include <QtCore/QtGlobal>
#if defined(MYSHAREDLIB_LIBRARY)
# define MYSHAREDLIB_EXPORT Q_DECL_EXPORT
#else
# define MYSHAREDLIB_EXPORT Q_DECL_IMPORT
#endif
MYSHAREDLIB_EXPORT uint64_t factorial(int max) {
int i = max;
uint64_t result = 1;
while (i >= 2)
result *= i--;
return result;
}
var FFI = require('node-ffi')
,libstackoverflow = new FFI.Library("build/libstackoverflow", {
'factorial': [ 'uint64', [ 'int' ] ]
});
console.log(libstackoverflow.factorial(10));
######################################################################
# Automatically generated by qmake (2.01a) Wed Jun 8 21:28:16 2011
######################################################################
TEMPLATE = lib
DEFINES += MYSHAREDLIB_LIBRARY
CONFIG += qt dll
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
DESTDIR = ./build
# Input
SOURCES += main.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment