[SOLVED] node.js on qnap?

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.
zyclon
New here
Posts: 7
Joined: Wed Nov 23, 2011 10:52 pm
Location: Germany

Re: [SOLVED] node.js on qnap?

Post by zyclon » Thu Dec 29, 2011 5:59 am

Hi,

finally I've found a way to compile nodejs on QNAP for armv5te (TS-419P+ maybe also TS-419P and others using arm processors).
Just a short description, if I have some more time I will write a little howto.

The trick was to compile the v8 engine delivered with NodeJs standalone.

I downloaded the current source code from http://nodejs.org/ (v0.6.6) and followed this guide for cross compiling v8 on arm: Guide how to compile v8 on arm

meet some requirements:

Code: Select all

ipkg install openssl openssl-dev make gcc python27 scons


Set environment:

Code: Select all

## add /opt/bin to PATH
export PATH=$PATH:/opt/bin

## add /opt/lib to ldconfig
echo "/opt/lib" >> /etc/ld.so.conf
ldconfig


In the sources go to:

Code: Select all

cd deps/v8

## export the CCFLAGS to match architecture here armv5te
export CCFLAGS="-march=armv5te"

## now run scons with the following params to build v8
## armeabi=soft uses emulated software floating point unit, important for armv5te
## sample=shell builds a v8 shell (so you can test if v8 works)
scons wordsize=32 snapshot=off arch=arm armeabi=soft library=shared
scons wordsize=32 snapshot=off arch=arm armeabi=soft library=shared sample=shell 

## test shell
./shell
V8 version 3.6.6.14 [sample shell]
>
 


now copy v8 to a place you want

Code: Select all

pwd
/share/Download/NodeJS/node-v0.6.6/deps/v8
cd ..
cp -a v8 /opt/share/.

## add library to ldconfig
echo "/opt/share/v8" >> /etc/ld.so.conf
ldconfig


compile and install nodejs

Code: Select all

## go to node js src dir 
cd /share/Download/NodeJS/node-v0.6.6

## run configure
./configure --shared-v8 --shared-v8-libpath=/opt/share/v8 --shared-v8-includes=/opt/share/v8/include --prefix=/opt/share/nodejs
Checking for program g++ or c++          : /opt/bin/g++
Checking for program cpp                 : /opt/bin/cpp
Checking for program ar                  : /opt/bin/ar
Checking for program ranlib              : /opt/bin/ranlib
Checking for g++                         : ok 
Checking for program gcc or cc           : /opt/bin/gcc
Checking for program ar                  : /opt/bin/ar
Checking for program ranlib              : /opt/bin/ranlib
Checking for gcc                         : ok 
Checking for library dl                  : yes
Checking for openssl                     : yes
Checking for library util                : yes
Checking for library rt                  : yes
Checking for header v8.h                 : yes
Checking for fdatasync(2) with c++       : yes
'configure' finished successfully (2.606s)
 
