【发布时间】:2016-10-17 07:04:11
【问题描述】:
我正在尝试将 libsass(一个 C 库)导入到我用 Swift 编写的 OSX 项目中。但不知何故,我正在处理很多依赖问题。顺便说一句,我在这里使用本指南中的 Module maps 方法:https://spin.atomicobject.com/2015/02/23/c-libraries-swift/。
libsass 存储库:https://github.com/sass/libsass
我可以在 c: 中运行 version.c(提供的示例 libsass)程序:
#include <stdio.h>
#include "sass/context.h"
int main() {
puts(libsass_version());
return 0;
}
我的方法是在“libsass/include”目录中导入头文件。
这是迄今为止的尝试:
1我建了一个module.map文件,放在libsass目录下。
module libsass [system] {
header "include/sass.h"
export *
}
2然后我将目录添加到我的 swift 项目中
3 设置 Swift Compiler > Search Paths > Import Paths to '${SRCROOT}/libsass'
4 构建,我遇到了这个:
'sass/base.h' file not found with <angled> include; use "quotes" instead
'sass/version.h' file not found with <angled> include; use "quotes" instead
'sass/values.h' file not found with <angled> include; use "quotes" instead
5 构建设置 > 搜索路径 > 标头搜索路径设置为“$(PROJECT_DIR)/libsass/include”
构建设置 > 搜索路径 > 库搜索路径设置为“$(PROJECT_DIR)/libsass/include”
这次我没有看到之前的错误但是在test_superselector.cpp中遇到了一个新的错误:
'../ast.hpp' file not found
6 我在 Build settings > Linking > Other Linker Flags 中添加了“-lsass”。由于在 libsass 提供的示例中,他们使用 -lsass 标志来编译 c 代码。
同样,不好。
我花了两天时间试图弄清楚这一点,但没有明显的进展。请查看 libsass 存储库。任何帮助表示赞赏。 谢谢!!
【问题讨论】: