|
BuildingTheCode
Configuring and building the source tree
Phase-UserDocs, Phase-Implementation, Featured, Topic-Project
Requirements and prerequisitesCaveat #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 compilingThe 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:
See SourceTreeOverview for info on how the tree is laid out. InstallationRun 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):
The makefile also supports make uninstall. Using SConsAs of 20090313 the tree has very minimal support for a build using 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 MacGood 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. |
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...
=?= 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: :-( 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.
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).
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:
make Making 'all' in /Users/lpsantil/Desktop/build/v8juice.20091008/src
make4?: Nothing to be done for `all'. 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 2Whoops...the above is as far as I got. :/ I'll work on this more tomorrow.
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).
I get this as an error when running make, any ideas?
Making 'all' in /home/vonkow/libv8-juice-20091115/src
make4?: Nothing to be done for `all'. make3?: Nothing to be done for `all'. make3?: Nothing to be done for `all'. + 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 2That'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.
it's 2.0.3, I just sucked it down from subversion last night
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.
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.
@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.
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
$ 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 ?
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".
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.
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).
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.
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.
cd /usr/bin sudo touch ldd sudo chmod +x ldd sudo nano ldd
#!/bin/bash otool -L $@
Save & Exit
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.
Glad you've decided to go along with the whole cross platform thing <dripping with sarcasm>. Isn't that the whole point of JavaScript??