LMTS/pcre for Linux

by Valaria

Back to Project L.

Valaria2007-11-23 12:00:10
Greetings Fair Citizens of Lusternia, I have work with sweats and struggle to find a way to have lrexlib to work with LMTS. have no fear for I brings you a good news, I have found a solution to thine problem.

Continue on, if you are eager to learn the tale how to harness the power of lrexlib on...

LINUX.

otherwise, window user can find other thread to find some interests that are relative to them! Begone!
*ahem*

now.. now.. where am I... AH!

please begin learn 15 lessons in lmts-on-linux from me...

*LEARN 15 LMTS-ON-LINUX FROM VALARIA*

*blah blah blah.... (boring and dull scroll about how amazing it is the power of lmts*)


Intro
1. The purpose of this thread is to help you, the linux user, to learn how to compile and run the lua file that use lrexlib library that enables you to use PCRE for the purpose of triggers and other thing.

2. Also teach how to.. uh... compiles the lmts program too!


Disclaimer
1. This procedure has been done on Ubuntu Linux(Gusty Gibbon)... So I am not sure about your distro will work if it differs from Ubuntu.

2. Lua and lrexlib are slightly customized(just makefiles). So that way it may work for LMTS program.
2.a Lua: makefile has been customized so it can include .so too. Originally, in default lua it didn't this for a reason.(in version 5.1.2 lua)

3. I am not expert in land of linux; But, I can do what I can with my current Knowledge


Procedure
1. First, Fire up the Terminal. Yes, Terminal. You can find it on the menu: Applications->Accesories->Terminal.


For Ubuntu User, You will need the Essential set of compilers, make or whatever in order to make/compile some files.
CODE
sudo apt-get build-essential


Before you compiles those files, there are some libraries require in order for those to compile smoothly.


For librexlib.. specifically... pcre version.
PCRE6 - perl parsing library
CODE
sudo apt-get install libpcre3
sudo apt-get install libpcre3-dev


For lmts, specifically MCCP.
Zlib - compression library
CODE
apt-get install zlibc
apt-get install zlib1g-dev


for lua.
readline lib - to read line and history.
CODE
sudo apt-get install libreadline5-dev


Finally...
SVN (you may need it to download LMTS later)
CODE
sudo apt-get svn


Now let move on to.... getting the actual files of customized Lua and lrexlib from my website.
CODE
wget http://aetherweaving.googlepages.com/lua-5.1.2-cus.tar.gz
wget http://aetherweaving.googlepages.com/lrexlib-cus.tar.gz


Next, let get Lmts from lmts's sourceforge website by using SVN.
CODE
cd ~/
svn co https://lmts.svn.sourceforge.net/svnroot/lmts lmts


what it do is that it will create lmts directionary on your home folder and all files in it.

Next, unzip lua and lrexlib with your favorite archieve program. make sure to unzip it at ~/ directory (your home directory).

Finally let compile lmts!

WAIT! I forgot about lua. Let compile Lua first. Then lrexlib and lmts. So we can get lrexlib and lmts's i_lua library to work thereafter properly!

Let enter in the Tower of Lua who in need of Construction to be complete...
CODE
cd ~/lua*


Build the tower of Lua...
CODE
make linux


And thou shall recieves thy reward.
CODE
sudo make install


that was easy is it? now let get lrexlib built too.

You attempt to conjures and bring lrexlib to life by using Forbidden Knowledge of Necromancy in tower of Lua.
CODE
cd ~/lrexlib*
make rex_pcre


it compiles without any error? good! the problem is that it dont have the install option.. so i will help you by move the pcre library over to /usr/local/lib

Exerts such extraordinary power, you commands your first zombie, lrexlib, to move.
CODE
sudo mv /src/rex_pcre.so.2.2 /usr/local/lib


lastly, let make syslink to rex_pcre.so.2.2.. That way you can find it by REQUIRE in lua script later.

