Skip to content

Instantly share code, notes, and snippets.

@cristobal
Last active December 14, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristobal/5163655 to your computer and use it in GitHub Desktop.
Save cristobal/5163655 to your computer and use it in GitHub Desktop.
Builde nodejs and ZMQ on a shared host when build tools are available
# 1. Downdload the latest distribution from http://nodejs.org
# 2. Extract the nodejs distribution
$> tar zxvf node-{version}.tar.gz
$> cd node-{version}
# 3. Configure and gmake with the location for your distribution i.e.
$> ./configure --prefix=$HOME/local
$> gmake
$> gmake install
# 4. Make sure that the PATH variable includes local/bin in your
# if not so update your .bashrc / .bashrc_login or .profile file to include it
PATH=$PATH:$HOME/local/bin; export PATH
# 5.The node binary should be available from local/bin now
$> which node
# 6. Make sure to set the NODE_PATH in your .bashrc / .bashrc_login or .profile file
NODE_PATH=$HOME/local/lib/node:$HOME/local/lib/node_modules; export NODE_PATH
# 1. Download the latest zmq library from http://www.zeromq.org
# 2. Extract the zmq distribution
$> tar zxvf zmq-{version}.tar.gz
$> cd zmq-{version}
# 3. Configure and gmake with the location for your distribution i.e.
$> ./configure --prefix=$HOME/local
$> gmake
$> gmake install
# 4. Make sure to install the required node-gyp library
$> npm install -g node-gyp
# 5. Download or clone the latest zeromq.node from https://github.com/JustinTulloss/zeromq.node
$> git clone https://github.com/JustinTulloss/zeromq.node.git
$> cd zeromq.node
# 6. Change the bindings.gyp file to include the correct path to search for when building
# Replace $HOME with the actual location just in case
$> vim bindings.gyp
{
'targets': [
{
'target_name': 'binding',
'sources': [ 'binding.cc' ],
## -- [The libraries section]-- ##
'libraries': [
'-lzmq',
# Now it knows where to search for the shared zmq object
'-L$HOME/local/lib'
],
'cflags!': ['-fno-exceptions'],
'cflags_cc!': ['-fno-exceptions'],
## -- [The include_dirs section]-- ##
'include_dirs': [
# Now it knows where to lookup the include the zmq.h file used by the node's bindings.cc file
'$HOME/local/include'
],
## -- [The ldflags section]-- ##
'ldflags': [
###############################
# Now it knows where to lookup the shared object libzmq.so
# when the module is loaded inside node.
#
# Otherwise we would get the following error:
# Shared object "libzmq.so.3" not found, required by "binding.node"
############################
'-Wl,-rpath=$HOME/local/lib'
],
'conditions': [
]
}
]
}
# 7. Configure and build the zmq node module
$> npm install -g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment