centos7下安装flex,bison
1,修改镜像源为国内镜像源,比如阿里云
(1)首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
[root@fengyi flex]# cp /etc/yum.repos.d/CentOS-Base.repo /home/fengyi/Destop
(2)进入yum源配置文件所在的文件夹
[root@fengyi flex]# cd /etc/yum.repos.d/
(3)下载阿里云源文件作为新的yum源配置文件
[root@fengyi yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2,安装flex,bison
[root@fengyi flex]# yum install flex bison
3,问题:
(1)flex安装后可以使用,但是链接flex库时,-lfl找不到flex库
[root@fengyi flex]# gcc lex.yy.c -o analyze -lfl
/usr/bin/ld: cannot find -lfl
collect2: error: ld returned 1 exit status
问题分析:
flex包是包含了动态库,不包含动态库的头文件,基于flex的应用程序为基础开发,flex可以正常使用;但是,如果使用flex库里面的源代码,则会导致找不到flex库的问题;
解决方案:
flex-devel包包含了这个包程序开发所有必须的文件,比如头文件、动态库等,安装flex-devel包可以调用flex库代码开发;
安装flex-devel
[root@fengyi flex]# yum install flex-devel
4,package和package-devel的区别
(1)普通package
通常只包含能让程序运行的动态库和配置文件,可以基于package的应用程序开发,不能基于源码开发;
(2)package-devel
带devel后缀的package,则包含使用这个package开发程序的所有的必需文件。比如头文件,等等。有时devel package还包含静态库。
// package-devel包说明介绍链接
https://stackoverflow.com/questions/2358801/what-are-devel-packages
以下package-devel包回答,摘自上述网址:
The *-devel packages (usually called *-dev in Debian-based distributions) are usually all the files necessary to compile code against a given library.
For running an application using the library libfoo only the actualy shared library file (*.so.*, for example libfoo.so.1.0) are needed (plus possibly some data files and some version-specific symlinks).
When you actually want to compile a C application that uses that library you'll need the header files (*.h, for example foo.h) that describe the interface of that application as well as a version-less symlink to the shared library (*.so, for example libfoo.so -> libfoo.so.1.0). Those are usually bundled in the *-devel packages.
Sometimes the *-devel packages also include statically compiled versions of the libraries (*.a, for example libfoo.a) in case you want to build a complete stand-alone application that doesn't depend on dynamic libraries at all.
Other languages (such as Java, Python, ...) use a different way of noting the API of a library (effectively including all the necessary information in the actual library) and thus usually need no separate *-devel packages (except maybe for documentation and additional tools).