clang: error: linker command failed with exit code 1 (use -v to see invocation)

这篇具有很好参考价值的文章主要介绍了clang: error: linker command failed with exit code 1 (use -v to see invocation)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在OCR项目调研过程发现一个开源工具gosseract,识别效果不错;

按部就班准备环境,先mac环境安装tesseract(gosseract依赖):

brew install tesseract
$ tesseract -v
tesseract 4.1.3
 leptonica-1.82.0
  libgif 5.2.1 : libjpeg 9d : libpng 1.6.37 : libtiff 4.3.0 : zlib 1.2.11 : libwebp 1.2.1 : libopenjp2 2.4.0
 Found AVX2
 Found AVX
 Found FMA
 Found SSE

第一次安装很顺利,成功。

随着业务需求增加,需要进行语言训练,因此需要安装训练工具, 选择卸载重装:

$ brew install --with-training-tools tesseract
Usage: brew install [options] formula|cask [...]

Install a formula or cask. Additional options specific to a formula may be
appended to the command.
...

Error: invalid option: --with-training-tools

提示此安装方式已废弃。所以选择编译安装方式:

安装依赖

# Packages which are always needed.
brew install automake autoconf libtool
brew install pkgconfig
brew install icu4c
brew install leptonica

# Packages required for training tools.
brew install pango

# Optional packages for extra features.
brew install libarchive

# Optional package for builds using g++.
brew install gcc

下载解压

https://github.com/tesseract-ocr/tesseract/releases

安装

cd tesseract-5.1.0
./autogen.sh
mkdir build
cd build

# Optionally add CXX=g++-8 to the configure command if you really want to use a different compiler.
../configure PKG_CONFIG_PATH=/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig
make -j

# Optionally install Tesseract.
sudo make install

# Optionally build and install training tools.
make training
sudo make training-install

问题:

安装好之后,编译项目报错:

2022/03/31 15:32:10 ERROR    ▶ 0004 Failed to build the application: # ocr
/usr/local/go/pkg/tool/darwin_amd64/link: running clang++ failed: exit status 1
Undefined symbols for architecture x86_64:
  "tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool)", referenced from:
      Init(void*, char*, char*) in 000023.o
      _Init in 000023.o
      _GetDataPath in 000023.o
  "tesseract::TessBaseAPI::Recognize(ETEXT_DESC*)", referenced from:
      _GetBoundingBoxesVerbose in 000023.o
      _GetBoundingBoxes in 000023.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

仅观察报错内容,没发现是版本问题,经过多次卸载重装后发现是版本太高导致的,于是重新安装了4.1.3版本后服务正常编译。

卸载方式可以手动删除安装文件,或者通过命令:

brew uninstall tesseract

但是在后续安装tesseract是会出现各种问题,如下:

$ brew install tesseract==4.1.3
Warning: No available formula with the name "tesseract==4.1.3". Did you mean tesseract?
==> Searching for similarly named formulae...
This similarly named formula was found:
tesseract
To install it, run:
  brew install tesseract
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
liumeng@liumengdeMacBook-Pro Pictures % brew install tesseract
==> Downloading https://ghcr.io/v2/homebrew/core/tesseract/manifests/4.1.3
Already downloaded: /Users/liumeng/Library/Caches/Homebrew/downloads/9597a8ae2cb676cd25c79cf252f4eb8759b9cf3d472c57f7c764e086c5f8f6e2--tesseract-4.1.3.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/tesseract/blobs/sha256:1b67091dce98b42c6c561981a01738fe01c19ac69a1dc4de6d8e43fe885177f0
Already downloaded: /Users/liumeng/Library/Caches/Homebrew/downloads/cf8d3fbb1aea1cc629c6873a25b11d732c90ff23bfa4c44ba23d0ce5c24e907a--tesseract--4.1.3.big_sur.bottle.tar.gz
==> Pouring tesseract--4.1.3.big_sur.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/tesseract/apitypes.h
/usr/local/include/tesseract is not writable.

You can try again using:
  brew link tesseract
