基本情報
- Berkeley DB Version : Berkeley DB 12cR1 (12.1.6.2.32)
- Download file : Berkeley DB 6.2.32.tar.gz
- OS : AWS EC2 (Amazon AMI)
リンク
インストール手順
Download / 配置
- tar.gzをダウンロードし、解凍。
configure, build, install
- build_unixフォルダーへ移動し、下記を実行
今回はインストールフォルダーは/home/ec2-user/bdb/install、--enable-cxxにより、C++から呼び出せるようにする。
$ ../dist/configure --prefix=/home/ec2-user/bdb/install --enable-cxx $ make $ make install
もし間違った場合は以下のように掃除
- configureからやり直し : make realclean
- makeからやり直し : make clean
- uninstall : make uninstall
尚、make install時のこのメッセージは注意
Libraries have been installed in: /home/ec2-user/bdb/install/lib If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf'
インスール後
サンプル実行
サンプルコードの場所
Cのサンプルコードは、ダウンロードしたソースコードの中のexamples/c/getting_started以下にある。
サンプルコードのコンパイル
# compile / link example_database_read.c gcc -c -I/home/ec2-user/bdb/install/include -L/home/ec2-user/bdb/install/lib gettingstarted_common.c ex ample_database_read.c gcc example_database_read.o gettingstarted_common.o -I/home/ec2-user/bdb/install/include -L/home/ec2-us er/bdb/install/lib -ldb-6.2 -o example_database_read # compile / link example_database_load gcc -c -I/home/ec2-user/bdb/install/include -L/home/ec2-user/bdb/install/lib gettingstarted_common.c ex ample_database_load.c gcc example_database_load.o gettingstarted_common.o -I/home/ec2-user/bdb/install/include -L/home/ec2-us er/bdb/install/lib -ldb-6.2 -o example_database_load
実行
- LD_LIBRARY_PATHでlibフォルダーを指定
$ export LD_LIBRARY_PATH=/home/ec2-user/bdb/install/lib:$LD_LIBRARY_PATH
- example_database_loadを実行
$ ./example_database_load databases opened successfully databases closed. Done loading databases.
- example_database_readを実行
$ ./example_database_read databases opened successfully name: Allspice SKU: AllsfruibJGK4R Category: fruits Price: 0.94 Quantity: 669 Vendor: TriCounty Produce 309 S. Main Street Middle Town, MN 55432 763 555 5761 Contact: Mort Dufresne 763 555 5765 ...... name: Zulu Nut SKU: ZulufruiWbz6vU Category: fruits Price: 0.71 Quantity: 653 Vendor: Simply Fresh 15612 Bogart Lane Harrigan, WI 53704 420 333 3912 Contact: Cheryl Swedberg 420 333 3952 databases closed.