首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

automake编译和安装方式说明

作为良好的习惯,建议为第三方库建立专门的目录,目录取名为thirdparty。然后,再在thirdparty下建立名叫src_package,用来存放第三方库的源码包,如没有特别说明,第三方库默认均为automake编译和安装方式。并且,一般建议将第三方库安装在thirdparty目录下,而不是系统的/usr/local目录下,目的是尽量减少对系统目录的污染,保持系统目录的整洁。 【automake编译和安装方式说明】 通常Linux系统自带automake编译工具,C/C++开源库一般都采用automake编译。 假设源代码库文件名为protobuf-2.4.1.tar.gz,则编译和安装操作步骤如下: 1) 将源代码包文件protobuf-2.4.1.tar.gz上传到Linux机上,这里假设上传到Linux机的/tmp目录 2) 进入/tmp目录 3) 解压源代码包文件:tar xzf protobuf-2.4.1.tar.gz,完成后会在/tmp目录下会出现一个子目录protobuf-2.4.1 4) 进入/tmp的子目录子目录protobuf-2.4.1 5) 执行configure命令,以生成Makefile文件:./configure --prefix=/usr/local/protobuf-2.4.1,这里假设将Protocol Buffers安装到/usr/local/protobuf-2.4.1 6) 上一步会生成编译用的Makefile文件,接下来执行make编译:make 7) make成功后,再执行make install安装 8) 成功后,就可以ls /usr/local/protobuf-2.4.1查看安装结果了; 9) 建立不带版本号的软链接:ln -s /usr/local/protobuf-2.4.1 /usr/local/protobuf 【automake编译和安装方式补充说明】 a) 源代码包如果是protobuf-2.4.1.tar.bz2形式,则表示是bzip2压缩包,而protobuf-2.4.1.tar.gz是gzip压缩包,对于bzip2压缩包,tar解压参数请由xzf改成xjf b) 上述第9步不是必须的,但会是一个良好的Linux风俗,建议保持 c) 注意第5步,如果生成的静态库会被其它共享库使用,则可能需要为configure增加参数,否则在链接生成共享库时,可能会报被链接的静态库需要带-fPIC参数重新编译,这个问题不难解决,如下变通一下即可: ./configure --prefix=/usr/local/protobuf-2.4.1 CXXFLAGS=-fPIC LDFLAGS=-fPIC d) 开源的C/C++库源代码包文件一般都采用类似于protobuf-2.4.1.tar.gz的命名方式 【推荐的编译环境目录结构】 假设有一项目mooon,它的目录结构如下,和SVN目录结构保持一致,但SVN上不存放中间目录和文件,mooon本身可以基于用户主目录,或者其它合适的目录,如/data目录下: mooon |-- doc |-- src `-- thirdparty     |-- apr-util     |-- boost     |-- gflags     |-- protobuf     |-- sqlite     |-- src_package     |   |-- apr-util-1.5.1.tar.gz     |   |-- boost_1_53_0.tar.gz     |   |-- cgicc-3.2.10.tar.gz     |   |-- gflags-2.0.tar.gz     |   |-- protobuf-2.4.1.tar.gz     |   |-- sqlite-autoconf-3071401.tar.gz     |   `-- thrift-0.9.0.tar.gz     `-- thrift 安装openssl:  # ./config --prefix=/usr/local/thirdparty/openssl-1.0.2a shared threads 安装httpd(apache),支持https:  # ./configure --with-apr=/usr/local/thirdparty/apr-1.4.6 --with-apr-util=/usr/local/thirdparty/apr-util-1.5.1 --with-ssl=/usr/local/thirdparty/openssl-1.0.2a --with-pcre=/usr/local/thirdpar

03

Python 文件复制&按目录树结构拷贝&批量删除目录及其子目录下的文件

#!/usr/bin/env/ python # -*- coding:utf-8 -*- __author__ = 'shouke' import os import subprocess # 复制文件或目录到指定目录(非自身目录) def copy_dir_or_file(src, dest): if not os.path.exists(dest): print('目标路径:%s 不存在' % dest) return [False, '目标路径:%s 不存在' % dest] elif not os.path.isdir(dest): print('目标路径:%s 不为目录' % dest) return [False, '目标路径:%s 不为目录' % dest] elif src.replace('/', '\\').rstrip('\\') == dest.replace('/', '\\').rstrip('\\'): print('源路径和目标路径相同,无需复制') return [True,'源路径和目标路径相同,不需要复制'] if not os.path.exists(src): print('源路径:%s 不存在' % src) return [False, '源路径:%s 不存在' % src] # /E 复制目录和子目录,包括空的 /Y 无需确认,自动覆盖已有文件 args = 'xcopy /YE ' + os.path.normpath(src) + ' ' + os.path.normpath(dest) # 注意:xcopy不支持 d:/xxx,只支持 d:\xxxx,所以要转换 try: with subprocess.Popen(args, shell=True, universal_newlines = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: output = proc.communicate() print('复制文件操作输出:%s' % str(output)) if not output[1]: print('复制目标文件|目录(%s) 到目标目录(%s)成功' % (src, dest)) return [True,'复制成功'] else: print('复制目标文件|目录(%s) 到目标目录(%s)失败:%s' % (src, dest, output[1])) return [False,'复制目标文件|目录(%s) 到目标目录(%s)失败:%s' % (src, dest, output[1])] except Exception as e: print('复制目标文件|目录(%s) 到目标目录(%s)失败 %s' % (src, dest, e)) return [False, '复制目标文件|目录(%s) 到目标目录(%s)失败 %s' % (src, dest, e)] # 删除指定目录及其子目录下的所有子文件,不删除目录 def delete_file(dirpath): if not os.path.exists(dirpath): print('要删除的目标路径:%s 不存在' % dirpath) return [False, '要删除的目标路径:%s 不存在' % dirpath] elif not os.path.isdir(dirpath): print('要删除的目标路径:%s 不为目录' % dirpath) return [False, '要删除的目标路径:%s 不为目录' % dirpath] # 注意:同xcopy命令,del也不支持 d:/xxxx,Linux/Unix路径的写法,只支持d:\xxx windows路径的写法 args = 'del /F/S/Q ' + os.path.normpath(dirpath) # /F 强制删除只读文件。 /S 删除所有子目录中的指定的文件。 /Q 安静模式。删除前,不要求确认 try: with subprocess.Popen(args, shell=True, universal_newlines = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:

02

SVN利用钩子post-commit自动更新到线上测试服务器

使用svnadmin create 创建一个版本库: svnadmin create cqzn_server 每个版本库的目录下有一个hooks目录: # ls /home/svn/cqzn_server/ conf dav db format hooks locks README.txt 在每个版本库下有hooks文件夹,里面有很多钩子程序: # ls -l hooks/ total 40 -rwxr-xr-x 1 www-data www-data 332 2010-05-30 16:47 post-commit -rw-r–r– 1 www-data www-data 2000 2010-05-30 15:22 post-commit.tmpl -rw-r–r– 1 www-data www-data 1663 2010-05-29 23:28 post-lock.tmpl -rw-r–r– 1 www-data www-data 2322 2010-05-29 23:28 post-revprop-change.tmpl -rw-r–r– 1 www-data www-data 1592 2010-05-29 23:28 post-unlock.tmpl -rw-r–r– 1 www-data www-data 3488 2010-05-29 23:28 pre-commit.tmpl -rw-r–r– 1 www-data www-data 2410 2010-05-29 23:28 pre-lock.tmpl -rw-r–r– 1 www-data www-data 2796 2010-05-29 23:28 pre-revprop-change.tmpl -rw-r–r– 1 www-data www-data 2100 2010-05-29 23:28 pre-unlock.tmpl -rw-r–r– 1 www-data www-data 2830 2010-05-29 23:28 start-commit.tmpl

01

linux中find命令基本使用方法_find命令用法及参数

Linux 查找命令find是Linux系统中最重要和最常用的命令之一,用于查找与指定参数条件匹配的文件及目录列表。find查找命令可以在各种条件下使用,我们可以通过权限,用户,组,文件类型,修改日期,大小等多种条件来查找文件。 这里我会以实例的形式向大家说明find命令的具体用法。 find命令的格式很简单,一般分成三个部分:1)find命令;2)搜索路径(目录可以写多个);3)表达式。对于find命令,最需要学习的是表达式这一段。表达式决定了我们要找的文件是什么属性的文件,还可以指定一些“动作”,比如将匹配某种条件的文件删除。所以,find命令的核心就是表达式的指定方法。在这里,我们首先用下表说明find命令各参数的含义:

02
领券