xfrpc icon indicating copy to clipboard operation
xfrpc copied to clipboard

WSL2 Ubuntu 22.04.3 LTS交叉编译失败

Open xioei opened this issue 1 year ago • 2 comments

一、环境:

  1. lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

  2. cat /proc/version Linux version 5.10.102.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Wed Mar 2 00:30:59 UTC 2022

3.arm-linux-gnueabihf-gcc --version arm-linux-gnueabihf-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

二、编译报错: 1.git拉取master分支 2.执行cmake -DTHIRDPARTY_STATIC_BUILD=arm -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc ..报错

/usr/bin/ld: crypto/aes/aes_cbc.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: crypto/aes/aes_cbc.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:704: libcrypto.so] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/xiongwei/workspace/xfrpc/thirdparty/openssl-1.1.1m'
make: *** [Makefile:174: all] Error 2

还有其他报错省略

3.执行make 报错

xfrpc/client.c:16:10: fatal error: zlib.h: No such file or directory
   16 | #include <zlib.h>
      |          ^~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/xfrpc.dir/build.make:90: CMakeFiles/xfrpc.dir/client.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:101: CMakeFiles/xfrpc.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

4.将zlib.h和zconf.h复制到include目录下,再执行make 还是报错

/usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lcrypt: No such file or directory
/usr/lib/gcc-cross/arm-linux-gnueabihf/11/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lcrypt: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/xfrpc.dir/build.make:497: xfrpc] Error 1
make[1]: *** [CMakeFiles/Makefile2:101: CMakeFiles/xfrpc.dir/all] Error 2
make: *** [Makefile:136: all] Error 2


xioei avatar Dec 07 '24 10:12 xioei

解决了吗

fkdyufu avatar Jan 15 '25 06:01 fkdyufu

目前使用master分支在github的云编译成功了

[ 96%] Building C object CMakeFiles/xfrpc.dir/plugins/youtubedl.c.o
[100%] Linking C executable xfrpc
[100%] Built target xfrpc
xfrpc: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), static-pie linked, stripped
name: 编译xfrpc
on:
  workflow_dispatch:
    inputs:
      branch:
        description: '编译xfrpc源码的分支或版本号,默认主分支master'
        required: true
        default: 'master'
      del:
        description: '是否删除历史编译的流程记录'
        required: true
        default: true
        type: boolean
      rel:
        description: '编译完成后是否发布Release'
        required: true
        default: true
        type: boolean
      tag:
        description: '指定Release的版本号(留空为源码提交哈希值)'
        required: false
        default: ''
  
env:
  branch: "${{ github.event.inputs.branch }}"
  tag: "${{ github.event.inputs.tag }}"
  rel: "${{ github.event.inputs.rel }}"
  TZ: Asia/Shanghai
permissions:
  contents: write
  actions: write
