xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.18k stars 371 forks source link

echo_server.js fails to run - wrong architecture #9

Closed DTrejo closed 13 years ago

DTrejo commented 13 years ago

It seems like node-expat is being built by npm for the wrong architecture?

Flags like the ones used in this article may be in order, but I'm not sure: http://de-co-de.blogspot.com/2008/04/if-you-install-modjk.html

I am running snow leopard and node 0.3.0.

I'm guessing this is node-expat's problem rather than node-xmpp's problem. My bad for posting here.

Steps to reproduce:

DTrejo:nxmpp david$ git clone https://github.com/astro/node-xmpp.git
Cloning into node-xmpp...
remote: Counting objects: 856, done.
remote: Compressing objects: 100% (288/288), done.
remote: Total 856 (delta 561), reused 851 (delta 556)
Receiving objects: 100% (856/856), 119.22 KiB | 174 KiB/s, done.
Resolving deltas: 100% (561/561), done.
DTrejo:nxmpp david$ npm install node-xmpp
npm info it worked if it ends with ok
npm info using npm@0.2.12-1
npm info using node@v0.3.0
npm info preinstall node-xmpp@0.2.3
npm info preinstall ltx@0.0.1
npm info preinstall node-expat@1.1.0
npm info install node-xmpp@0.2.3
npm info postinstall node-xmpp@0.2.3
npm info preactivate node-xmpp@0.2.3
npm info activate node-xmpp@0.2.3
npm info postactivate node-xmpp@0.2.3
npm info install ltx@0.0.1
npm info postinstall ltx@0.0.1
npm info preactivate ltx@0.0.1
npm info activate ltx@0.0.1
npm info postactivate ltx@0.0.1
npm info install node-expat@1.1.0
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /Users/david/.node_libraries 
Checking for node prefix                 : ok /Users/david/local 
'configure' finished successfully (0.063s)
Waf: Entering directory `/Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build'
[1/2] cxx: node-expat.cc -> build/default/node-expat_1.o
[2/2] cxx_link: build/default/node-expat_1.o -> build/default/node-expat.node
Waf: Leaving directory `/Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build'
'build' finished successfully (0.393s)
npm info postinstall node-expat@1.1.0
npm info preactivate node-expat@1.1.0
npm info activate node-expat@1.1.0
npm info postactivate node-expat@1.1.0
npm info build Success: node-xmpp@0.2.3
npm info build Success: ltx@0.0.1
npm info build Success: node-expat@1.1.0
npm ok
DTrejo:nxmpp david$ cd node-xmpp/
DTrejo:node-xmpp david$ node examples/
echo_bot.js                echo_server.js             send_message.js            
echo_component.js          probe_server.js            send_message_component.js  
DTrejo:node-xmpp david$ node examples/echo_server.js 
The 'sys' module is now called 'util'. It should have a similar interface.
The 'sys' module is now called 'util'. It should have a similar interface.

node.js:50
    throw e; // process.nextTick error, or 'error' event on first tick
    ^
Error: dlopen(/Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build/default/node-expat.node, 1): no suitable image found.  Did find:
    /Users/david/local/lib/node/.npm/node-expat/1.1.0/package/build/default/node-expat.node: mach-o, but wrong architecture
    at Object..node (node.js:362:13)
    at Module.load (node.js:279:25)
    at loadModule (node.js:251:12)
    at require (node.js:291:14)
    at Object. (/Users/david/local/lib/node/node-expat/index.js:11:18)
    at Module._compile (node.js:348:23)
    at Object..js (node.js:356:12)
    at Module.load (node.js:279:25)
    at loadModule (node.js:251:12)
    at require (node.js:291:14)
DTrejo:node-xmpp david$ node --version
v0.3.0
astro commented 13 years ago

Sorry, I don't have Mac OS to reproduce.

Have you tried recompiling/reinstalling node-expat?

Have you tried Node v0.2.x instead of unstable v0.3.x?

DTrejo commented 13 years ago