==> Caveats
This formula contains only the "eng", "osd", and "snum" language data files.
If you need any other supported languages, run `brew install tesseract-lang`.
==> Summary
🍺  /usr/local/Cellar/tesseract/4.1.3: 65 files, 29.7MB

查看报错信息,需要如下操作:

$ brew link tesseract
Linking /usr/local/Cellar/tesseract/4.1.3...
Error: Could not symlink include/tesseract/apitypes.h
/usr/local/include/tesseract is not writable.

此时需要先删除一些文件:

$ sudo rm -rf  /usr/local/include/tesseract

继续如下操作:

$ brew link tesseract
Linking /usr/local/Cellar/tesseract/4.1.3...
Error: Could not symlink share/tessdata/configs/alto
Target /usr/local/share/tessdata/configs/alto
already exists. You may want to remove it:
  rm '/usr/local/share/tessdata/configs/alto'

To force the link and overwrite all conflicting files:
  brew link --overwrite tesseract

To list all files that would be deleted:
  brew link --overwrite --dry-run tesseract

给了三种操作方法。

如下操作:

$ sudo rm -rf /usr/local/share/tessdata/configs/alto
$ brew link --overwrite --dry-run tesseract
Would remove:
/usr/local/share/tessdata/configs/ambigs.train
...
/usr/local/lib/libtesseract.dylib -> /usr/local/lib/libtesseract.5.dylib
/usr/local/lib/pkgconfig/tesseract.pc
liumeng@liumengdeMacBook-Pro Pictures % tesseract -v
zsh: command not found: tesseract
liumeng@liumengdeMacBook-Pro Pictures % brew install tesseract
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 7 casks.

Warning: tesseract 4.1.3 is already installed, it's just not linked.
To link this version, run:
  brew link tesseract
$ brew link --overwrite tesseract
Linking /usr/local/Cellar/tesseract/4.1.3...
Error: Could not symlink share/tessdata/configs/alto
/usr/local/share/tessdata/configs is not writable.

继续删除:

$ sudo rm -rf /usr/local/share/tessdata/configs
$ brew link --overwrite tesseract
Linking /usr/local/Cellar/tesseract/4.1.3...
Error: Could not symlink share/tessdata/tessconfigs/batch
/usr/local/share/tessdata/tessconfigs is not writable.
$ sudo rm -rf /usr/local/share/tessdata/tessconfigs
$ brew link --overwrite tesseract
Linking /usr/local/Cellar/tesseract/4.1.3... 12 symlinks created.

验证:

$ tesseract -v
tesseract 4.1.3
 leptonica-1.82.0
  libgif 5.2.1 : libjpeg 9d : libpng 1.6.37 : libtiff 4.3.0 : zlib 1.2.11 : libwebp 1.2.1 : libopenjp2 2.4.0
 Found AVX2
 Found AVX
 Found FMA
 Found SSE

项目编译正常,结束!文章来源地址https://www.toymoban.com/news/detail-490942.html

