首页 > 解决方案 > 从 macOS 构建 sqlcipher3 时出现致命错误(未找到“sqlcipher/sqlite3.h”文件)

问题描述

我一直在尝试使用以下命令在 MacOS 上构建 sqlcipher3:

git clone https://github.com/coleifer/sqlcipher3 && cd sqlcipher3
python3 setup.py build

我收到以下错误:

$ python3 setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
creating build/lib.macosx-10.14-x86_64-3.7/sqlcipher3
copying sqlcipher3/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/sqlcipher3
copying sqlcipher3/dbapi2.py -> build/lib.macosx-10.14-x86_64-3.7/sqlcipher3
running build_ext
Builds a C extension linking against libsqlcipher library
building 'sqlcipher3._sqlite3' extension
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/src
xcrun -sdk macosx clang -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Qunused-arguments -DMODULE_NAME="sqlcipher3.dbapi2" -I/usr/include -I/Users/gab/Downloads/testbuild/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/include/python3.7m -c src/module.c -o build/temp.macosx-10.14-x86_64-3.7/src/module.o
In file included from src/module.c:24:
src/connection.h:34:10: fatal error: 'sqlcipher/sqlite3.h' file not found
#include "sqlcipher/sqlite3.h"
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'xcrun' failed with exit status 1

但是使用 brew 正确安装了 sqlcypher:

$ brew install sqlcipher
Warning: sqlcipher 4.4.2 is already installed and up-to-date
To reinstall 4.4.2, run `brew reinstall sqlcipher`

sqlite3.h在过程中添加:

$ find /usr/local/Cellar -name sqlite3.h
/usr/local/Cellar/sqlite/3.33.0/include/sqlite3.h
/usr/local/Cellar/sqlite/3.34.0/include/sqlite3.h
/usr/local/Cellar/sqlcipher/4.4.2/include/sqlcipher/sqlite3.h

有什么我想念的吗?我应该在运行时添加路径标志python3 setup.py build吗?

标签: cbuildhomebrewsqlcipher

解决方案


我会

C_INCLUDE_PATH=/usr/local/Cellar/sqlcipher/4.4.2/include LIBRARY_PATH=/usr/local/Cellar/sqlcipher/4.4.2/lib python3 setup.py build

试一下。


推荐阅读