on i4PACE(i for Personal Archiving and Creating Environment)
actions » SearchLogin 89 articles • 30 Jul 2010

Recent articles in 'c'

Tuesday, 08 Sep 2009

permalink Wt

Try a C++ based Wt library for developing web applications.

On Ubuntu, use apt-get

> sudo apt-get install witty witty-dbg witty-dev witty-doc

(ref.http://www.webtoolkit.eu/wt/wiki/index.php/Installing_Wt_on_Ubuntu)

Try examples.

> mkdir ~/wt
> cd wt
> cmake -DWT_SOURCE_DIR=/usr/share/doc/witty-doc/ -DEXAMPLES_CONNECTOR="wt;wthttp" /usr/share/doc/witty-doc/examples

Oops, need to install cmake.

> sudo apt-get install cmake

Running cmake again created a directory ~/wt/wt-homepage and ~/wt/wtwithqt.

Oops, again. need to install libboost

> apt-get install libboost1.35-dev libboost1.35-dbg

Gee, a lot of files are dependant... 60.7MB download and 358MB disk space consumed o_o

Well, done. Running cmake

> cmake -DWT_SOURCE_DIR=/usr/share/doc/witty-doc/ -DEXAMPLES_CONNECTOR="wt;wthttp" /usr/share/doc/witty-doc/examples

terminal output

> ~/wt$ cmake -DWT_SOURCE_DIR=/usr/share/doc/witty-doc/ -DEXAMPLES_CONNECTOR="wt;wthttp" /usr/share/doc/witty-doc/examples
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 2.6)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- ** Filetreetable example needs boost_filesystem library... Skipping.
-- ** Form example needs boost_date_time library... Skipping.
-- ** Mandelbrot example needs gd library... Skipping.
-- ** Serverpush example needs boost with thread support... Skipping.
-- ** Style example needs gd library... Skipping.
-- ** hangman example needs mysql++-2.x library... Skipping.
-- ** Wt/Qt interopability example (wtwithqt) needs Qt4... Skipping.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/laurel/wt

Hmmm, some examples are skipped... i found on the mailing list for Wt, it's a bug. will need to build Wt from the current souce to run these skipped examples. Anyhow, see what's created

> cd ~/wt
> ls
CMakeCache.txt  charts               dragdrop       hangman     mission     treelist       wtwithqt
CMakeFiles      cmake_install.cmake  extkitchen     hello       painting    treeview
Makefile        composer             filetreetable  javascript  simplechat  widgetgallery
bobsmith        dialog               form           mandelbrot  style       wt-homepage

Oh, lots :-D

Run make