jobs:
  build:
    name: Build ${{ matrix.target }}
    strategy:
      fail-fast: false
      matrix:
        include:
        - target: aarch64-linux-musl
          os: ubuntu-latest
          URL: aarch64-linux-musl
          ARCH_FLAG: linux-aarch64
          
        - target: x86_64-linux-musl
          os: ubuntu-latest
          URL: x86_64-linux-musl
          ARCH_FLAG: linux-x86_64
            
        - target: i686-linux-musl
          os: ubuntu-latest
          URL: i686-linux-musl
          ARCH_FLAG: linux-generic32
        
        - target: armv7-linux-musleabihf
          os: ubuntu-latest
          URL: armv7l-linux-musleabihf
          ARCH_FLAG: linux-armv4

        - target: armv7-linux-musleabi
          os: ubuntu-latest
          URL: armv7m-linux-musleabi
          ARCH_FLAG: linux-armv4
          
        - target: arm-linux-musleabihf
          os: ubuntu-latest
          URL: arm-linux-musleabihf
          ARCH_FLAG: linux-armv4

        - target: arm-linux-musleabi
          os: ubuntu-latest
          URL: arm-linux-musleabi
          ARCH_FLAG: linux-armv4

        - target: mipsel-linux-musl
          os: ubuntu-latest
          URL: mipsel-linux-muslsf
          ARCH_FLAG: linux-mips32

        - target: mips-linux-musl
          os: ubuntu-latest
          URL: mips-linux-muslsf
          ARCH_FLAG: linux-mips32

    runs-on: ${{ matrix.os }}
    steps:
     - name: Checkout code
       uses: actions/checkout@v4
       with:
        repository: liudf0716/xfrpc
        ref: ${{ env.branch }}
     - name: 下载linux-musl-gcc
       uses: lmq8267/dl-musl@main
       with:
        target: ${{ matrix.URL }}
        static: true
        gccpath: /tmp
     - name: 编译
       run: |
         rm -rf thirdparty/openssl-1.1.1m
         git clone --recurse-submodules https://github.com/openssl/openssl.git -b openssl-3.4.0 thirdparty/openssl-1.1.1m
         sed -i 's|"linux-mips32"|${CMAKE_ARCH_FLAG}|g' thirdparty/CMakeLists.txt
         sed -i 's|mips|YES|g' thirdparty/CMakeLists.txt
         sed -i 's|--static|no-shared|g' thirdparty/CMakeLists.txt
         sed -i 's|DOPENSSL_LIBRARES|DOPENSSL_LIBRARIES|g' thirdparty/CMakeLists.txt
         sed -i 's|dl pthread|dl pthread json-c atomic ${PROJECT_SOURCE_DIR}/thirdparty/libs/libz.a ${PROJECT_SOURCE_DIR}/thirdparty/libs/libcrypto.a|g' CMakeLists.txt
         sed -i '/${PROJECT_SOURCE_DIR}\/thirdparty\/include\/libevent/i ${PROJECT_SOURCE_DIR}/thirdparty/zlib-1.2.13/' CMakeLists.txt
         mkdir -p bin && cd bin
         cmake -DTHIRDPARTY_STATIC_BUILD=YES -DCMAKE_ARCH_FLAG="${{ matrix.ARCH_FLAG }}" -DCROSS_C_COMPILER=$CC ..
         make
         $STRIP xfrpc
         file xfrpc
     - name: 安装 UPX
       uses: crazy-max/ghaction-upx@v3
       with:
        version: latest
        install-only: true
     - name: 压缩
       run: |
        cd bin
        cp xfrpc xfrpc-${{ matrix.target }}_upx
        mv xfrpc xfrpc-${{ matrix.target }}
        upx --lzma --best xfrpc-${{ matrix.target }}_upx 
        
     - uses: actions/upload-artifact@v4
       with:
        name: xfrpc-${{ env.branch }}-${{ matrix.target }}
        path: bin/*
     - name: 打包
       if: github.event.inputs.rel == 'true'
       shell: bash
       run: |
          echo "build_time=$(date '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
          if [ -z "$TAG" ]; then
              echo "tag=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
          fi
          echo "haxi=$(git rev-parse HEAD)" >> $GITHUB_ENV
       env:
        TAG: ${{ env.tag }}
        TARGET: ${{ matrix.target }}
     - name: 发布Release
       if: github.event.inputs.rel == 'true'
       uses: softprops/action-gh-release@v2
       with:
          token: ${{ secrets.GITHUB_TOKEN }}
          body: |
           > ### 编译时间 :${{ env.build_time }} [提交记录](https://github.com/liudf0716/xfrpc/tree/${{ env.haxi }})
           
           [官方源码](https://github.com/liudf0716/xfrpc)
           
          tag_name: ${{env.tag}}
          files: |
            bin/xfrpc-${{ matrix.target }}
            bin/xfrpc-${{ matrix.target }}_upx
  del:
    runs-on: ubuntu-latest
    steps:
      - name: 删除流程记录
        if: github.event.inputs.del == 'true'
        uses: Mattraks/delete-workflow-runs@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          retain_days: 0
          keep_minimum_runs: 0

lmq8267 avatar Feb 06 '25 10:02 lmq8267