Centos编译boost
/*linux - centos下boost库的安装
- yum install boost
- yum install boost-devel
- yum install boost-doc
*/
libmemcached安装及简单例子
1、下载安装libmemcached
$ wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
$ tar xvzf libmemcached-0.44tar.gz
$ cd libmemcached-0.44
$ ./configure
$ make
$ sudo make install
libmemcached 默认安装在/usr/local/,头文件安装在/usr/local/include/libmemcachde/,动态库默认安装在/usr/local/lib/下。
2、libmemcached简单测试使用
2 #include <string>
3 #include <libmemcached/memcached.h>
4
5 using namespace std;
6
7 int main(int argc,char *argv[])
8 {
9 //connect server
10 memcached_st *memc;
11 memcached_return rc;
12 memcached_server_st *server;
13 time_t expiration;
14 uint32_t flags;
15
16 memc = memcached_create(NULL);
17 server = memcached_server_list_append(NULL,"localhost",11211,&rc);
18 rc=memcached_server_push(memc,server);
19 memcached_server_list_free(server);
20
21 string key = "key";
22 string value = "value";
23 size_t value_length = value.length();
24 size_t key_length = key.length();
25
26
27 //Save data
28 rc=memcached_set(memc,key.c_str(),key.length(),value.c_str(),value.length(),expiration,flags);
29 if(rc==MEMCACHED_SUCCESS)
30 {
31 cout<<"Save data:"<<value<<" sucessful!"<<endl;
32 }
33
34 //Get data
35 char* result = memcached_get(memc,key.c_str(),key_length,&value_length,&flags,&rc);
36 if(rc == MEMCACHED_SUCCESS)
37 {
38 cout<<"Get value:"<<result<<" sucessful!"<<endl;
39 }
40
41 //Delete data
42 rc=memcached_delete(memc,key.c_str(),key_length,expiration);
43 if(rc==MEMCACHED_SUCCESS)
44 {
45 cout<<"Delete key:"<<key<<" sucessful!"<<endl;
46 }
47
48 //free
49 memcached_free(memc);
50 return 0;
51 }
52
53
编译:g++ -o testmemcached testmemcached.cpp -lmemcached
运行:./testmemcached
结果:Save data:value sucessful!
Get value:value sucessful!
Delete key:key sucessful!
QT的安装
是解压缩剪切过去的。
下面是全局环境配置:
export PATH=/usr/lib:/usr/local/lib:$PATH
export LD_LIBRARY_PATH=/usr/lib64/plugins:/usr/lib64/plugins/sqldrivers:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/usr/lib64/plugins
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
export PATH=/usr/lib:/usr/local/lib:$PATH
export LD_LIBRARY_PATH=/usr/lib64/plugins:/usr/lib64/plugins/sqldrivers:/usr/lib64/sqldrivers:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/usr/lib64/plugins
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
protobuf的安装
protobuf-2.5.0.tar.gz上传到百度云盘供大家下载,地址: http://pan.baidu.com/s/1pJlZubT
1、protobuf是google公司提出的数据存储格式,详细介绍可以参考:https://code.google.com/p/protobuf/
2、下载最新的protobuf,下载地址:https://code.google.com/p/protobuf/downloads/list
3、下载protobuf2.5.o版本,protobuf-2.5.0.tar.gz解压并进行安装。
解压:tar xvf protobuf-2.5.0.tar.gz
安装步骤:(1)./configure (2)make (3)make check (4)make install
注意:安装成功后,将它的bin和lib目录分别加入到PATH和LD_LIBRARY_PATH环境变量,以方便直接调用。
通常建议安装到/usr/local目录下,执行configure时,指定--prefix=/usr/local/protobuf即可
设置环境变量过程:编辑/etc/profile,在文件末尾添加:
export PATH=$PATH:/usr/local/protobuf/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/protobuf/lib
最后输入 protoc --version命令,如显示libprotoc 2.5.0则安装成功
CentOS 安装gcc g++ gtk opengl
yum -y
install
gcc
yum -y
install
gcc-c++
yum
install
make
-- 或者
yum groupinstall
"Development Tools"
-- 或者
yum
install
gcc gcc-c++ kernel-devel
gtk2.0
解决No package ‘gtk+-2.0′ found
方法:yum install libgnomeui-devel
openGL
root执行:
yum list mesa* // 它会列出所有可用的mesa包
yum install mesa* //安装所有可用的mesa包
2.安装freeglut
root执行:
yum install freeglut*
可能你在运行时会出现这样的错误:error while loading shared libraries: libboost_thread.so.1.49.0: cannot open shared object file: No such file or directory
这是因为要用到的库不在默认的环境变量里,可以使用下面的命令添加:
$ sudo ldconfig /usr/local/lib