> make
laurel@laurel:~/wt$ make
Scanning dependencies of target bobsmith.wt
[  1%] Building CXX object bobsmith/CMakeFiles/bobsmith.wt.dir/bobsmith.o
Linking CXX executable bobsmith.wt
[  1%] Built target bobsmith.wt
Scanning dependencies of target charts.wt
[  3%] Building CXX object charts/CMakeFiles/charts.wt.dir/PanelList.o
[  5%] Building CXX object charts/CMakeFiles/charts.wt.dir/ChartConfig.o
[  6%] Building CXX object charts/CMakeFiles/charts.wt.dir/ChartsExample.o
[  8%] Building CXX object charts/CMakeFiles/charts.wt.dir/CsvUtil.o
[ 10%] Building CXX object charts/CMakeFiles/charts.wt.dir/ChartsApplication.o
Linking CXX executable charts.wt
[ 10%] Built target charts.wt
Scanning dependencies of target composer.wt
[ 11%] Building CXX object composer/CMakeFiles/composer.wt.dir/AddresseeEdit.o
[ 13%] Building CXX object composer/CMakeFiles/composer.wt.dir/AttachmentEdit.o
[ 15%] Building CXX object composer/CMakeFiles/composer.wt.dir/ComposeExample.o
[ 16%] Building CXX object composer/CMakeFiles/composer.wt.dir/Composer.o
[ 18%] Building CXX object composer/CMakeFiles/composer.wt.dir/ContactSuggestions.o
[ 20%] Building CXX object composer/CMakeFiles/composer.wt.dir/Label.o
[ 21%] Building CXX object composer/CMakeFiles/composer.wt.dir/Option.o
[ 23%] Building CXX object composer/CMakeFiles/composer.wt.dir/OptionList.o
Linking CXX executable composer.wt
[ 23%] Built target composer.wt
Scanning dependencies of target dialog.wt
[ 25%] Building CXX object dialog/CMakeFiles/dialog.wt.dir/DialogExample.o
Linking CXX executable dialog.wt
[ 25%] Built target dialog.wt
Scanning dependencies of target dragdrop.wt
[ 26%] Building CXX object dragdrop/CMakeFiles/dragdrop.wt.dir/Character.o
[ 28%] Building CXX object dragdrop/CMakeFiles/dragdrop.wt.dir/DragExample.o
[ 30%] Building CXX object dragdrop/CMakeFiles/dragdrop.wt.dir/DragApplication.o
Linking CXX executable dragdrop.wt
[ 30%] Built target dragdrop.wt
Scanning dependencies of target extkitchen.wt
[ 31%] Building CXX object extkitchen/CMakeFiles/extkitchen.wt.dir/ExtKitchenApplication.o
[ 33%] Building CXX object extkitchen/CMakeFiles/extkitchen.wt.dir/CsvUtil.o
Linking CXX executable extkitchen.wt
[ 33%] Built target extkitchen.wt
Scanning dependencies of target hello.wt
[ 35%] Building CXX object hello/CMakeFiles/hello.wt.dir/hello.o
Linking CXX executable hello.wt
[ 35%] Built target hello.wt
Scanning dependencies of target javascript.wt
[ 36%] Building CXX object javascript/CMakeFiles/javascript.wt.dir/JavascriptExample.o
[ 38%] Building CXX object javascript/CMakeFiles/javascript.wt.dir/Popup.o
Linking CXX executable javascript.wt
[ 38%] Built target javascript.wt
Scanning dependencies of target impossible.wt
[ 40%] Building CXX object mission/CMakeFiles/impossible.wt.dir/impossible.o
[ 41%] Building CXX object mission/CMakeFiles/impossible.wt.dir/CountDownWidget.o
Linking CXX executable impossible.wt
[ 41%] Built target impossible.wt
Scanning dependencies of target paintexample.wt
[ 43%] Building CXX object painting/CMakeFiles/paintexample.wt.dir/PaintApplication.o
[ 45%] Building CXX object painting/CMakeFiles/paintexample.wt.dir/PaintExample.o
[ 46%] Building CXX object painting/CMakeFiles/paintexample.wt.dir/ShapesWidget.o
Linking CXX executable paintexample.wt
[ 46%] Built target paintexample.wt
Scanning dependencies of target demotreelist.wt
[ 48%] Building CXX object treelist/CMakeFiles/demotreelist.wt.dir/DemoTreeList.o
[ 50%] Building CXX object treelist/CMakeFiles/demotreelist.wt.dir/IconPair.o
[ 51%] Building CXX object treelist/CMakeFiles/demotreelist.wt.dir/TreeNode.o
Linking CXX executable demotreelist.wt
[ 51%] Built target demotreelist.wt
Scanning dependencies of target treeviewexample.wt
[ 53%] Building CXX object treeview/CMakeFiles/treeviewexample.wt.dir/TreeViewExample.o
[ 55%] Building CXX object treeview/CMakeFiles/treeviewexample.wt.dir/TreeViewApplication.o
Linking CXX executable treeviewexample.wt
[ 55%] Built target treeviewexample.wt
Scanning dependencies of target Home.wt
[ 56%] Building CXX object wt-homepage/CMakeFiles/Home.wt.dir/Home.o
[ 58%] Building CXX object wt-homepage/CMakeFiles/Home.wt.dir/TreeListExample.o
[ 60%] Building CXX object wt-homepage/CMakeFiles/Home.wt.dir/__/treelist/TreeNode.o
[ 61%] Building CXX object wt-homepage/CMakeFiles/Home.wt.dir/__/treelist/IconPair.o
Linking CXX executable Home.wt
[ 61%] Built target Home.wt
Scanning dependencies of target widgetgallery.wt
[ 63%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/main.o
[ 65%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/BasicControls.o
[ 66%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/ChartWidgets.o
[ 68%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/ControlsWidget.o
[ 70%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/DialogWidgets.o
[ 71%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/EventsDemo.o
[ 73%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/EventDisplayer.o
[ 75%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/WidgetGallery.o
[ 76%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/ExtWidgets.o
[ 78%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/FormWidgets.o
[ 80%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/GraphicsWidgets.o
[ 81%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/MvcWidgets.o
[ 83%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/Validators.o
[ 85%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/StyleLayout.o
[ 86%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/charts/ChartsExample.o
[ 88%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/charts/ChartConfig.o
[ 90%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/charts/CsvUtil.o
[ 91%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/charts/PanelList.o
[ 93%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/dragdrop/Character.o
[ 95%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/dragdrop/DragExample.o
[ 96%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/painting/PaintExample.o
[ 98%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/painting/ShapesWidget.o
[100%] Building CXX object widgetgallery/CMakeFiles/widgetgallery.wt.dir/__/treeview/TreeViewExample.o
Linking CXX executable widgetgallery.wt
[100%] Built target widgetgallery.wt

Success :-)

• Wrote Teru at 13:31 (edited 5×, last on 09 Sep 2009) | read 128× | 2 Comments

Thursday, 20 Aug 2009

permalink Tokyo Tyrant

OK, start installing Tokyo Tyrant, following the instruction at http://tokyocabinet.sourceforge.net/tyrantdoc/. It's a database management server for concurrent and remote access to Tokyo Cabinet database. Its features include hot backup, update logging, and replication.

Download the source at http://tokyocabinet.sourceforge.net/tyrantpkg/tokyotyrant-1.1.33.tar.gz. Did

> tar xzvf tokyotyrant-1.1.33.tar.gz 
> cd tokyotyrant-1.1.33/
> ./configure
> make
> sudo make install

Success. Ran ttserver

> ttserver
2009-08-20T15:25:34+09:00	SYSTEM	--------- logging started [4180] --------
2009-08-20T15:25:34+09:00	SYSTEM	server configuration: host=(any) port=1978
2009-08-20T15:25:34+09:00	SYSTEM	opening the database: *
2009-08-20T15:25:34+09:00	SYSTEM	service started: 4180
2009-08-20T15:25:34+09:00	INFO	timer thread 1 started
2009-08-20T15:25:34+09:00	INFO	worker thread 1 started
2009-08-20T15:25:34+09:00	INFO	worker thread 2 started
2009-08-20T15:25:34+09:00	INFO	worker thread 3 started
2009-08-20T15:25:34+09:00	INFO	worker thread 4 started
2009-08-20T15:25:34+09:00	INFO	worker thread 5 started
2009-08-20T15:25:34+09:00	INFO	worker thread 6 started
2009-08-20T15:25:34+09:00	INFO	worker thread 7 started
2009-08-20T15:25:34+09:00	INFO	worker thread 8 started
2009-08-20T15:25:34+09:00	SYSTEM	listening started

OK. While the server is still up, ran

> make check

Got

#================================================================
# Checking completed.
#================================================================

at the end on terminal. OK.

The author of Tokyo Tyrant, Mikio HIRABAYASHI wrote a blog about it here (in Japanese). Launched a TT server

> ttserver '/tmp/caskettch#num=1000'
2009-08-21T15:08:08+09:00	SYSTEM	--------- logging started [5714] --------
2009-08-21T15:08:08+09:00	SYSTEM	server configuration: host=(any) port=1978
2009-08-21T15:08:08+09:00	SYSTEM	opening the database: /tmp/casket.tch#bnum=1000
2009-08-21T15:08:08+09:00	SYSTEM	service started: 5714
2009-08-21T15:08:08+09:00	INFO	timer thread 1 started
2009-08-21T15:08:08+09:00	INFO	worker thread 1 started
2009-08-21T15:08:08+09:00	INFO	worker thread 2 started
2009-08-21T15:08:08+09:00	INFO	worker thread 3 started
2009-08-21T15:08:08+09:00	INFO	worker thread 4 started
2009-08-21T15:08:08+09:00	INFO	worker thread 5 started
2009-08-21T15:08:08+09:00	INFO	worker thread 6 started
2009-08-21T15:08:08+09:00	INFO	worker thread 7 started
2009-08-21T15:08:08+09:00	INFO	worker thread 8 started
2009-08-21T15:08:08+09:00	SYSTEM	listening started
2009-08-21T15:08:45+09:00	INFO	connected: 127.0.0.1:53669
2009-08-21T15:08:45+09:00	INFO	doing vanish command
2009-08-21T15:08:45+09:00	INFO	connection finished
2009-08-21T15:09:01+09:00	INFO	connected: 127.0.0.1:53670
2009-08-21T15:09:01+09:00	INFO	connection finished

and tested in another terminal

> tcrtest write localhost 1000
<Writing Test>
  host=localhost  port=1978  cnum=1  tout=0  rnum=1000  nr=0  rnd=0

......................... (00000100)
......................... (00000200)
......................... (00000300)
......................... (00000400)
......................... (00000500)
......................... (00000600)
......................... (00000700)
......................... (00000800)
......................... (00000900)
......................... (00001000)
record number: 1000
size: 40512
time: 0.091
ok

and for read,

> tcrtest read localhost
<Reading Test>
  host=localhost  port=1978  cnum=1  tout=0  mul=0  rnd=0

......................... (00000100)
......................... (00000200)
......................... (00000300)
......................... (00000400)
......................... (00000500)
......................... (00000600)
......................... (00000700)
......................... (00000800)
......................... (00000900)
......................... (00001000)
record number: 1000
size: 40512
time: 0.087
ok

TT(Tokyo Tyrant) supports memcached and http interface as well.

If working locally, various utilty commands like tctmgr can be used to manipulate Tokyo Cabinet databases.

• Wrote Teru at 14:28 (edited 5×, last on 21 Aug 2009) | read 44× | 0 Comments

Wednesday, 19 Aug 2009

permalink Tokyo Promenade 2

Found that promenade.css is not really working. maybe, it was because it's installed under /usr/lib/cgi-bin. reinstalled under /var/www1/blog. it works better. but, now i realize passwd.txt is exposed :-# Changed the directory of passwd.txt and reflected it on promenade.tmpl. Following the manual gave me errors in writing to the database. i changed the ownership of all the files in promenade to www-data, and it worked.

OK, it works. But, where are the data? It's in promenade.tct, i guess. It's a Tokyo Cabinet database. How can i access it? Hmm, need to learn more on the database handling. Because my interest right now is to use the database, what i need may be Tokyo Tyrant, which gives me access to Tokyo Cabinet databases.

• Wrote Teru at 14:47 (edited 5×, last on 20 Aug 2009) | read 29× | 0 Comments

permalink Installing Tokyo Cabinet and Tokyo Promenade

Started to install Tokyo Cabinet and Tokyo Promenade. Info is here (in Japanese). Planing to move this blog to Tokyo Promenade if I succeed.

Requirements for installation: Linux 2.4+, gcc, make, zlib, bzip2. Make sure they are installed. Fro zlib, do

> sudo apt-get install zlib1g

Download the source file:http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.31.tar.gz. Untar

> sudo tar xzvf tokyocabinet-1.4.31.tar.gz
> cd tokyocabinet-1.4.31/

Configure

> ./configure

gave an error

configure: error: zlib.h is required

. Did

sudo apt-get install zlib1g-dev

Reran configure. Now

configure: error: bzlib.h is required

. Did

> sudo apt-get install libbz2-dev

. Dd

> make
> make check

Checking emits a lot of lines on the terminal screen, and takes some time. Feel even meticulous, but it's probably a good engineering practice to make sure everything works as it should. Need a coffee break :-O After probably thousans of lines, got

#================================================================
# Checking completed.
#================================================================

Did

> sudo make install

Got

#================================================================
# Thanks for using Tokyo Cabinet.
#================================================================

OK :-)

Now download TokyoPromenade here. See here for installation (in English). Untar

> sudo tar xzvf tokyopromenade-0.9.2.tar.gz

Did

> ./confiture
> make
> make check
> sudo make install

in seconds successfully. Create a base directory for CGI as

> sudo mkdir -p /usr/lib/cgi-bin/tokyopromenade

After setting up the Apache site file at /etc/apache2/sites-available/sitefile3, accessing here gave me this page
[[image: tokyopromenade.png]]
Simple and sufficient! I like it :->

OK. What next? See here, for the instructions (in Japanese). Well, it doesn't explain how to register a user :(( When tried with guest without a pasword, login was successful. But, how ca I create a user? Alright, I found it in a blog article %-| here. I.e., admin/nimda for administrator. The top page for admin is
[[image: tokyopromenade_1.png]]
Hitting the "users" there gets [[image: tokyopromenade_2.png]]

• Wrote Teru at 12:49 (edited 4×, last on 19 Aug 2009) | read 154× | 0 Comments

4 shown; more articles may be found in the archives. The permalink icon is the article's permalink.
Process times: page=0.413 request=0.421 cpu=0.420