【发布时间】:2021-02-02 14:51:23
【问题描述】:
有一个 Github 存储库,其中包含我有兴趣使用的 C++ 库的 Python“绑定”。 README 中有大量关于如何在类似 Linux 的机器上安装 C++ 库的信息,但没有关于如何在 mac OS 上安装的信息。
我还提出了一个问题,要求 README 安装说明除了 linux 之外还包括特定于 mac OS 的安装。没有关于该问题的任何活动。
这是两个 repos:
由于无法通过 Brew/pip/anaconda 安装 C++ 包,因此我不知道如何开始。
我的尝试:
我尝试过./configure 和make。没有./configure 文件。
要解决./configure 的缺失问题,请阅读一个名为autoconf 的工具,它可以为您生成./configure。我用brew 安装它,但不确定要传递什么参数。这些文档很难理解:https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Making-configure-Scripts.html
仅使用 make 会导致错误叮当声:error: unsupported option '-fopenmp'这让我陷入了一个完全不同的兔子洞,这让我在 Makefile 中添加了行:
CPP = /usr/local/opt/llvm/bin/clang
CPPFLAGS = -I/usr/local/opt/llvm/include -fopenmp
LDFLAGS = -L/usr/local/opt/llvm/lib
omp_hello: omp_hello.c
$(CPP) $(CPPFLAGS) $^ -o $@ $(LDFLAGS)
那感觉很危险,因为我不知道这些东西是什么意思。另外它导致了一个新错误:*** missing separator. Stop.
然后我读到这可能是由于使用“软”标签而不是可以使用cat -e -t -v makefile_name 识别的“硬”标签。我找到了缺少“硬”标签的一行(上面的缩进行)并将其插入。这导致了一个新错误:
make: *** No rule to make target `omp_hello.c', needed by `omp_hello'. Stop.
接下来,在杨玉石和他对 cmets 的建议下,我根据他的回答更改了第 39 行和第 40 行,并在CXXFLAGS 变量中添加了一些额外文件的位置:
-I//opt/homebrew/Cellar/libomp/11.0.1/include
-L/opt/homebrew/Cellar/libomp/11.0.1/lib
这让我更进一步。接下来,正如this answer 所解释的那样,OSX 不喜欢这个脚本试图安装的位置。所以我在 makefile 中更改了这两行,这似乎决定了安装位置:
INSTALL_HEAD_DIR = $(DESTDIR)/usr/include/libspot
INSTALL_LIB_DIR = $(DESTDIR)/usr/lib
到
INSTALL_HEAD_DIR = $(DESTDIR)/usr/local/include/libspot
INSTALL_LIB_DIR = $(DESTDIR)/usr/local/lib
这确实让我走得更远。接下来我遇到了一个错误,在 makefile 的这些行中抱怨 flat -t:
@install -t $(INSTALL_LIB_DIR) $(LIB_DIR)/*.so
@install -t $(INSTALL_HEAD_DIR) $(INC_DIR)/*.h
所以我删除了那些标志,然后导致了这个错误:
Checking the headers installation directory (/usr/local/include/libspot)
Checking the library installation directory (/usr/local/lib)
Installing the shared library (libspot.so)
install: /usr/local/lib: Inappropriate file type or format
我找不到任何阅读材料,也不知道如何解决。任何进一步的帮助表示赞赏。
以下是我为回答这个问题而仔细阅读过的 SO 和其他资源的列表:
- Enable OpenMP support in clang in Mac OS X (sierra & Mojave)
- makefile error: make: *** No rule to make target `omp.h' ; with OpenMP
- makefile:4: *** missing separator. Stop
- http://www.idryman.org/blog/2016/03/10/autoconf-tutorial-1/
- https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Making-configure-Scripts.html
- https://developer.gnome.org/anjuta-build-tutorial/stable/create-autotools.html.en
我的问题
我该如何进行。
如果您知道如何执行此操作,能否还简要说明每个步骤背后的概念?我很乐意学习一点,而不仅仅是按正确的顺序复制和粘贴命令。
【问题讨论】:
标签: python c++ macos installation