## build
make
[...]
Waf: Leaving directory `/share/MD0_DATA/Download/NodeJS/node-v0.6.6/out'
'build' finished successfully (4m19.194s)
-rwxr-xr-x    1 admin    administ     3.2M Dec 28 22:51 out/Release/node
 
## check if node runs  :)
out/Release/node
>
 
make install
 
/opt/share/nodejs/bin/node
>



A little hint:
PATH variable and /etc/ld.so.conf are reset after reboot to defaults. So I used the optware init mechanism to set config and $PATH on reboot with a little init script.

Next step, build etherpad-lite on arm-QNAP :)
Hopes this helps someone.

Best regards,
zyclon
TS-419P+:
Processor: Feroceon 88F6282 rev 1 (v5l); Features: swp half thumb fastmult edsp;
CPU architecture: 5TE (armv5te); Hardware: Feroceon-KW ARM;
Overview: http://www.marvell.com/embedded-processors/kirkwood/
Datasheet: http://www.marvell.com/embedded-process ... 2-3_pb.pdf

Mumin2012
First post
Posts: 1
Joined: Sat May 19, 2012 9:11 am

Re: [SOLVED] node.js on qnap?

Post by Mumin2012 » Sat May 19, 2012 9:20 am

Hi zyclon,

thanks for this excellent guidance. I have just managed to build node.js 0.6.18 on my NAS259+ (which has Atom CPU, i.e. the ARM options are not required).

The build works without SSL. However, NPM and other progs do need SSL in node.js, so I would really like to have that running as well.
Maybe you have an idea what is going on with the following error message that I get during the linking.

It is obviously something missing here but I have no idea what lib could be missing (OpenSSL was successfully installed with the ipkg command you mentioned.

thanks in advance!!
Mumin2012


/lib -Wl,-Bdynamic -lrt -lssl -lcrypto -ldl -lutil
/share/MD0_DATA/.qpkg/Optware/bin/../lib/gcc/i686-unknown-linux-gnu/4.2.1/../../../libssl.so: undefined reference to `d2i_X509_EXTENSIONS'
/share/MD0_DATA/.qpkg/Optware/bin/../lib/gcc/i686-unknown-linux-gnu/4.2.1/../../../libssl.so: undefined reference to `ENGINE_get_ssl_client_cert_function'
/share/MD0_DATA/.qpkg/Optware/bin/../lib/gcc/i686-unknown-linux-gnu/4.2.1/../../../libssl.so: undefined reference to `HMAC_CTX_set_flags'
/share/MD0_DATA/.qpkg/Optware/bin/../lib/gcc/i686-unknown-linux-gnu/4.2.1/../../../libssl.so: undefined reference to `i2d_X509_EXTENSIONS'
/share/MD0_DATA/.qpkg/Optware/bin/../lib/gcc/i686-unknown-linux-gnu/4.2.1/../../../libssl.so: undefined reference to `ENGINE_load_ssl_client_cert'
/share/MD0_DATA/.qpkg/Optware/bin/../lib/gcc/i686-unknown-linux-gnu/4.2.1/../../../libssl.so: undefined reference to `pqueue_size'
collect2: ld returned 1 exit status
Waf: Leaving directory `/share/MD0_DATA/Public/node-v0.6.18/out'
Build failed: -> task failed (err #1):
{task: cxx_link node_main_5.o,node_5.o,node_buffer_5.o,node_javascript_5.o,node_extensions_5.o,node_http_parser_5.o,node_constants_5.o,node_file_5.o,node_script_5.o,node_os_5.o,node_dtrace_5.o,node_string_5.o,node_zlib_5.o,timer_wrap_5.o,handle_wrap_5.o,stream_wrap_5.o,tcp_wrap_5.o,udp_wrap_5.o,pipe_wrap_5.o,cares_wrap_5.o,tty_wrap_5.o,fs_event_wrap_5.o,process_wrap_5.o,v8_typed_array_5.o,node_signal_watcher_5.o,node_stat_watcher_5.o,node_io_watcher_5.o,platform_linux_5.o,node_crypto_5.o,http_parser_3.o -> node}
make: *** [program] Error 1

zyclon
New here
Posts: 7
Joined: Wed Nov 23, 2011 10:52 pm
Location: Germany

Re: [SOLVED] node.js on qnap?

Post by zyclon » Sat May 19, 2012 9:57 pm

Hi Mumin2012,

I'm not sure but have an assumption.

Can you check your /etc/ld.so.conf file?

I think there are some lib paths missing which are necessary for ldconfig to find the ssl libs from ipkg.

I have written a little script for me, which configures the file on every restart of the NAS since it is reseted on boot.

Code: Select all

[/opt/etc] # cat set_qnap_libs.sh 
#!/bin/sh

#### adding /opt/lib to ldconfig file
/bin/cat /etc/ld.so.conf | /bin/grep "/opt/lib" 1>>/dev/null 2>>/dev/null
[ $? -ne 0 ] && /bin/echo "/opt/lib" >> /etc/ld.so.conf; ldconfig

#### adding ggogle v8 java script engine /opt/share/v8 to ldconfig file
/bin/cat /etc/ld.so.conf | /bin/grep "/opt/share/v8" 1>>/dev/null 2>>/dev/null
[ $? -ne 0 ] && /bin/echo "/opt/share/v8" >> /etc/ld.so.conf; ldconfig



This script is linked to the Optware init mechanism to run on every reboot.

Code: Select all

[/opt/etc/init.d] # ls -alh S01_set_qnap_lib 
lrwxrwxrwx    1 admin    administ       25 Nov 28 20:46 S01_set_qnap_lib -> /opt/etc/set_qnap_libs.sh*


Hope this is the right hint :)

zyclon
TS-419P+:
Processor: Feroceon 88F6282 rev 1 (v5l); Features: swp half thumb fastmult edsp;
CPU architecture: 5TE (armv5te); Hardware: Feroceon-KW ARM;
Overview: http://www.marvell.com/embedded-processors/kirkwood/
Datasheet: http://www.marvell.com/embedded-process ... 2-3_pb.pdf

Post Reply

Return to “Miscellaneous”