My favorites | Sign in
Project Hosting will be READ-ONLY Thursday at 3:00pm UTC for up to 3 hours for network maintenance.
Project Home Downloads Wiki Issues Source
Search
for
BuildingTheCode  
Configuring and building the source tree
Phase-UserDocs, Phase-Implementation, Featured, Topic-Project
Updated Jan 20, 2011 by sgbeal@gmail.com

Requirements and prerequisites

Caveat #1: the main/complete build tree will ONLY work on GNU platforms, or Unix-like platforms which host GNU toolsets (including GNU-compatible versions of the basic system tools, gcc, and GNU Make 3.81). It won't compile as-is (or will compile but not link) on Cygwin or Mac platforms (i only have Linux boxes, so that's what my build tools target). i would really like to port (or get someone else to port) the tree to scons at some point (for platform compatibility), but i have no experience with scons. Once the tree is restructured how i want it, i'll revisit scons (which can live in parallel with my own personal favourite, Make).

Caveat #2: there is a minimal build configuration for scons, but it can't do much and requires manual tweaking of the SConstruct file. See the section on scons down below.

The sources have only two hard dependencies: Google v8 and the STL (which comes with all sane C++ compilers and is also available separately via projects like STLPort). For plugins to work it needs (on Unix platforms) libdl or libltdl and v8-juice must be compiled as a shared library (the plugin model cannot work from within a static library for boring technical reasons). (For Windows platforms the DLL support needs no additional libraries.)

Configuring and compiling

The build is fairly conventional:

./configure ... options (see below) ...
make
make install # installs under the path defined by --prefix=/path

My default build options is make -j2 for parallel building, so the tree is believed to build okay with parallel builds (if it doesn't, please file a bug report). That said, certain parts of the tree enforce that certain directory branches are built before others, so certain branches may not allow parallelization. Even without parallelization it builds quickly (currently (20101126) it takes about 12 seconds on a 3GHz PC).

The following configuration options are often helpful or necessary:

  • --prefix=/dir is the installation prefix and the default place under which it will look for v8 and any additional libraries (e.g. those needed by plugins). Using --prefix=$HOME is often a good choice, and it allows a non-root user to run the installation.
  • --v8-prefix=/top/install/dir/of/v8 tells configure to look for v8 under the given dir. It expects to find include/v8.h and lib/libv8(_g).(a|so). Tip: use --prefix=$HOME if you are a non-root user or do not want to install it globally.
  • --enable-debug turns on debugging options and tries to link against libv8_g instead of libv8 (but will use the latter if it can't find the former).
  • --help shows many more options which you'll never need.
  • --disable-plugins makes the plugin loading features no-ops and disables the build of the core plugins. Plugins are automatically disabled if neither -ldl or -lltdl are found. Specific plugins might not get compiled because their plugin-specific prerequisites are not met (e.g. libsqlite3 or libncurses).
  • --enable-warn turns on the -Wall compilation flag.
  • --enable-werror turns on the -Werror compilation flag.

See SourceTreeOverview for info on how the tree is laid out.

Installation

Run make install to install the library under the directory specified by the --prefix=/path configure argument.

If you need to do a custom installation, here's what you'll need to copy (and to where):

  • src/lib/juice/libv8-juice.* should go somewhere in your linker path.
  • src/include/v8 should be copied (recursively) to some top-level includes dir of your choice.
  • src/client/shell/v8-juice-shell can optionally be installed somewhere in your PATH.

The makefile also supports make uninstall.

Using SCons

As of 20090313 the tree has very minimal support for a build using SCons.

  • Tweak the top-most SConstruct file to set the path to your libv8 library and header.
  • If you are NOT on a Unix platform, also remove the reference to the library named "dl".
  • Building the shell app seems to require the static v8-juice library, even if it links against the shared library. This might be a bug particular to my platform or version of scons.

Finally, just type scons. All buildable objects will be created in the top of the source tree.

To install it, follow the instructions shown above for a manual installation.

Achtung: the scons build actually depends on certain header files which are generated by the make-based build process. The copies of those generated files "might" not be as current as their generated forms.

Building on Windows and Mac

Good luck! i use Windows only for gaming and i've been boycotting Apple since the mid 1990's, so i cannot personally support building on such platforms. i am happy to accept patches, or even whole new build options (e.g. a MSVC project file), for such platforms, but cannot personally test or maintain them.

Comment by lpsan...@gmail.com, Sep 23, 2009

Two things about building on a 10.5 Mac: 1) There is no ldd. otool -L is supposed to be equivalent. For some, toc2/test/gnu_cpp_test.sh checks for ldd but it does not seemed to be used elsewhere. 2) I'm not getting stuck on looking for libv8/v8.h. I have v8 built in ~/Desktop/build/v8 but running ./configure --v8-prefix=~/Desktop/build/v8 returns...