到了这里,关于clang: error: linker command failed with exit code 1 (use -v to see invocation)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • XCode提示“Command PhaseScriptExecution failed with a nonzero exit code”

    许久没有遇到XCode提示错误信息了。针对这个问题,网上也有教程。我的解决办法是:查看Mac的【钥匙串】,证书列表里存在多个证书,有一对证书是相同的,并且一个是过期证书,一个是有效证书。把过期证书删除掉即可。 当然也有其他博主给的信息。附上链接,方便大家

    2024年02月12日
    浏览(34)
  • 解决XCode错误:Command PhaseScriptExecution failed with a nonzero exit code

    XCode版本:14.3 使用模拟器或真机调试、编译等都不出错,唯独在进行Archive时,会出现以下错误: 出错时的XCode截图如下: 展开XCode左侧的项目结构目录,逐级展开“Pods” - “Target Support Files” - \\\"Pods-项目名称\\\",打开其中的“Pods-项目名称-frameworks.sh”文件: 在该文件中,找

    2024年02月11日
    浏览(44)
  • IOS编译出现Command PhaseScriptExecution failed with a nonzero exit code

    在 Github 上下载了一个用 SwiftUI 开发的仿微信Demo.用Xcode15运行报以下错误. 首先我们得找到具体的错误,这报错太抽象啦. 那我们要在哪里看到具体的报错信息呢? 通过在 Stackoverflow 上搜索发现,点击导航栏最右边的图标 选中最近的build,在右边就能看到具体详细的编译错误信

    2024年01月24日
    浏览(37)
  • Xcode打包报错 Command PhaseScriptExecution failed with a nonzero exit code

    iOS发布,xcode13不能用了需要升级,不得已换了新电脑,安装最新Xcode打包发布,版本15.0.1。 遇到的问题,一打包就报错: Command PhaseScriptExecution failed with a nonzero exit code,网上有两种解决方法。 1:菜单栏选择File - Workspace Setting - Build System 选择Legacy Build System 重新运行即可。

    2024年02月02日
    浏览(46)
  • Xcode打包遇到的坑 Command PhaseScriptExecution failed with a nonzero exit code

    这个问题看网上的解决方法多为更改构建方式。 这其实是一个Xcode10引起的bug。 解决方案: 在Xcode菜单栏选择File - Workspace Setting - Build System 选择Legacy Build System 重新运行即可。 但是这里注意一下,我用最新的Xcode 14.2的版本并没有换构建方式的选项了,我改为13.4.1的版本后就

    2024年02月11日
    浏览(44)
  • Xcode14.3 升级后报错 Command PhaseScriptExecution failed with a nonzero exit code

    xcode升级到14.3运行和打包都报错:Command PhaseScriptExecution failed with a nonzero exit code 注意: 1.不要尝试去删除 DerivedData 下的文件解决问题,这只能是自己挖新坑 2.xcode14.3无论是swift项目还是oc项目,pod都有问题,修复方法见文末 3.报错如下: 2.1 pod问题 不要尝试去重新安装cocoap

    2023年04月26日
    浏览(31)
  • iOS 编译报错:Xcode Command PhaseScriptExecution failed with a nonzero exit code 解决方案

    iOS 报错“ Xcode Command PhaseScriptExecution failed with a nonzero exit code ” 解决方案 问题:xcode版本差异造成的不兼容。低版本xcode不兼容高版本xcode。 解决方案1: 在Xcode菜单栏选择File - Workspace Setting - Build System 选择Legacy Build System 重新运行 解决方案2: 将低版本xcode升级为最新版本,

    2024年02月13日
    浏览(41)
  • brew install报错Error: No developer tools installed. Error: Command failed with exit 128: git

    先来解决第一个问题 Error: No developer tools installed. Install the Command Line Tools: xcode-select --install 然后升级一下brew,出现警告。然后再次尝试安装tree 出现如下错误: fatal: not in a git directory Error: Command failed with exit 128: git 在终端输入 Homebrew 3.6.20 fatal: detected dubious ownership in repositor

    2024年02月05日
    浏览(55)
  • iOS-bug Xcode 14.3 archive打包失败,command PhasescriptExecution failed with a nonzero exit code

    升级到Xcode14.3后,打包出现如下问题 command PhasescriptExecution failed with a nonzero exit code 1、在Xcode中找到该路径文件,Pods/Targets Support Files/Pods-xxxxx/Pods-xxxx-frameworks.sh 2、找到 source =\\\"$(readlink \\\"${source}\\\")\\\"  更改为 source =\\\"$(readlink -f \\\"${source}\\\")\\\" 3、修改完成后,重新archive即可成功,亲测

    2024年02月14日
    浏览(40)
  • Job for network.service failed because the control process exited with error code.

    Linux Centos7 修改为静态iP后重启网络服务遇到的问题 重启网络:service network restart                   /etc/init.d/network restart 报错问题描述:Job for network.service failed because the control process exited with error code. See \\\"systemctl status network.service\\\" and \\\"journalctl -xe\\\" for details.   查看 cat /etc/sy

    2024年02月08日
    浏览(56)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包