Linux下编译和安装软件的方法

For all those who are beginners in any linux(ubuntu) find hard to find the package files of their distro and end up in finding an source package(which is either in tar.gz or .gz).. so now people think how to install these source files…..

lets now see how would you be installing source files in ubuntu…..

source files contain the programs and hence before the installation you need to compile them… so you need to install the build-essentials from the synaptic package manager…. else this build-essentials is already present in the cd.. and so you can install it…..else you can install it typing it in the terminal by

sudo aptitude install build-essential

suppose you have a source file name src.tar.gz, what you do initially is that you need to extract the source files and then in the terminal….

navigate to the folder where the source file is extracted using the cd commands….. and then

type the following…
./configure

make

sudo make install

clean install

lets see what each one of them does…

./configure….. checks whether the required dependencies are available on your system or not….. if not an error is reported….

make compiles the source code and make install is used to install the program in to the location

if it asks for an installation location it is recommended to install all the source to /usr/src

clean install removes any temporary files created in the installation process of the source

and thats it your source file in installed in your system.

使用方法:打开scws-1.2.3\win32里的解决方案文件,里面包括了scws和zhparser,另外一个是scws的php扩展不用编译 zhparser是Postgresql中进行中文分词的常用扩展,网上的相关资料很多,安装的教程也不少,但大多数是linux的,并没有windows的安装介绍。原因有两个方面,一个是本身像这种数据库服务器一般都是linux系统的,另外一个比较致命,zhparser本身并没提供windows环境下的编译工程,连依赖库scws的readme里也建议在linux环境下使用,或者用cygwin或mingw一类工具。对于博主这种只使用windows环境(其实Postgresql也是刚接触),连makefile也搞不明白的真是头大。好在万变不离其中,编译环境只是工具,只要搞清楚个中原理(看代码),移植到windows+VS的环境应该也不是难事(当然这个也只是在轻量级的库下面适用)。下面进入正题: 干货在这里 ① 编译scws:由于 zhparser是基于scws(scws是简易中文分词系统的缩写,它的原理其实很简单,基于词典,将文本中的内容按照词典进行分词,提取关键字等。)做的分词,因此先要编译scws,网上下载下来的源码有vs2008的版本,因此,直接编译,后来出现头文件无法加入的错误,将相关文件编码方式修改成unicode解决(利用notepad++ 编码->转换为UTF-8编码)。 ② 编译zhparser:由于zhparser只提供了linux下面的makefile文件,想着用Mingw去编译,后来因为postgresql所在目录有空格,导致编译过程也失败。只好到vs2008里自建一个工程,建好工程后,首先把scws的头文件和库文件加进去,然后把postgresql的头文件和库文件加进去,设置项目属性为生成dll文件。 ③ 扩展安装编译成功以后,在postgresql下面运行:create extension zhparser; 提示找不到control文件,在下载的源码文件夹里找到该文件,放到指定目录,再次运行sql,提示找不到dll文件,将dll文件放到指定目录,再运行,提示找不到zhprs_start函数,看来是dll没有正常explort出函数,修改源代码中的相关函数声明,再次运行后,显示成功。但zhparser源文件下其实还有很多文件,包括一个词典文件和ini配制文件,还不知道应该放在何处。 ④ zhparser运行环境配制:运行测试sql语句,发现并没有实现分词,想起来应该是词典位置不正确,到zhparser源码中去搜寻,发现如下代码,看来是放到tsearch_data目录下面,用同样的方法找到ini文件的目录,将它们都放进去,再次运行测试代码,得到正确结果。 测试代码: REATE EXTENSION zhparser; -- make test configuration using parser CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser); ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple; select to_tsvector('testzhcfg','南京市长江大桥');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值