InstallingLuabind

Version 17 (rti, 11/17/2010 12:20 am)

1 2 rti
h1. Installing Luabind on Linux, Mac OS X, ...
2 1 rti
3 1 rti
Since luabind is not available from macports (I think certain Linux Distributions do not provide it too), here the short summary how to install luabind on a Unix like system :)
4 1 rti
5 4 tnxgalaxy
h2. Installing lua
6 1 rti
7 1 rti
To build luabind, you need liblua. Install it, for example on a Mac using macports:
8 1 rti
<pre>
9 1 rti
sudo port install lua
10 1 rti
</pre>
11 4 tnxgalaxy
On Ubuntu 10.04:
12 4 tnxgalaxy
<pre>
13 4 tnxgalaxy
sudo apt-get install liblua5.1-0-dev
14 4 tnxgalaxy
</pre>
15 1 rti
16 6 TomH
On CentOS 5+
17 6 TomH
18 6 TomH
<pre>
19 8 TomH
yum install lua-devel
20 6 TomH
</pre>
21 6 TomH
22 1 rti
h2. Getting the source
23 1 rti
24 1 rti
While writing this, the most current version is 0.9. Get it!
25 4 tnxgalaxy
On Mac OS X:
26 1 rti
<pre>
27 4 tnxgalaxy
curl -O http://sunet.dl.sourceforge.net/project/luabind/luabind/0.9/luabind-0.9.tar.gz
28 4 tnxgalaxy
</pre>
29 4 tnxgalaxy
30 4 tnxgalaxy
On Linux:
31 4 tnxgalaxy
<pre>
32 1 rti
wget http://sunet.dl.sourceforge.net/project/luabind/luabind/0.9/luabind-0.9.tar.gz
33 1 rti
</pre>
34 1 rti
35 15 molator
Alternativly, you can take the source on Kervala's repository
36 13 molator
<pre>
37 16 kervala
svn checkout http://svn.kervala.net/utils/packaging/luabind
38 13 molator
</pre>
39 13 molator
40 14 molator
That version includes a cmake config and allows to build a debian package.
41 13 molator
42 1 rti
h2. Extract the source
43 1 rti
44 1 rti
<pre>
45 1 rti
tar zxf luabind-0.9.tar.gz
46 1 rti
</pre>
47 1 rti
48 1 rti
h2. Building and installing
49 16 kervala
50 16 kervala
h3. All CMake platforms
51 16 kervala
52 16 kervala
If you downloaded sources from http://svn.kervala.net/utils/packaging/luabind, you just need to type
53 16 kervala
54 16 kervala
<pre>
55 16 kervala
cd luabind
56 16 kervala
mkdir build
57 16 kervala
cd build
58 16 kervala
cmake ..
59 16 kervala
60 16 kervala
# with STLport, append: -DWITH_STLPORT=ON
61 16 kervala
# in static, append: -DWITH_STATIC=ON
62 16 kervala
# for Mac OS X, append: -DCMAKE_INSTALL_PREFIX=/opt/local
63 16 kervala
64 16 kervala
make
65 16 kervala
sudo make install
66 16 kervala
</pre>
67 1 rti
68 5 tnxgalaxy
h3. On Ubuntu 10.04:
69 1 rti
70 4 tnxgalaxy
install boost build:
71 4 tnxgalaxy
<pre>
72 9 molator
sudo apt-get install boost-build libboost-dev
73 4 tnxgalaxy
</pre>
74 4 tnxgalaxy
75 4 tnxgalaxy
and compile / install with the following command:
76 4 tnxgalaxy
<pre>
77 4 tnxgalaxy
sudo bjam --prefix=/usr/local install
78 4 tnxgalaxy
</pre>
79 1 rti
80 10 noxxy
h3. On Gentoo
81 11 noxxy
82 10 noxxy
if boost-build package is not installed:
83 10 noxxy
<pre>
84 10 noxxy
sudo emerge boost-build -av
85 10 noxxy
</pre>
86 11 noxxy
87 10 noxxy
and compile /install with the following command: (replace 1_41 by your version of bjam)
88 10 noxxy
<pre>
89 10 noxxy
sudo bjam-1_41 --prefix=/usr/local install
90 10 noxxy
</pre>
91 12 noxxy
check if lib is named correctly. 
92 12 noxxy
<pre>
93 12 noxxy
ls /usr/local/lib/libluabind*.so
94 12 noxxy
</pre>
95 12 noxxy
if lib si named libluabindd.so create a symlink
96 12 noxxy
<pre>
97 12 noxxy
sudo ln -s /usr/local/lib/libluabindd.so /usr/local/lib/libluabind.so
98 12 noxxy
</pre>
99 12 noxxy
100 10 noxxy
101 5 tnxgalaxy
h3. On Mac OS X:
102 5 tnxgalaxy
103 17 rti
Kervala's repository works great on Mac OS X as well. Just do:
104 17 rti
<pre>
105 17 rti
svn checkout http://svn.kervala.net/utils/packaging/luabind
106 17 rti
cd luabind
107 17 rti
mkdir build
108 17 rti
cd build
109 17 rti
cmake ..
110 17 rti
make
111 17 rti
sudo make install
112 17 rti
</pre>
113 17 rti
114 17 rti
Thats all!
115 17 rti
116 17 rti
*The following method is deprecated!*
117 17 rti
118 5 tnxgalaxy
Bjam might be annoying and complicated, use this small build script. Put it in the luabind root directory.
119 4 tnxgalaxy
120 1 rti
This script is configured for a Mac OS X having lua and boost installed in /opt/local (using macports).
121 1 rti
Please adjust LUA_INCLUDE_DIR, LUA_LIBRARY_DIR and LIB_EXTENSION if you have a different setup.
122 1 rti
<pre>
123 1 rti
#!/bin/sh
124 1 rti
125 1 rti
LUA_INCLUDE_DIR=/opt/local/include
126 1 rti
LUA_LIBRARY_DIR=/opt/local/lib
127 1 rti
LIB_EXTENSION=dylib
128 1 rti
129 1 rti
rm -rf build
130 1 rti
mkdir -p build/src
131 1 rti
132 1 rti
for i in src/*.cpp
133 1 rti
do 
134 1 rti
	gcc -I$LUA_INCLUDE_DIR -I. -fPIC -c $i -o build/$i.o
135 1 rti
done
136 1 rti
137 1 rti
gcc -shared -o build/libluabind.$LIB_EXTENSION build/src/*.o \
138 1 rti
	-L$LUA_LIBRARY_DIR -lstdc++ -llua
139 1 rti
</pre>
140 1 rti
141 1 rti
To install the thing, just copy lib and header into the preferred path. For example:
142 1 rti
143 1 rti
<pre>
144 7 vl
sudo mkdir -p /usr/local/include
145 1 rti
sudo cp -r luabind /usr/local/include
146 7 vl
sudo mkdir -p /usr/local/lib
147 1 rti
sudo cp build/libluabind.* /usr/local/lib
148 1 rti
</pre>
149 1 rti
150 1 rti
h2. Thats all
151 1 rti
152 1 rti
Hope that works for you. 
153 1 rti
Have fun!