Compiling Programs from Source

在使用linux的时候你早晚都要听说"compile from source"这个术语。你第一次听说他的时候会让你感到很害怕,但是当你明白他是什么,他怎么工作的时候,你就会感觉他太简单了。也许你会问自己有像rpm和apt这样的安装包管理系统,我们为什么还要用原代码呢?尽管这些工作让事情变的简单,但是在使用他们中还是会发现有一些缺点。第一,你必须依赖与那些做安装包的人。这也就是说如果软件有的新的版本,在安装包不升级的情况下你是不能获得他的。但是你总是可以获得最新版本的程序原代码。安装包总是保留最大的通用性。一些选项有些人需要使用,而有些人却不需要。这也就是说如果有些特性你想要的没有被编译到安装包或者你想要安装一些十分符合你的系统的东西,那么原代码是你唯一的选择。从原代码编译成程序我们需要一些工具。一些发行商叫他们开发包。至少我们需要make程序,编译器(通常是gcc),一些相关的类库和其他的基础程序。如果你遇到一些问题,那么错误信息回告诉你缺少什么东西。在你解决了那些问题以后,需要删除一个叫做config.cache的文件,那样装配器才会发现你的更改。

现在我们已经作好了安装一个小程序的准备了。接下来我们要做的第一件事情就是下载原代码。在这篇文章里面我们要安装的程序叫做zgBasic。假设我已经把那个下载的原代码放到下面的这个目录:/usr/local/src(在这里的原代码名字叫做zgBasic.tar.gz).下载完后你接着做下面的:
=============================

tar zxf zgBasic.tar.gz

cd zxf zgBasic

./configure

make

make test (optional)

make install
=============================
 

第一行命令会解压缩(unzip)和解包(untar)下载的文件。下一条命令转换到相应的目录中去。大多数的标准安装包用./configure 和 make 还有make install来安装。大多数情况下你可以在README或INSTALL文件中找到安装包的结构。通过运行./configure命令你可以做两个基本的事情:1是让程序检测到他要安装的所有的文件和他们的位置,2是告诉程序那些选项你想在编译是添加。选项是可多可少的,你想知道他到底有那些选项可以运行下面的命令:
============================

./configure --help | less

============================

可以让你看到可以使用的选项。一旦装配器运行通过,并且你检查没有任何错误了,你就可以运行make了。这一步实际上是编译原代码为程序。取决与你编译的原代码和你的机器,这个过程可能执行几秒,也有可能是几个小时。make test是可选的,但是他是个很好的实践机会。他可以检测所有的东西是否正常,程序的操作是否合理。这里我们要注意到现在所有的步骤都可以由一个非root用户完成。但是最后的步骤是需要root权限的。只有那样做你的程序才能运行象其他安装在你系统上的程序一样。因为最后一步是真正的把文件copy到我们的系统中去。如果你还需要从新编译这个程序,在编译之前你需要做个make clean,他会删除你先前编译器产生的那些文件,并且返回一个删除文件的tree。

和前面的教程明显不同的是perl程序。从原代码(同样可以使用CPAN)安装perl程序我们需要按照下面的做

============================

tar zxf zgBasic-perl.tar.gz

cd zgBasic-perl

perl Makefile.PL

make

make test (optional)

make install

============================

你会发现大多数的步骤都一样,明显的不同只有./configure和perl makefile.pl。

