20150209-3 选题

This commit is contained in:
DeadFire 2015-02-09 10:17:52 +08:00
parent 78452d10d4
commit 864934ada7
2 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1,91 @@
Linux FAQs with Answers--How to fix “fatal error: x264.h: No such file or directory” on Linux
================================================================================
> **Question**: I am trying to build a video encoding application from the source on Linux. However, during compilation, I am encountering the error: "fatal error: x264.h: No such file or directory" How can I fix this error?
The following compilation error indicates that you do not have x264 library's development files installed on your Linux system.
fatal error: x264.h: No such file or directory
[x264][1] is an H.264/MPEG-4 AVC encoder library licensed with GNU GPL. The x264 library is popularly used by many video encoder/transcoder programs such as Avidemux, [FFmpeg][2], [HandBrake][3], OpenShot, MEncode and more.
To solve the above compilation error, you need to install development files for x264 library. Here is how you can do it.
### Install x264 Library and its Development Files on Debian, Ubuntu or Linux Mint ###
On Debian based systems, x264 library is already included in the base repositories. Thus its installation is straightforward with apt-get as follows.
$ sudo apt-get install libx264-dev
### Install x264 Library and its Development Files on Fedora, CentOS/RHEL ###
On Red Hat based distributions such as Fedora or CentOS, the x264 library is available via the free repository of RPM Fusion. Thus, you need to install [RPM Fusion (free)][4] first.
Once RPM Fusion is set up, you can install x264 development files as follows.
$ sudo yum --enablerepo=rpmfusion-free install x264-devel
Note that RPM Fusion repository is not available for CentOS 7 yet, so the above method does not work for CentOS 7. In case of CentOS 7, you can build and install x264 library from the source, which is explained below.
### Compile x264 Library from the Source on Debian, Ubuntu or Linux Mint ###
If the libx264 package that comes with your distribution is not up-to-date, you can compile the latest x264 library from the source as follows.
$ sudo apt-get install g++ automake autoconf libtool yasm nasm git
$ git clone git://git.videolan.org/x264.git
$ cd x264
$ ./configure --enable-static --enable-shared
$ make
$ sudo make install
The x264 library will be installed in /usr/local/lib. To allow the library to be used by other applications, you need to complete the last step:
Open /etc/ld.so.conf with a text editor, and append the following line.
$ sudo vi /etc/ld.so.conf
----------
/usr/local/lib
Finally reload all shared libraries by running:
$ sudo ldconfig
### Compile x264 Library from the Source on Fedora, CentOS/RHEL ###
If the x264 library is not available on your Linux distribution (e.g., CentOS 7) or the x264 library is not up-to-date, you can build the latest x264 library from the source as follows.
$ sudo yum install gcc gcc-c++ automake autoconf libtool yasm nasm git
$ git clone git://git.videolan.org/x264.git
$ cd x264
$ ./configure --enable-static --enable-shared
$ make
$ sudo make install
Finally, to allow other applications to use x264 library installed in /usr/local/lib, add the following line in /etc/ld.so.conf:
$ sudo vi /etc/ld.so.conf
----------
/usr/local/lib
and reload all shared libraries by running:
$ sudo ldconfig
![](https://farm8.staticflickr.com/7350/16453197512_7c18c5c09e_b.jpg)
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/fatal-error-x264-h-no-such-file-or-directory.html
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://www.videolan.org/developers/x264.html
[2]:http://ask.xmodulo.com/compile-ffmpeg-centos-fedora-rhel.html
[3]:http://xmodulo.com/how-to-install-handbrake-on-linux.html
[4]:http://xmodulo.com/how-to-install-rpm-fusion-on-fedora.html

View File

@ -0,0 +1,48 @@
Linux FAQs with Answers--How to get the process ID (PID) of a shell script
================================================================================
> **Question**: I want to know the process ID (PID) of the subshell under which my shell script is running. How can I find a PID in a bash shell script?
When you execute a shell script, it will launch a process known as a subshell. As a child process of the main shell, a subshell executes a list of commands in a shell script as a batch (so-called "batch processing").
In some cases, you may want to know the process ID (PID) of the subshell where your shell script is running. This PID information can be used under different circumstances. For example, you can create a unique temporary file in /tmp by naming it with the shell script PID. In case a script needs to examine all running processes, it can exclude its own subshell from the process list.
In bash, the **PID of a shell script's subshell process** is stored in a special variable called '$$'. This variable is read-only, and you cannot modify it in a shell script. For example:
#!/bin/bash
echo "PID of this script: $$"
The above script will show the following output.
PID of this script: 6583
Besides $$, bash shell exports several other read-only variables. For example, PPID stores the process ID of the subshell's parent process (i.e., main shell). UID stores the user ID of the current user who is executing the script. For example:
#!/bin/bash
echo "PID of this script: $$"
echo "PPID of this script: $PPID"
echo "UID of this script: $UID"
Its output will be:
PID of this script: 6686
PPID of this script: 4656
UID of this script: 1000
In the above, PID will keep changing every time you invoke a script. That is because each invocation of a script will create a new subshell. On the other hand, PPID will remain the same as long as you run a script inside the same shell.
![](https://farm8.staticflickr.com/7437/16274890369_e78ce16d42_b.jpg)
For a complete list of built-in bash variables, refer to its man page.
$ man bash
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/process-id-pid-shell-script.html
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出