【Linux开发】Linux下jpeglib库的安装详解

时间:2022-02-07 22:59:13

Linux下jpeglib库的安装详解

首先要下载所需的库压缩包:jpegsrc.v6b.tar.gz或 jpegsrc.v8b.tar.gz

然后将下载的压缩包随便放在和解压到你喜欢的地方。

# tar -zxvf jpegsrc.v6b.tar.gz

# cd jpeg-6b

# ./configure  --enable-shared

# make

/以下代码是在usr/local目录下建立库文件安装目录

/如果没有权限建立输入命令sudo –s 回车,然后按提示输入你的登录密码

# mkdir /usr/local/jpeg6

# mkdir /usr/local/jpeg6/include

# mkdir /usr/local/jpeg6/lib

# mkdir /usr/local/jpeg6/bin

# mkdir /usr/local/jpeg6/man

# mkdir /usr/local/jpeg6/man/man1

# make install

#----configuration information----

  echo "---------------------------------------------------------------------"

echo "please add following lines in you /etc/profile"

  echo "("

  echo " tip:"

  echo " you can add these lines in a file named /etc/profile.jpeg,"

  echo " and then add a line on the end of /etc/profile:"

  echo " . /etc/profile.jpeg"

  echo " it is simple,:)"

  echo "):"

  echo " PATH=""$""PATH:$jpeg/bin"

  echo " CPLUS_INCLUDE_PATH=""$""CPLUS_INCLUDE_PATH:$jpeg/include"

  echo " LD_LIBRARY_PATH=""$""LD_LIBRARY_PATH:$jpeg/lib"

  echo " LIBRARY_PATH=""$""LIBRARY_PATH:$jpeg/lib"

  echo " MANPATH=""$""MANPATH:$jpeg/man"

  echo ""

  echo " export PATH CPLUS_INCLUDE_PATH LD_LIBRARY_PATH LIBRARY_PATH MANPATH"

这就安装完了吗???no!!!

你可能在编译自己写的程序的时候会遇到一下问题终端提示

/tmp/cc9DqMJZ.o: In function `jpeg_compress':

server1214.c:(.text+0x4f5): undefined reference to `jpeg_std_error'

server1214.c:(.text+0x519): undefined reference to `jpeg_CreateCompress'

server1214.c:(.text+0x59b): undefined reference to `jpeg_stdio_dest'

server1214.c:(.text+0x5d1): undefined reference to `jpeg_set_defaults'

server1214.c:(.text+0x5ef): undefined reference to `jpeg_set_quality'

server1214.c:(.text+0x605): undefined reference to `jpeg_start_compress'

server1214.c:(.text+0x64c): undefined reference to `jpeg_write_scanlines'

server1214.c:(.text+0x66a): undefined reference to `jpeg_finish_compress'

server1214.c:(.text+0x686): undefined reference to `jpeg_destroy_compress'

collect2: ld 返回 1

解决办法在编译命令后加-ljpeg

例 gcc –o **** ****.c –ljpeg

Ok 成功!!!!