CaptfEncoder编译

解决CaptfEncoder无法在MacOS上运行。

背景

直接从GitHub下载下来的CaptfEncoder在MacOS M系列芯片上无法正常运行。根据issues提示是缺少GMP Library。通过brew安装之后,还是无法直接运行。

1
brew install gmp


通过find命令查找libgmp.10.dylib将其复制到对应目录

1
2
sudo find / -name "libgmp.10.dylib"
cp /System/Volumes/Data/opt/homebrew/Cellar/gmp/6.2.1_1/lib/libgmp.10.dylib /usr/local/opt/gmp/lib/libgmp.10.dylib

这时候提示变为mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')

运行

下载源码,进入对应目录使用使用cargo运行提示报错

1
2
3
git clone https://github.com/guyoung/CaptfEncoder.git
cd CaptfEncoder/CaptfEncoder-V3
cargo run


根据提示可以知道还是缺少gmp库导致的,根据猜测应该是对应的依赖没被找到。
将brew对应的lib加入到环境变量中export LIBRARY_PATH=/opt/homebrew/lib,再运行即可完美解决。

编译

CaptfEncoder本身已经做了编译的配置,只需要调整Cargo.toml内容即可:

  1. package中添加description
  2. icon中修改为app.ico
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    [package]
    name = "captfencoder"
    version = "3.3.0"
    authors = ["guyoung"]
    edition = "2021"
    build = "build.rs"
    description = ""



    [dependencies]

    fltk = "1.4"
    fltk-theme = "0.7"
    rhai = "1.15"

    tokio = { version = "1", features = ["full"] }
    reqwest = { version = "0.11", features = ["json"] }
    serde = "1.0"
    serde_json = "1.0"
    pollster = "0.2"
    base64 = "0.13"
    anyhow = "1"
    image = "0.23"
    clipboard = "0.5"
    rust-embed = "6.3"
    webbrowser = "0.5"
    rand = "0.8"
    dyn-clone = "1.0"
    sysinfo = "0.29"
    chrono = "0.4"

    captfencoder_encoding = { version = "1.0.0", path = "../encoding"}
    captfencoder_query = { version = "1.0.0", path = "../query"}
    captfencoder_misc = { version = "1.0.0", path = "../misc"}


    lazy_static = "1.4"
    state = "0.5"
    enum-ordinalize = "3.1"
    sublime_fuzzy = "0.7"
    crossbeam-channel = "0.5"
    event-emitter-rs = "0.1"
    hey_listen = "0.5"

    num = "0.4"
    num-bigint = "0.4"
    num-traits = "0.2"
    primal = "0.3"

    [build-dependencies]
    winresource = "0.1"

    [package.metadata.winresource]
    ProductName = "CaptfEncoder"
    ProductVersion = "3.3.0"
    OriginalFilename = "CaptfEncoder.exe"
    LegalCopyright = "Copyright © Guyoung studio 2022"


    [package.metadata.bundle]
    name = "CaptfEncoder"
    identifier = "net.guyoung.captfencoder"
    icon = ["app.ico"]
    #deb_depends = []
    osx_minimum_system_version = "10.0"
    之后通过cargo bundle编译即可

其他

  1. 使用cargo时遇到无法通过更新、下载的问题,通过添加CARGO_HTTP_MULTIPLEXING即可解决(多线程下载)CARGO_HTTP_MULTIPLEXING=false cargo update
  2. 需要在zshrc在添加export LIBRARY_PATH=/opt/homebrew/lib避免之后又遇到找不到lib的情况