Looking for libv8 headers and libraries...
=?= find_header? Looking for header file v8.h :-) v8.h :-) find_header? Using v8 CPPFLAGS: -I/Users/lpsantil/Desktop/build/v8/include Searching for v8 library: Debuggering not enabled. Preferring libv8 over libv8_g. Looking for libv8.a Looking for libv8.so Looking for libv8_g.a Looking for libv8_g.so Could not find libv8 any of these paths:
/Users/lpsantil/Desktop/build/v8/libnt/usr/local/libnt/usr/libnt/usr/local/libnt/Users/lpsantil/lib
:-( toc2_die: exiting with error code 127. Missing required v8 library :'-(

It would seem test/message/testcfg.py is getting confused. I'm trying the SConstruct file now.

Comment by project member sgbeal@gmail.com, Sep 24, 2009

The "default" build tools will only work on Unix-like platforms, and Mac isn't quite Unix enough. i'm perfectly happy to accept patches for getting it to work on Mac, but i don't have a Mac (i've boycotted Apple since the mid 1990's), so i can't personally test such patches.

For the second part of the problem, libv8.{so,a} must be somewhere in the search path used by the configure script. The default path is: ${v8_prefix}/lib, PREFIX/lib, /usr/lib, /usr/local/lib, $HOME/lib, where ${v8_prefix} can be specified by passing --v8-prefix to the configure script.

You could also try the scons build, but it's very minimal and requires manual tweaking of the SConstruct file (i'm no scons expert).

Comment by lpsan...@gmail.com, Oct 8, 2009

