Created
June 9, 2011 04:14
-
-
Save kirbysayshi/1016045 to your computer and use it in GitHub Desktop.
attempt at using node-ffi, but node-ffi cannot find the symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FFI = require('node-ffi') | |
,libstackoverflow = new FFI.Library("build/libstackoverflow", { | |
'factorial': [ 'uint64', [ 'int' ] ] | |
}); | |
console.log(libstackoverflow.factorial(10)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################### | |
# 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