You admires your lovely creation. You name your first zombie, "rex_pcre".
CODE
sudo ln -s /usr/local/lib/rex_pcre.so.2.2 /usr/local/lib/rex_pcre.so


Finally, let compiles LMTS at long last!

after many years of research, you finally learn the secret of LMTS. You attempts to summon the worthy beast of all, the fearsome Soulless God called... LMTS... and suceed. People of Lusternia shall now fears in terror. Forever Lusternia in the age of darkness. Soulless God LMTS rewards for your fruitful work.. by eat you whole in one big gulp.
CODE
cd ~/lmts
make


that it! voila!

now let run your bot to see if it running well enough.
CODE
./bot

P.S. i will post next thread about how to use lua script with LMTS. smile.gif (with rex_pcre of course).

Problem?
If you have problem, please let me know by PM or post it here. Thanks! I will try my best to fix the problem for you! Athough not always.

F.A.Q

Glossary
ln - it is a link(conceptally, 'alias'), that let you link to an original file. -s option is to make a system/symbolic link.
sudo - sudo that grant you a temporary administrative(a.k.a elder god) power to perform sensetive command on terminal once.
apt-get - apt-get is a program that let you to install certain package over on the web or on your computer.
~/ - equal to /home/(username)
mv - a.k.a 'move. it is also used to rename file. 'mv uglyfile prettyfile'
Simimi2007-11-23 12:11:56
Nice thread! Might want to have the users check for "build-essential" since Ubuntu does not provide build tools standard anymore.
Valaria2007-11-23 12:44:17
okay gotcha, I have updated the OP post. thanks!
Vulcanius2007-11-23 19:24:42
Problem and Fix

Some users may encounter problems when making lua. Specifically something that looks like this...

QUOTE
gcc -O2 -Wall -DLUA_USE_LINUX -c -o loslib.o loslib.c
gcc -O2 -Wall -DLUA_USE_LINUX -c -o ltablib.o ltablib.c
gcc -O2 -Wall -DLUA_USE_LINUX -c -o lstrlib.o lstrlib.c
gcc -O2 -Wall -DLUA_USE_LINUX -c -o loadlib.o loadlib.c
gcc -O2 -Wall -DLUA_USE_LINUX -c -o linit.o linit.c
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o
ranlib liblua.a
gcc -O2 -Wall -DLUA_USE_LINUX -c -o lua.o lua.c
In file included from lua.h:16,
from lua.c:15:
luaconf.h:275:31: error: readline/readline.h: No such file or directory
luaconf.h:276:30: error: readline/history.h: No such file or directory
lua.c: In function ‘pushline’:
lua.c:180: warning: implicit declaration of function ‘readline’
lua.c:180: warning: assignment makes pointer from integer without a cast
lua.c: In function ‘loadline’:
lua.c:208: warning: implicit declaration of function ‘add_history’
make: *** Error 1
make: Leaving directory `/home/vulcanius/lua-5.1.2/src'
make: *** Error 2
make: Leaving directory `/home/vulcanius/lua-5.1.2/src'
make: *** Error 2


This problem occurs when the readline library is not installed.

To fix this on Ubuntu you can simply do "sudo apt-get install libreadline5-dev" and then of course you'll need to "make clean" before doing another "make linux". After installing the readline library everything should work perfectly.

