# 编译文件加上新的库如jpeglib

# 1.下载jpeglib源码

```bash
wget http://www.ijg.org/files/jpegsrc.v9e.tar.gz
tar -xzf jpegsrc.v9e.tar.gz
cd jpeg-9e
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749109872166/919e4703-3ee4-4f4b-bf82-e3095fb714d8.png align="center")

# 2.配置交叉编译环境

创建MISP安装路径，存放头文件和库文件：

```bash
mkdir install-mips
```

然后运行configure配置交叉编译

```bash
./configure \
  --host=mips-linux-gnu \
  --prefix=$(pwd)/install-mips \
  --enable-static \
  --disable-shared \
  CC=mips-linux-gnu-gcc

# 君正芯片要修改交叉编译工具链
./configure CC=mips-linux-uclibc-gnu-gcc #对应君正的交叉编译工具链的位置
    LD=mips-linux-uclibc-gnu-ld  #对应君正的交叉编译工具链的位置
    --prefix=/home/ding/SourceCode/svn-battery/jpeglib/jpeg-9e/install-mips #编译结果输出文件
    --enable-shared #不编译动态库 .so 文件
    --enable-static #编译静态库 .a 文件
    --host=mips #指定交叉编译的目标架构
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749110471524/5eb10b79-b27a-4628-9d47-0a9c407dd8c3.png align="center")

# 3.编译并安装

```bash
make

# 如果install-mips已经存放了上一次编译结果要
make clean
rm -rf install-mips/*
make
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749110707638/7326dc84-7ee2-45ba-a1a9-aa0d212b6452.png align="center")

安装

```bash
make install
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749110761465/6666b6ca-730f-4487-ae32-c4fc2c74af38.png align="center")

安装完成后路径结构如下：

```bash
jpeg-9e/
├── install-mips/
│   ├── include/
│   │   └── jpeglib.h
│   └── lib/
│       └── libjpeg.a
```

可以使用以下指令查看交叉编译工具链是否使用正确

```bash
mips-linux-uclibc-gnu-readelf jquant2.o -h #可以选择任意一个.o文件进行查看
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749110905019/2e03f1ec-081d-4d3c-a0fd-b6a011dd7327.png align="center")

# 4.修改Makefile文件

在你的Makefile头部添加以下内容：

```bash
CUR_DIR := $(shell pwd)

# libjpeg include & lib 目录
JPEG_INC_DIR := $(CUR_DIR)/jpeg-9e/install-mips/include
JPEG_LIB_DIR := $(CUR_DIR)/jpeg-9e/install-mips/lib
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749111065195/247fee29-cb5d-4b6c-9dd5-6b89538a823f.png align="center")

修改INCLUDES变量，加入jpeglib头文件路径：

```bash
INCLUDES = -I$(SDK_INC_DIR) -I$(IVS_INC_DIR) -I$(JPEG_INC_DIR)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749111126235/cd093d80-3713-45f0-9157-7e8501ba5856.png align="center")

修改LIBS变量，加入jpeglib静态库：

```bash
LIBS += -L$(JPEG_LIB_DIR) -ljpeg

#或

LIBS = $(SDK_LIB_DIR)/libimp.a $(SDK_LIB_DIR)/libalog.a \
       $(MXU_LIB_DIR)/libmxu_merge.a  \
       $(MXU_LIB_DIR)/libmxu_video.a \
       $(MXU_LIB_DIR)/libmxu_imgproc.a \
       $(MXU_LIB_DIR)/libmxu_core.a \
	   $(JPEG_LIB_DIR)/libjpeg.a
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749111429656/df594eaf-5f75-4723-8ee7-ba5e42d1dc2d.png align="center")

# 5.重新编译项目

```bash
make clean
make
```

# 6.星辰编译链编译curl

```bash
# 要先下载openssl
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
tar -xvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w

mkdir install-arm

#运行配置信息后

#下载包
make -j$(nproc)
make install_sw

# 此时安装好的包在openssl-1.1.1w/install-arm当中





# 下载curl
wget https://curl.se/download/curl-8.7.1.tar.gz
tar -xvf curl-8.7.1.tar.gz

cd curl-8.7.1

mkdir install-arm

#运行配置信息

#下载包
make
make 
```

## 6.1.安装openssl的配置信息

```bash
./Configure linux-armv4 \
    --prefix=/home/ding/yyb/curl/openssl-1.1.1w/install-arm \
    --cross-compile-prefix=arm-sigmastar-linux-uclibcgnueabihf-9.1.0- \
    no-async no-zlib no-shared no-tests \
    --openssldir=/etc/ssl
```

## 6.2.curl配置信息

```bash
./configure CC=arm-sigmastar-linux-uclibcgnueabihf-9.1.0-gcc \
LD=arm-sigmastar-linux-uclibcgnueabihf-9.1.0-ld \
--prefix=/home/ding/yyb/curl/curl-8.7.1/install-arm \
--enable-shared \
--enable-static \
--host=arm \
--with-ssl=/home/ding/yyb/curl/openssl-1.1.1w/install-arm
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1751278099559/801a54fa-3138-433b-86bd-42f8416a4948.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1751278185702/83024b3c-56be-49da-a6b1-3ccce9667984.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1751278241807/23ae1438-6ad6-416d-97f3-314b5110d3cd.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1751281167743/df87cc42-89f0-4e3a-92d0-f857eff28dac.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1751281530623/51aa9ed9-83bd-422f-a5c2-b13bd8c7eaf8.png align="center")
