XCode 在 /usr/include 中找不到 OpenSSL 标头

发布于 2024-08-31 19:01:33 字数 632 浏览 5 评论 0原文

我正在尝试在我的 C++ XCode 项目中使用标准系统头文件:

#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>

构建失败并抱怨:

"Openssl/bio.h: No such file or directory"

我将 /usr/include 添加到项目设置中的“头搜索路径”中,但这并不能解决问题。

我可以通过添加整个路径来修复它,例如:

#include </usr/include/openssl/bio.h>

-- 但该项目充满了类似的包含内容,我不想以这种方式更改所有内容。另外,我觉得我不应该这样做。

修复它的另一种方法是像另一个线程提到的那样,即将 /usr/include 添加到用户标头搜索路径。但如果我这样做,那么我必须更改所有尖括号 <>引用“”,这又像是一个黑客。我的意思是,这些是标准的系统头文件,所以我觉得它应该很简单,不需要这些类型的黑客。

有什么想法吗?

谢谢!

I'm trying to use standard system header files in my C++ XCode project:

#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>

The build fails and it complains:

"Openssl/bio.h: No such file or directory"

I added /usr/include to the "Header Search Paths" in Project settings, but that doesn't fix it.

I can fix it by adding the whole path like:

#include </usr/include/openssl/bio.h>

-- but the project is full of similar includes and I don't want to change all of them this way. Also, I feel I shouldn't have to do this.

Another way to fix it would be as another thread mentioned, which is to add /usr/include to User Header Search Paths. But if I do that, then I'd have to change all the angle brackets <> to quotes "", which again seems like a hack. I mean, these are standard system header files so I feel it should be something simple, not requiring these kinds of hacks.

Any ideas?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑,眼淚并存 2024-09-07 19:01:33

Xcode 使用当前选择的 SDK 作为基本路径,并将其作为系统包含的前缀。因此,如果您的 SDK 是 /Developer/SDKs/MacOSX10.6.sdk 那么默认情况下它将在 /Developer/SDKs/MacOSX10.6.sdk/usr/include 下查找对于系统包括。

有各种可能的解决方法 - 我可能只是在 /Developer/SDKs/MacOSX10.6.sdk/usr/include 中放置一个指向 /usr/include/openssl 的符号链接> 但既然您知道了根本问题,您就可以想到其他问题了。

Xcode uses the currently selected SDK as a base path, which it prefixes on to system includes. So if your SDK is /Developer/SDKs/MacOSX10.6.sdk then it will look under /Developer/SDKs/MacOSX10.6.sdk/usr/include by default for system includes.

There are various possible workarounds - I would probably just put a symbolic link in /Developer/SDKs/MacOSX10.6.sdk/usr/include pointing at /usr/include/openssl but you can probably think of others now that you know the underlying problem.

鹤仙姿 2024-09-07 19:01:33

这可能取决于 HFS(+) 不区分大小写这一事实。错误消息涉及大写“O”的“Openssl/bio.h”,但您在包含文件中指定了“openssl/bio.h”,并且 /usr/include 的路径有效。

我怀疑您的包含路径中有一些“Openssl”(大写“O”)目录,在查找“openssl/bio.h”时会使用该目录。如果 HFS(+) 从一开始就区分大小写,这种情况就不会发生(我知道有可能区分大小写,但它实际上是一个 PITA 使用......)

It might depend on the fact that HFS(+) is case insensitive. The error message talks about "Openssl/bio.h" with capital "O", but you're specifying "openssl/bio.h" in the include and the path with /usr/include works.

I suspect that there's some "Openssl" (capital "O") directory in your include path, that gets used when looking for "openssl/bio.h". This wouldn't happen if HFS(+) were case sensitive from the very beginning (I know it's possible to have is case sensitive, but it's actually a PITA to use...)

汹涌人海 2024-09-07 19:01:33

我已经能够避免在包含时指定路径,只需确保为添加文件中的文件夹选项选择为任何添加的文件夹创建组添加文件时弹出的“项目”对话框。

使用另一个选项,为任何添加的文件夹创建文件夹引用,我必须通过完整路径手动将其指向文件(并且文件夹图标显示为蓝色而不是正常的米色)。有趣的是,即使在这种情况下,AutoComplete 也能看到该文件,但 Xcode 抱怨它找不到它。

I've been able to avoid having to specify paths on includes by simply making sure to select Create groups for any added folders for the Folders option in the Add Files to Project dialog which pops up when you're adding the files.

With the other option, Create folder reference for any added folders, I have to manually point it to the file via the full path (and the folder icons show up blue instead of the normal beige). Interestingly, even in this case, AutoComplete sees the file, but Xcode complains it can't find it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文