如果你在从原代码安装程序的时候还是遇到一些问题,那么错误信息会明确的告诉你那些地方你丢失了,和他怎么失败的。如果还有不明白的,你可以联系我,qq:26798   7618279

Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\Micheal_Ma\AppData\Local\Temp\pip-install-j4qmc98t\pandas_0cd186d67c0c4b9aba085f37ddc0aba7\setup.py", line 813, in <module> ext_modules=maybe_cythonize(extensions, compiler_directives=directives), File "C:\Users\Micheal_Ma\AppData\Local\Temp\pip-install-j4qmc98t\pandas_0cd186d67c0c4b9aba085f37ddc0aba7\setup.py", line 542, in maybe_cythonize return cythonize(extensions, *args, **kwargs) File "C:\Users\Micheal_Ma\AppData\Local\Programs\Python\Python38\lib\site-packages\Cython\Build\Dependencies.py", line 1134, in cythonize cythonize_one(*args) File "C:\Users\Micheal_Ma\AppData\Local\Programs\Python\Python38\lib\site-packages\Cython\Build\Dependencies.py", line 1301, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: pandas\_libs/reduction.pyx Compiling pandas\_libs/algos.pyx because it changed. Compiling pandas\_libs/groupby.pyx because it changed. Compiling pandas\_libs/hashing.pyx because it changed. Compiling pandas\_libs/hashtable.pyx because it changed. Compiling pandas\_libs/index.pyx because it changed. Compiling pandas\_libs/indexing.pyx because it changed. Compiling pandas\_libs/internals.pyx because it changed. Compiling pandas\_libs/interval.pyx because it changed. Compiling pandas\_libs/join.pyx because it changed. Compiling pandas\_libs/lib.pyx because it changed. Compiling pandas\_libs/missing.pyx because it changed. Compiling pandas\_libs/parsers.pyx because it changed. Compiling pandas\_libs/reduction.pyx because it changed. Compiling pandas\_libs/ops.pyx because it changed. Compiling pandas\_libs/properties.pyx because it changed. Compiling pandas\_libs/reshape.pyx because it changed. Compiling pandas\_libs/skiplist.pyx because it changed. Compiling pandas\_libs/sparse.pyx because it changed. Compiling pandas\_libs/tslib.pyx because it changed. Compiling pandas\_libs/tslibs/c_timestamp.pyx because it changed. Compiling pandas\_libs/tslibs/ccalendar.pyx because it changed. Compiling pandas\_libs/tslibs/conversion.pyx because it changed. Compiling pandas\_libs/tslibs/fields.pyx because it changed. Compiling pandas\_libs/tslibs/frequencies.pyx because it changed. Compiling pandas\_libs/tslibs/nattype.pyx because it changed. Compiling pandas\_libs/tslibs/np_datetime.pyx because it changed. Compiling pandas\_libs/tslibs/offsets.pyx because it changed. Compiling pandas\_libs/tslibs/parsing.pyx because it changed. Compiling pandas\_libs/tslibs/period.pyx because it changed. Compiling pandas\_libs/tslibs/resolution.pyx because it changed. Compiling pandas\_libs/tslibs/strptime.pyx because it changed. Compiling pandas\_libs/tslibs/timedeltas.pyx because it changed. Compiling pandas\_libs/tslibs/timestamps.pyx because it changed. Compiling pandas\_libs/tslibs/timezones.pyx because it changed. Compiling pandas\_libs/tslibs/tzconversion.pyx because it changed. Compiling pandas\_libs/testing.pyx because it changed. Compiling pandas\_libs/window.pyx because it changed. Compiling pandas\_libs/writers.pyx because it changed. Compiling pandas\io/sas/sas.pyx because it changed. Compiling pandas\io/msgpack/_packer.pyx because it changed. Compiling pandas\io/msgpack/_unpacker.pyx because it changed. [ 1/41] Cythonizing pandas\_libs/algos.pyx [ 2/41] Cythonizing pandas\_libs/groupby.pyx [ 3/41] Cythonizing pandas\_libs/hashing.pyx [ 4/41] Cythonizing pandas\_libs/hashtable.pyx [ 5/41] Cythonizing pandas\_libs/index.pyx [ 6/41] Cythonizing pandas\_libs/indexing.pyx [ 7/41] Cythonizing pandas\_libs/internals.pyx [ 8/41] Cythonizing pandas\_libs/interval.pyx [ 9/41] Cythonizing pandas\_libs/join.pyx [10/41] Cythonizing pandas\_libs/lib.pyx [11/41] Cythonizing pandas\_libs/missing.pyx [12/41] Cythonizing pandas\_libs/ops.pyx [13/41] Cythonizing pandas\_libs/parsers.pyx [14/41] Cythonizing pandas\_libs/properties.pyx [15/41] Cythonizing pandas\_libs/reduction.pyx [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output.
11-22
``` Makefile compilation parameter description: 1. DEBUG: DEBUG=1: Indicates that the debug program is generated. other value: Indicates that the release program is generated. The default value of DEBUG is 1. 2. HW_VER: HW_VER=0: Indicates that the compiled program is used for fpga version. HW_VER=1: Indicates that the compiled program is used for fpga jtag version. HW_VER=2: Indicates that the compiled program is used for fpga simulation version. HW_VER=3: Indicates that the compiled program is used for asic simulation version. HW_VER=4: Indicates that the compiled program is used for first MPW version. HW_VER=5: Indicates that the compiled program is used for fpga rom version. other value: Not supported. The default value of HW_VER is 4. Description of the main working directory: 1. test: Store the test code. |-ddr_source: store the test code for running in ddr. HW_VER must be 0, 1, 4 when compiling. |-sram_source: store the test code for running in sram. HW_VER must be 0, 1, 4 when compiling. |-sim_source: store the test code for running in the simulation environment. HW_VER must be 2, 3 when compiling. |-fpga_rom_source: store the test code for running in the fpga rom. HW_VER must be 5 when compiling. 2. hal: Store the driver code. 3. romcode: Store the rom code of codetap-out version or FPGA version for receiving, burning, and running the program. 4. tools: Store the bin file processing and merging tools for rom code adaptation. 5. utest: Store utest test programs. 6. linker_scripts: store the link script using for compiling. 7. debug/release: store the compilation.```使用git克隆到本地后,如果代码有更新,应该使用什么指令将新的代码克隆到本地
04-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值