2013-01-15 1 views
0

Je souhaite utiliser la bibliothèque CImg pour traiter les images dans node.js, donc j'écris un addon de noeud pour le faire. La compilation est un succès, je lance node-gyp build commond, c'est bon.Exécution de la bibliothèque CImg avec l'erreur node-gyp

Mais quand je lance le programme de nœud, l'erreur de suivi se produit:

[[email protected] hcaptha]# node index.js 

module.js:485 
    process.dlopen(filename, module.exports); 
     ^
Error: /usr/local/nodejs/hcaptha/build/Release/hcaptha.node: undefined symbol: XSendEvent 
    at Object.Module._extensions..node (module.js:485:11) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.require (module.js:362:17) 
    at require (module.js:378:17) 
    at Object.<anonymous> (/usr/local/nodejs/hcaptha/lib/hcap.js:1:75) 
    at Module._compile (module.js:449:26) 
    at Object.Module._extensions..js (module.js:467:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 

le fichier binding.gyp est:

{ 
    "targets":[ 
    { 
     "target_name": "hcaptha", 
     "sources": [ "addon/hcaptha.cc" ,"addon/cap.cc"], 
     'cflags': ['-fexceptions','-O2','-Dcimg_use_png'],//the configure using CImg lib 
     'cflags_cc': ['-fexceptions','-O2','-Dcimg_use_png'] 
    } 
    ] 
} 

Code cap.cc:

#include <node.h> 
#include <string> 
#include <iostream> 
#include "cap.h" 
#include "CImg-1.5.3/CImg.h" 

using namespace v8; 
Handle<Value> cap::create(const Arguments& args) {//create an image 
    HandleScope scope; 
    using namespace cimg_library; 
    CImg<unsigned char> captcha(256,64,1,3,0);//delete this line run ok! 
    return scope.Close(Boolean::New(1)); 
} 
cap::cap(){}; 
cap::~cap(){}; 

code index.js:

var obj = require('../build/Release/hcaptha.node'); 

quelqu'un peut-il m'aider?

Répondre

2

Je trouve enfin le résultat. ajoutez la ligne "libraries": ['- lX11'] dans le fichier binding.gyp, c'est bon! nouveau fichier binding.gyp comme ceci:

{ 
    "targets":[ 
    { 
     "target_name": "hcaptha", 
     "sources": [ "addon/hcaptha.cc" ,"addon/cap.cc"], 
     "cflags": ['-fexceptions','-O2','-Dcimg_use_png'], 
     "cflags_cc": ['-fexceptions','-O2','-Dcimg_use_png'], 
     "libraries":['-lX11'] 
    } 
    ] 
} 
Questions connexes