Hi Astro, I think I've made a bit of progress at fixing this and pinpointing where the problem is:

There are two things that I think could be going wrong:

  1. I installed the wrong verison via macports (I need to look into this more Edit: I think I have the right one: icu @4.6 devel/icu)
  2. there is some compilation flag that needs to be changed Also, what's going on with all the strange syntax errors?
DTrejo:node-xmpp david$ npm install node-stringprep
npm info it worked if it ends with ok
npm info using npm@0.2.13
npm info using node@v0.2.5
npm info preinstall node-stringprep@0.0.2
npm info install node-stringprep@0.0.2
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /Users/david/.node_libraries 
Checking for node prefix                 : ok /Users/david/local 
'configure' finished successfully (0.219s)
Waf: Entering directory `/Users/david/local/lib/node/.npm/node-stringprep/0.0.2/package/build'
[1/2] cxx: node-stringprep.cc -> build/default/node-stringprep_1.o
i686-apple-darwin10-g++-4.2.1: \c: No such file or directory
../node-stringprep.cc:3:28: error: unicode/unistr.h: No such file or directory
../node-stringprep.cc:4:28: error: unicode/usprep.h: No such file or directory
In file included from /Users/david/local/include/node/node.h:6,
                 from ../node-stringprep.cc:1:
/Users/david/local/include/node/eio.h:199: error: comma at end of enumerator list
In file included from /Users/david/local/include/node/node.h:7,
                 from ../node-stringprep.cc:1:
/Users/david/local/include/node/v8.h:2246: warning: unused parameter ‘name’
../node-stringprep.cc:89: error: expected ‘,’ or ‘...’ before ‘profileType’
../node-stringprep.cc:89: error: ISO C++ forbids declaration of ‘UStringPrepProfileType’ with no type
../node-stringprep.cc:154: error: ISO C++ forbids declaration of ‘UStringPrepProfile’ with no type
../node-stringprep.cc:154: error: expected ‘;’ before ‘*’ token
../node-stringprep.cc:155: error: ‘UErrorCode’ does not name a type
../node-stringprep.cc:157: error: use of enum ‘UStringPrepProfileType’ without previous declaration
../node-stringprep.cc: In member function ‘bool StringPrep::good() const’:
../node-stringprep.cc:39: error: ‘error’ was not declared in this scope
../node-stringprep.cc: In member function ‘const char* StringPrep::errorName() const’:
../node-stringprep.cc:44: error: ‘error’ was not declared in this scope
../node-stringprep.cc:44: error: ‘u_errorName’ was not declared in this scope
../node-stringprep.cc: In static member function ‘static v8::Handle StringPrep::New(const v8::Arguments&)’:
../node-stringprep.cc:62: error: ‘UStringPrepProfileType’ was not declared in this scope
../node-stringprep.cc:62: error: expected `;' before ‘profileType’
../node-stringprep.cc:65: error: ‘profileType’ was not declared in this scope
../node-stringprep.cc:72: error: ‘profileType’ was not declared in this scope
../node-stringprep.cc: In constructor ‘StringPrep::StringPrep(int)’:
../node-stringprep.cc:90: error: class ‘StringPrep’ does not have any field named ‘error’
../node-stringprep.cc:90: error: ‘U_ZERO_ERROR’ was not declared in this scope
../node-stringprep.cc:92: error: ‘profile’ was not declared in this scope
../node-stringprep.cc:92: error: ‘profileType’ was not declared in this scope
../node-stringprep.cc:92: error: ‘error’ was not declared in this scope
../node-stringprep.cc:92: error: ‘usprep_openByType’ was not declared in this scope
../node-stringprep.cc: At global scope:
../node-stringprep.cc:89: warning: unused parameter ‘UStringPrepProfileType’
../node-stringprep.cc: In destructor ‘virtual StringPrep::~StringPrep()’:
../node-stringprep.cc:99: error: ‘profile’ was not declared in this scope
../node-stringprep.cc:100: error: ‘usprep_close’ was not declared in this scope
../node-stringprep.cc: In member function ‘v8::Handle StringPrep::prepare(v8::String::Value&)’:
../node-stringprep.cc:122: error: ‘UChar’ was not declared in this scope
../node-stringprep.cc:122: error: ‘dest’ was not declared in this scope
../node-stringprep.cc:125: error: expected type-specifier before ‘UChar’
../node-stringprep.cc:125: error: expected `;' before ‘UChar’
../node-stringprep.cc:126: error: ‘profile’ was not declared in this scope
../node-stringprep.cc:129: error: ‘USPREP_DEFAULT’ was not declared in this scope
../node-stringprep.cc:129: error: ‘error’ was not declared in this scope
../node-stringprep.cc:129: error: ‘usprep_prepare’ was not declared in this scope
../node-stringprep.cc:131: error: ‘U_BUFFER_OVERFLOW_ERROR’ was not declared in this scope
../node-stringprep.cc:135: error: type ‘’ argument given to ‘delete’, expected pointer
../node-stringprep.cc:141: error: type ‘’ argument given to ‘delete’, expected pointer
../node-stringprep.cc:149: error: type ‘’ argument given to ‘delete’, expected pointer
../node-stringprep.cc: In static member function ‘static int StringPrep::parseProfileType(v8::String::Utf8Value&)’:
../node-stringprep.cc:161: error: ‘USPREP_RFC3491_NAMEPREP’ was not declared in this scope
../node-stringprep.cc:163: error: ‘USPREP_RFC3530_NFS4_CS_PREP’ was not declared in this scope
../node-stringprep.cc:165: error: ‘USPREP_RFC3530_NFS4_CS_PREP_CI’ was not declared in this scope
../node-stringprep.cc:167: error: ‘USPREP_RFC3530_NFS4_CIS_PREP’ was not declared in this scope
../node-stringprep.cc:169: error: ‘USPREP_RFC3530_NFS4_MIXED_PREP_PREFIX’ was not declared in this scope
../node-stringprep.cc:171: error: ‘USPREP_RFC3530_NFS4_MIXED_PREP_SUFFIX’ was not declared in this scope
../node-stringprep.cc:173: error: ‘USPREP_RFC3722_ISCSI’ was not declared in this scope
../node-stringprep.cc:175: error: ‘USPREP_RFC3920_NODEPREP’ was not declared in this scope
../node-stringprep.cc:177: error: ‘USPREP_RFC3920_RESOURCEPREP’ was not declared in this scope
../node-stringprep.cc:179: error: ‘USPREP_RFC4011_MIB’ was not declared in this scope
../node-stringprep.cc:181: error: ‘USPREP_RFC4013_SASLPREP’ was not declared in this scope
../node-stringprep.cc:183: error: ‘USPREP_RFC4505_TRACE’ was not declared in this scope
../node-stringprep.cc:185: error: ‘USPREP_RFC4518_LDAP’ was not declared in this scope
../node-stringprep.cc:187: error: ‘USPREP_RFC4518_LDAP_CI’ was not declared in this scope
Waf: Leaving directory `/Users/david/local/lib/node/.npm/node-stringprep/0.0.2/package/build'
Build failed:  -> task failed (err #1): 
    {task: cxx node-stringprep.cc -> node-stringprep_1.o}
npm info node-stringprep@0.0.2 Failed to exec install script
npm ERR! install failed Error: node-stringprep@0.0.2 install: `./install.sh`
npm ERR! install failed `sh` failed with 1
npm ERR! install failed     at ChildProcess. (/Users/david/local/lib/node/.npm/npm/0.2.13/package/lib/utils/exec.js:25:18)
npm ERR! install failed     at ChildProcess.emit (events:27:15)
npm ERR! install failed     at ChildProcess.onexit (child_process:168:12)
npm ERR! install failed     at node.js:773:9
npm info install failed rollback
npm info uninstall [ 'node-stringprep@0.0.2' ]
npm info preuninstall node-stringprep@0.0.2
npm info uninstall node-stringprep@0.0.2
npm info auto-deactive not symlink
npm info postuninstall node-stringprep@0.0.2
npm info uninstall node-stringprep@0.0.2 complete
npm info install failed rolled back
npm ERR! Error: node-stringprep@0.0.2 install: `./install.sh`
npm ERR! `sh` failed with 1
npm ERR!     at ChildProcess. (/Users/david/local/lib/node/.npm/npm/0.2.13/package/lib/utils/exec.js:25:18)
npm ERR!     at ChildProcess.emit (events:27:15)
npm ERR!     at ChildProcess.onexit (child_process:168:12)
npm ERR!     at node.js:773:9
npm ERR! 
npm ERR! Failed at the node-stringprep@0.0.2 install script.
npm ERR! This is most likely a problem with the node-stringprep package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./install.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-stringprep
npm ERR! There may be additional logging output above.
npm not ok
DTrejo commented 13 years ago

Hey Astro, would your guess be that this is a compilation flags problem?

I have very almost no experience with C++, so any insight from you would be super helpful!

Thanks! -David

astro commented 13 years ago

If the icu header files are not in /usr/include (g++ default path), you'll need to pass the right location with the -I flag.

Where are unicode/unistr.h and unicode/usprep.h on your system?

astro commented 13 years ago

Have you managed to install recent ICU? Does the problem still persist for you?

DTrejo commented 13 years ago

Hey astro, apologies, I am still having the problem, but since it's just me I think it's best to ignore it. Also, this is on OSX, so if I was actually running this for my app it would probably be on a linux machine (and it would work). Thanks for the help anyway.

astro commented 13 years ago

Development environments are almost as important as production systems. I won't be able to help you with anything Apple-specific, but a solution may help others as well.

DTrejo commented 13 years ago

So, I updated icu with macports, it did install correctly to /opt/local/unicode/unistr.h and /opt/local/unicode/usprep.h. My mac does not have the above two files in /usr/include/, so I made a symlink sudo ln -s /opt/local/include/unicode /usr/include/unicode

to check if it worked:

DTrejo:include david$ ls -al | grep unicode
lrwxr-xr-x    1 root  wheel      26 Apr  3 16:47 unicode -> /opt/local/include/unicode

When I ran npm install node-stringprep, I got an error again (but it is different, which is good I suppose). It's too bad the error messages aren't more helpful :|

DTrejo:include david$ npm install node-stringprep
npm info it worked if it ends with ok
npm info using npm@0.3.17
npm info using node@v0.4.1
npm info preinstall node-stringprep@0.0.3
npm info install node-stringprep@0.0.3
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : ok /Users/david/.node_libraries 
Checking for node prefix                 : ok /Users/david/local 
'configure' finished successfully (0.106s)
Waf: Entering directory `/Users/david/local/lib/node/.npm/node-stringprep/0.0.3/package/build'
[1/2] cxx: node-stringprep.cc -> build/default/node-stringprep_1.o
i686-apple-darwin10-g++-4.2.1: \c: No such file or directory
In file included from /Users/david/local/include/node/node.h:6,
                 from ../node-stringprep.cc:1:
/Users/david/local/include/node/eio.h:179: error: comma at end of enumerator list
/Users/david/local/include/node/eio.h:187: error: comma at end of enumerator list
In file included from /Users/david/local/include/node/node.h:7,
                 from ../node-stringprep.cc:1:
/Users/david/local/include/node/v8.h:2312: warning: unused parameter ‘name’
Waf: Leaving directory `/Users/david/local/lib/node/.npm/node-stringprep/0.0.3/package/build'
Build failed:  -> task failed (err #1): 
    {task: cxx node-stringprep.cc -> node-stringprep_1.o}
npm info node-stringprep@0.0.3 Failed to exec install script
npm ERR! install failed Error: node-stringprep@0.0.3 install: `./install.sh`
npm ERR! install failed `sh "-c" "./install.sh"` failed with 1
npm ERR! install failed     at ChildProcess. (/Users/david/local/lib/node/.npm/npm/0.3.17/package/lib/utils/exec.js:49:20)
npm ERR! install failed     at ChildProcess.emit (events.js:45:17)
npm ERR! install failed     at ChildProcess.onexit (child_process.js:171:12)
npm info install failed rollback
npm info uninstall [ 'node-stringprep@0.0.3' ]
npm info preuninstall node-stringprep@0.0.3
npm info uninstall node-stringprep@0.0.3
npm info auto-deactive not symlink
npm info postuninstall node-stringprep@0.0.3
npm info uninstall node-stringprep@0.0.3 complete
npm info install failed rolled back
npm ERR! Error: node-stringprep@0.0.3 install: `./install.sh`
npm ERR! `sh "-c" "./install.sh"` failed with 1
npm ERR!     at ChildProcess. (/Users/david/local/lib/node/.npm/npm/0.3.17/package/lib/utils/exec.js:49:20)
npm ERR!     at ChildProcess.emit (events.js:45:17)
npm ERR!     at ChildProcess.onexit (child_process.js:171:12)
npm ERR! 
npm ERR! Failed at the node-stringprep@0.0.3 install script.
npm ERR! This is most likely a problem with the node-stringprep package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./install.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-stringprep
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 10.6.0
npm ERR! argv { remain: [ 'node-stringprep' ],
npm ERR! argv   cooked: [ 'install', 'node-stringprep' ],
npm ERR! argv   original: [ 'install', 'node-stringprep' ] }
npm not ok
rmanalan commented 13 years ago

@DTrejo I'm getting the exact same thing as you on snow leopard. Have you figured out a way to get around it?

DTrejo commented 13 years ago

Hey, I didn't. Sorry :|

albertyann commented 11 years ago

yum install libicu yum install libicu-devel

You need head file unicode/unistr.h in icu library.

http://stackoverflow.com/questions/8861852/what-is-unicode-unistr-h.

My system is CentOS.

kimshinelove commented 11 years ago

@albertyann thank you for your comment~

wstucco commented 11 years ago

I managed to install node-stringprep using homebrew on mac with the following steps

brew install icu4c ln -sf /usr/local/Cellar/icu4c//include/* /usr/include/ (this step could be optional) npm install node-stringprep

the installation is successful, but I still get an error

node echo_bot.js Cannot load StringPrep-0.1.0 bindings. You may need to `npm install node-stringprep'

lloydwatkin commented 11 years ago

Hi @wstucco,

This shouldn't stop the echobot from working, its just means that node-stringprep isn't installed (properly). So its a warning rather than an error.

Cheers, Lloyd.

wstucco commented 11 years ago

@lloydwatkin Yes, you're right, it doesn't stop the bot from working, I was just wondering why the warning if the lib is installed.BTW it works great.

lloydwatkin commented 11 years ago

I'm unsure, the code lives in lib/xmpp/jid.js and for some reason an exception is being thrown.

lloyd:xmpp-ftw lloyd$ brew install icu4c
Error: icu4c-49.1.2 already installed

Then I get the following when dumping the exception that is thrown:

lloyd:xmpp-ftw lloyd$ node index.js 
Cannot load StringPrep-0.1.0 bindings. You may need to `npm install node-stringprep'
[Error: dlopen(/private/tmp/xmpp-ftw/node_modules/node-stringprep/build/Release/node-stringprep.node, 1): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.50.1.dylib
  Referenced from: /private/tmp/xmpp-ftw/node_modules/node-stringprep/build/Release/node-stringprep.node
  Reason: image not found]

ls'ing that directory I see the following files:

lloyd:xmpp-ftw lloyd$ ls /usr/local/opt/icu4c/lib/libicui
libicui18n.49.1.2.dylib  libicui18n.a             libicuio.49.1.2.dylib    libicuio.a               
libicui18n.49.dylib      libicui18n.dylib         libicuio.49.dylib        libicuio.dylib

Therefore it looks like the version has changed and we need to do some more intelligent attempts at loading?