Excellent work Valaria, I was looking for something exactly like this yesterday and this morning.
Valaria2007-11-23 20:04:01
ah execellent, thanks for reply. i will update my OP post about it then too!
Simimi2007-11-25 13:18:57
I get errors on every step when trying to do this, starting with make linux and then make rex_pcre...
CODE
~/lua-5.1.2$ make linux
cd src && make linux
make: Entering directory `/home/simimi/lua-5.1.2/src'
make all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
make: Entering directory `/home/simimi/lua-5.1.2/src'
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lapi.o lapi.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lcode.o lcode.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ldebug.o ldebug.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ldo.o ldo.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ldump.o ldump.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lfunc.o lfunc.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lgc.o lgc.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o llex.o llex.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lmem.o lmem.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lobject.o lobject.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lopcodes.o lopcodes.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lparser.o lparser.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lstate.o lstate.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lstring.o lstring.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ltable.o ltable.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ltm.o ltm.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lundump.o lundump.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lvm.o lvm.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lzio.o lzio.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lauxlib.o lauxlib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lbaselib.o lbaselib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ldblib.o ldblib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o liolib.o liolib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lmathlib.o lmathlib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o loslib.o loslib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o ltablib.o ltablib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lstrlib.o lstrlib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o loadlib.o loadlib.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o linit.o linit.c
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o
ranlib liblua.a
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o lua.o lua.c
gcc -o lua  lua.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o luac.o luac.c
gcc -O2 -Wall -DLUA_USE_LINUX   -c -o print.o print.c
gcc -o luac  luac.o print.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
gcc -o liblua.so -shared lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o
/usr/bin/ld: lapi.o: relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object; recompile with -fPIC
lapi.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** Error 1
make: Leaving directory `/home/simimi/lua-5.1.2/src'
make: *** Error 2
make: Leaving directory `/home/simimi/lua-5.1.2/src'
make: *** Error 2

And later...
CODE
~/lrexlib$ make rex_pcre
make -C src -f rex_pcre.mak
make: Entering directory `/home/simimi/lrexlib/src'
gcc -W -Wall -g -I/usr/locate/include/  -DREX_OPENLIB=luaopen_rex_pcre -DREX_LIBNAME=\\"rex_pcre\\"    -c -o lpcre.o lpcre.c
gcc -W -Wall -g -I/usr/locate/include/  -DREX_OPENLIB=luaopen_rex_pcre -DREX_LIBNAME=\\"rex_pcre\\"    -c -o lpcre_f.o lpcre_f.c
gcc -W -Wall -g -I/usr/locate/include/  -DREX_OPENLIB=luaopen_rex_pcre -DREX_LIBNAME=\\"rex_pcre\\"    -c -o common.o common.c
ar rcu librex_pcre.a lpcre.o lpcre_f.o common.o
ld -o rex_pcre.so.2.2 -shared lpcre.o lpcre_f.o common.o -lpcre -llua5.1
ld: lpcre.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
lpcre.o: could not read symbols: Bad value
make: *** Error 1
make: Leaving directory `/home/simimi/lrexlib/src'
make: *** Error 2


losewings.gif
Unknown2007-11-25 19:31:19
Just a quick reply, but it seems to be an AMD-64 related problem.

Link with information: http://www.gentoo.org/proj/en/base/amd64/h...rt=1&chap=3
Simimi2007-11-26 04:19:18
Knew I should have installed 32bit Linux...
Vulcanius2007-11-26 19:02:42
Personally I keep both 32 and 64 bit installs, I'll use 32 bit for just about everything and only switch to 64 bit when I need to do some crunching.
Vadi2007-11-27 13:27:53
One can use a quick spell and be lazy:

CODE
sudo apt-get install build-essential libpcre3 libpcre3-dev zlibc zlib1g-dev libreadline5-dev svn
Valaria2007-11-28 12:55:21
you forgot the 'install' part... ->apt-get install?


I never knew it is easy to install all with just one line. smile.gif
Vadi2007-11-28 15:14:33
Yes I did, fixed now.

And most of the commands accept multiple arguments like that... thats when the terminal gets really handy (like when I had to create 100+ folders yesterday. I'm so glad I know the mkdir command)
relaren2008-05-13 23:17:31
QUOTE(Valaria @ Nov 23 2007, 01:00 PM) 459907
sudo mv /src/rex_pcre.so.2.2 /usr/local/lib


Should in fact read:
CODE
sudo mv src/rex_pcre.so.2.2 /usr/local/lib


-Very- slight difference, though is rather essential smile.gif

Oh, and please forgive me if this was already pointed out, though the fact it remains on the thread, suggests that it in fact has not been.

Enjoy!