brew install libusb链接失败 [英] brew install libusb linking failed

查看:450
本文介绍了brew install libusb链接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在Mac中安装带有 brew libusb

I am installing libusb with brew in my Mac

brew安装libusb

brew install libusb

链接步骤失败,如下所示

The linking step failed as below

Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local 

Could not symlink lib/libusb-1.0.0.dylib 

Target /usr/local/lib/libusb-1.0.0.dylib already exists. 

You may want to remove it:   rm '/usr/local/lib/libusb-1.0.0.dylib'

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

所以我用

sudo rm'/usr/local/lib/libusb-1.0.0.dylib'

sudo rm '/usr/local/lib/libusb-1.0.0.dylib'

然后创建了一个链接

brew链接-覆盖libusb

brew link --overwrite libusb

链接无效,下面显示错误

The linking doesn't work, shows error below

错误:无法符号链接lib/libusb-1.0.0.dylib

Error: Could not symlink lib/libusb-1.0.0.dylib

/usr/local/lib是不可写的.

/usr/local/lib is not writable.

如果我尝试

sudo brew链接-覆盖libusb

sudo brew link --overwrite libusb

相反,这也不起作用.我想念什么?

instead, that doesn't work either. What am I missing?

我正在使用OSX El Capitan版本10.11.4(15E65)

I am using OSX El Capitan version 10.11.4 (15E65)

推荐答案

如果homebrew似乎不起作用,我的一般策略是首先尝试:

If things seem not to work with homebrew, my general strategy is first to try:

brew doctor

做好医生推荐的事情.

如果失败,我倾向于卸载东西,通常使用--force确实可以很好地清理并删除旧版本.因此,在您的情况下:

If that fails, I tend to uninstall things, normally using --force which really does a good clean-up and removes old versions. So, in your case:

brew rm libusb --force

然后重新安装不满意" 软件包.因此,在您的情况下:

Then re-install the "unhappy" package. So, in your case:

brew install libusb

在评论中回答您的新问题.您的安装看起来正确,因为libusb不是可执行程序-它只是一个没有任何关联的命令行工具的库-因此,当您运行which libusb时,它不会显示.

In answer to your new question in the comments. Your installation looks correct because libusb isn't an executable program - it is just a library without any associated command-line tools - so it won't show up when you run which libusb.

您可以使用以下命令查看软件包的组成部分:

You can see the constituent parts of the package with this command:

brew ls libusb

/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0/libusb.h
/usr/local/Cellar/libusb/1.0.20/lib/libusb-1.0.0.dylib
/usr/local/Cellar/libusb/1.0.20/lib/pkgconfig/libusb-1.0.pc
/usr/local/Cellar/libusb/1.0.20/lib/ (2 other files)

而且,如您所见,在/usr/local/bin中没有名为libusb的独立可执行程序,只有

And, as you can see, there is no stand-alone executable program in /usr/local/bin called libusb, there are just

  • libusb.h-您要针对其编译的C头文件
  • libusb ... dylib-您要链接的动态库
  • libusb ... pc-提供pkgconfig工具的信息
  • libusb.h - a C header file you would compile against
  • libusb...dylib - a dynamic library you would link against
  • libusb...pc - which supplies the info for the pkgconfig tool

因此,如果要针对libusb编译和链接应用程序,则可以像这样运行pkg-config来找出包含路径" 和链接器详细信息

So, if you wanted to compile and link an application against libusb, you would run pkg-config like this to find out the "Include path" and linker details

pkg-config --cflags --libs libusb

-I/usr/local/Cellar/libusb-compat/0.1.5/include      \ 
-I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 \
-L/usr/local/Cellar/libusb

这意味着您的编译命令将如下所示:

which means your compilation command would look like this:

gcc yourApp.c $(pkg-config --cflags --libs libusb) -o yourApp

这篇关于brew install libusb链接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