javascript - undefined symbole using node-ffi in node js -
i have include c code in nodejs used node-ffi
,i created log.c
:
#include <stdio.h> #if defined(win32) || defined(_win32) #define export __declspec(dllexport) #else #define export #endif export void etat_periph(char periph[]){ file* fichier=null; fichier=fopen("log.txt","a+"); fputs(fichier,periph); fprintf(fichier,"**********end**********"); fclose(fichier); } export void user_connect(char user[] ,char date[]){ file* fichier=null; fichier=fopen("log.txt","a+"); fputs(fichier,"***********new user*********"); fputs(fichier,"user connected: %s at: %s",user,date); fclose(fichier); }
i added file app.js:
var ffi = require('node-ffi'); var libfile = ffi.library('./libfile', { 'etat_periph': ["void", ["string", "string"]], 'user_connect': ["void", ["string", "string"]] }); io.sockets.on('connection', function (socket) { socket.on("new_user", function (data) { console.log("a new user connected", data); var current_date = new date(); var date = current_date.tostring(); libfile.user_connect(data, date); }); socket.on("state", function (data) { console.log(data); libfile.etat_periph(data); }); });
when run app.js got error message:
error: dynamic symbol retrieval error: ./libfile.so: undefined symbol: etat_periph
Comments
Post a Comment