Ok....I've figured out what's needed to get v8-juice configured w/toc on Max OSX 10.6: 1) Download & build v8 with scons arch=x64 mode=release library=static 2) in $V8_SRC_DIR, do mkdir lib, cp libv8.a lib/ 2) ln -s otool ldd 3) (Using macports), install everything that toc complains about (gmake, findutils, gnutar, and maybe some others, I'll produce what I have installed w/macports below ) 4) configure v8-juice with the --v8-prefix dir

Now I'm off to go try and build v8-juice. Which me luck.

port installed The following ports are currently installed:

apr @1.3.8_0 (active) apr-util @1.3.9_0 (active) autoconf @2.64_2 (active) automake @1.11_0 (active) binutils @2.19_0 (active) bzip2 @1.0.5_3+darwin (active) ccrypt @1.9_0 (active) cryptlib @3.3.3_0+darwin+darwin_10 (active) curl @7.19.6_0 (active) cyrus-sasl2 @2.1.23_0+kerberos (active) db46 @4.6.21_5 (active) diffutils @2.8.1_3 (active) expat @2.0.1_0 (active) findutils @4.4.2_0 (active) fontconfig @2.7.3_0+macosx (active) freetype @2.3.9_1+macosx (active) gdbm @1.8.3_1 (active) gettext @0.17_4 (active) git-core @1.6.4.4_0+doc (active) GitX @0.7.1_0 (active) gmake @3.81_0 (active) gnutar @1.22_1 (active) gperf @3.0.4_0 (active) help2man @1.36.4_1 (active) libiconv @1.13_0 (active) libidn @1.15_0 (active) libmcrypt @2.5.8_1 (active) libtool @2.2.6a_0 (active) m4 @1.4.13_0 (active) mcrypt @2.6.8_0 (active) mhash @0.9.9.9_0 (active) ncurses @5.7_0+darwin_10 (active) ncursesw @5.7_0+darwin_10 (active) neon @0.28.6_0 (active) openssl @0.9.8k_0+darwin (active) p5-error @0.17015_0 (active) p5-locale-gettext @1.05_0 (active) perl5 @5.8.9_0 (active) perl5.8 @5.8.9_3 (active) pkgconfig @0.23_1 (active) popt @1.15_0 (active) python25 @2.5.4_7+darwin_10+macosx (active) python31 @3.1.1_0+darwin (active) readline @6.0.000_2+darwin (active) rsync @3.0.6_0 (active) scons @1.2.0_0 (active) serf @0.3.0_0 (active) sqlite3 @3.6.18_0 (active) subversion @1.6.5_0 (active) tcl @8.5.6_0+darwin (active) tk @8.5.6_1+darwin (active) wget @1.12_0 (active) Xft2 @2.1.13_2 (active) xorg-bigreqsproto @1.1.0_0 (active) xorg-inputproto @1.5.1_0 (active) xorg-kbproto @1.0.3_0 (active) xorg-libX11 @1.2.2_0 (active) xorg-libXau @1.0.5_0 (active) xorg-libXdmcp @1.0.3_0 (active) xorg-libXext @1.0.99.4_1 (active) xorg-libXScrnSaver @1.2.0_0 (active) xorg-renderproto @0.11_0 (active) xorg-scrnsaverproto @1.2.0_0 (active) xorg-util-macros @1.3.0_0 (active) xorg-xcmiscproto @1.2.0_0 (active) xorg-xextproto @7.1.1_0 (active) xorg-xf86bigfontproto @1.2.0_0 (active) xorg-xproto @7.0.16_0 (active) xorg-xtrans @1.2.4_0 (active) xrender @0.9.4_6 (active) zlib @1.2.3_3 (active)

Comment by lpsan...@gmail.com, Oct 8, 2009

make Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src

Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src/include
Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src/include/v8
Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src/include/v8/juice
make4?: Nothing to be done for `all'.
Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src/lib
Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src/lib/juice
Generating c-dlls rules: libv8-juice g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o PathFinder?.o PathFinder?.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o PathFinder?-js.o PathFinder?-js.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o cleanup.o cleanup.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o convert.o convert.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o plugin.o plugin.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o juice.o juice.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o JSClassCreator.o JSClassCreator.cc cc -o ../../../mkdep-toc2 /Users/lpsantil/Desktop/build/v8juice.20091008/toc2/bin/mkdep-toc2.c + cc -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -o whprintf.o whprintf.c g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o jssprintf.o jssprintf.cc g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -o time.o time.cc + g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -I/Users/lpsantil/Desktop/build/v8/include -c -I. -I/Users/lpsantil/Desktop/build/v8juice.20091008/src/include -I/Users/lpsantil/sw/include -o mutex.o mutex.cpp + ar crs libv8-juice.a PathFinder?.o PathFinder?-js.o cleanup.o convert.o plugin.o juice.o JSClassCreator.o whprintf.o jssprintf.o time.o mutex.o g++ -pipe -O2 -DNDEBUG -fPIC -o libv8-juice.so --export-dynamic -shared -Wl,-soname=libv8-juice.so PathFinder?.o PathFinder?-js.o cleanup.o convert.o plugin.o juice.o JSClassCreator.o whprintf.o jssprintf.o time.o mutex.o -ldl -rdynamic ld: unknown option: -soname=libv8-juice.so collect2: ld returned 1 exit status make3?: [libv8-juice.so] Error 1 make2?: [subdir-juice] Error 2 make1?: [subdir-lib] Error 2 make: [subdir-src] Error 2

Comment by lpsan...@gmail.com, Oct 8, 2009

Whoops...the above is as far as I got. :/ I'll work on this more tomorrow.

Comment by project member sgbeal@gmail.com, Oct 10, 2009

i can promise you that the existing build tree WILL NOT build on Mac systems. It (http://toc.sf.net) was designed on/for Linux-like systems (since those are the only ones i work with on a regular basis). Though Mac uses gcc, the options to link libraries on Mac are much different.

There are at least two options:

a) If you are up to the task of patching the build tools, the fix for the above problem should go in toc2/make/c-dlls.make.

b) Try building with scons (be sure to edit the top-level SConstruct file to suit your system).

Comment by skopsyc...@gmail.com, Dec 11, 2009

I get this as an error when running make, any ideas?

Making 'all' in /home/vonkow/libv8-juice-20091115/src

Making 'all' in /home/vonkow/libv8-juice-20091115/src/include
Making 'all' in /home/vonkow/libv8-juice-20091115/src/include/v8
Making 'all' in /home/vonkow/libv8-juice-20091115/src/include/v8/juice
make4?: Nothing to be done for `all'.
Making 'all' in /home/vonkow/libv8-juice-20091115/src/lib
Making 'all' in /home/vonkow/libv8-juice-20091115/src/lib/juice
make3?: Nothing to be done for `all'.
Making 'all' in /home/vonkow/libv8-juice-20091115/src/lib/plugins
make3?: Nothing to be done for `all'.
Making 'all' in /home/vonkow/libv8-juice-20091115/src/client
Making 'all' in /home/vonkow/libv8-juice-20091115/src/client/shell
+ g++ -pipe -O2 -DNDEBUG -fPIC -I. -I/home/vonkow/libv8-juice-20091115/src/include -I/home/vonkow/include -I/home/vonkow/v8-read-only/include -o v8-juice-shell shell.o -L../../../src/lib/juice -lv8-juice -ldl -rdynamic -L/home/vonkow/v8-read-only/lib -lv8 -lpthread /usr/bin/ld: v8-juice-shell: hidden symbol `v8::String::AsciiValue?::AsciiValue?(v8::Handle<v8::Value>)' in /home/vonkow/v8-read-only/lib/libv8.a(api.o) is referenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status make3?: [v8-juice-shell] Error 1 make2?: shell? Error 2 make1?: [subdir-client] Error 2 make: [subdir-src] Error 2

Comment by project member sgbeal@gmail.com, Dec 12, 2009

That's a new one. The "hidden symbol" bit is key. It seems to be telling us that the AsciiValue(Handle<Value>) ctor is private. i think. If you will email me the v8 version number you're using i can try to reproduce it here. My email address can be found via the first paragraph of the Contributing page.

Comment by skopsyc...@gmail.com, Dec 12, 2009

it's 2.0.3, I just sucked it down from subversion last night

Comment by project member sgbeal@gmail.com, Dec 12, 2009

i just tried v8 r.3334 (from bleeding_edge) and r.3456 (from trunk) and couldn't reproduce the problem. i'm using gcc 4.4.1, and haven't tried any other versions. i have no clue what the problem is. In nearly 20 years of C and 10 years of C++ i've never seen that link error before.

Comment by tdnord...@gmail.com, Apr 8, 2010

I had a similar problem when trying to build v8-juice against v8 r.4346. I resolved the problem by building v8 as a shared library instead of a static library.

Hope that helps.

Comment by project member sgbeal@gmail.com, Apr 8, 2010

@tdnordine: v8-juice's plugin model cannot work as a static library because it relies on code being run in the static initialization phase. That phase doesn't happen in static libraries. i should put that more prominently in the docs.

Comment by florent....@gmail.com, Jun 1, 2010

Hello, I had no problem building and installing the library. But I can't get a program or another shared object to link correctly against libv8-juice.so.

even a hello world program compiled with gcc: $ gcc -fPIC -lv8 -lv8-juice -o helloworld helloworld.c

it compiles fine but when I try to run it I get: $ ./helloworld ./helloworld: error while loading shared libraries: libv8-juice.so: cannot open shared object file: No such file or directory

$ ldd helloworld

linux-gate.so.1 => (0x009e8000) libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x00e48000) libv8-juice.so => not found libv8.so => /usr/local/lib/libv8.so (0x004e3000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x0014a000) /lib/ld-linux.so.2 (0x0012d000) libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x00e53000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x002ab000) libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00945000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00fad000)

$ ls /usr/local/lib libv8.a libv8-juice.so libv8.so node python2.6

so there should be no problem. I'm on ubuntu 10.04 32bits with an Atom processor. (as I found that this problem can be caused by 32/64bits incompatibilities) that's why I add this command: $ file /usr/local/lib/libv8-juice.so /usr/local/lib/libv8-juice.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

has anybody else this issue ? has anyone a solution ?

Comment by project member sgbeal@gmail.com, Jun 2, 2010

That's not a build problem but a misunderstanding of how to set up your environment so that the dynamic linker can find the library. You must add libv8-juice.so somewhere in your so-called "library path." Try googling for "LD_LIBRARY_PATH".

Comment by florent....@gmail.com, Jun 2, 2010

Hello. thanks for you answer, there should be no problem with the path as libv8-juice is int /usr/local/lib (which is already in the linker's path). Additionnally my LD_LIBRARY_PATH is empty by default (don't know why, but it's the fact).

anyway, silly me. one night and a reboot after my question, it works fine... --' sorry. The linker must update his paths on reboot. I know there must be a way of updating this by command, but I don't know it. maybe some options in ldconfig.

Comment by project member sgbeal@gmail.com, Nov 26, 2010

A bit late, but maybe helpful to someone else down the line: to update the linker cache without rebooting, use "ldconfig" (or "sudo ldconfig" if you're not the root user).

Comment by abhishek...@gmail.com, Dec 8, 2010

I'll to make sqlite3 plugin for V8-juice. And getting the error when running make of sqlite3, any idea??? ../plugin_template.make:32: /c-dlls.make: No such file or directory make: No rule to make target `/c-dlls.make'. Stop.

Comment by project member sgbeal@gmail.com, Dec 8, 2010

i'm just guessing because i have no idea what platform you're on, but my suspicion is that your version of "make" is either not GNU Make or it is GNU Make 3.80 or earlier. If that is the case, either get GNU Make 3.81+ or write custom makefiles. Optionally, you can try using the scons build from the 'extra-plugins' directory. If you can send me more details about your problem i might be able to provide more info, but please send them directly to me (http://wanderinghorse.net/home/stephan/) instead of posting them here in the wiki.

Comment by jimme...@gmail.com, Jan 20, 2011

cd /usr/bin sudo touch ldd sudo chmod +x ldd sudo nano ldd

#!/bin/bash otool -L $@

Save & Exit

Comment by project member sgbeal@gmail.com, Jan 20, 2011

The newlines got lost in translation there. Is that an "ldd" equivalent for Mac, or what is it? Linux systems already have /usr/bin/ldd.

Comment by golgo...@gmail.com, Nov 5, 2011

Glad you've decided to go along with the whole cross platform thing <dripping with sarcasm>. Isn't that the whole point of JavaScript??


Sign in to add a comment
Powered by Google Project Hosting