Android Studio NDK:使用预构建的OpenSll库 - 错误查找包括文件

发布于 2025-01-23 09:31:07 字数 1011 浏览 4 评论 0原文

我下载了Android Studio和NDK(Android Studio Bumblebee | 2021.1补丁3),并在我的Android手机上成功运行了“ Hello Word” CPP示例项目。 伟大的! 现在,我想在项目中使用OpenSSL功能和方法。

我从: https:// teskalabs下载了一个预构建的android二进制文件。 com/blog/openssl-binary-distribution-for-developers static-library 现在想在我的项目中包括静态库和标头文件。

在Android Studio中,我创建了一个“ Include”文件夹,其中我从Dowdloaded OpenSSL文件夹中复制了所有 *.H文件。我还添加了include_directories(src/main/cpp/include)在cmakelist.txt中。 最后,我添加了行#include< ssl.h>到本机lib.cpp-没事,没有openssl函数等。 当我尝试制作项目时,我会收到一个编译错误:致命错误:'ssl.h'文件找不到。如果我取出“ inclage”行,则所有内容都可以编译并运行正常。我还尝试了#include“ ssl.h” - 相同的错误。 我正在使用Windows 10。 我的项目树看起来像这样:

...
v main
  |
  cpp
    |
    > include
    CMakeList.txt
    native-lib.cpp
...

如果我打开“ inclage”选项卡,则具有所有ssl.h等文件。

我在做什么错?为什么Android Studio找到标题文件?

I dowloaded Android studio and NDK (Android Studio Bumblebee | 2021.1.1 Patch 3) and compiled and run the "Hello Word" CPP example project successfully on my Android phone.
Great!
Now I want to use openssl functions and methods in my project.

I downloaded a prebuilt Android binaries from: https://teskalabs.com/blog/openssl-binary-distribution-for-developers-static-library and now want to include the static libraries and header files in my project.

In Android Studio I created an "include" folder where I copied all *.h files from dowdloaded openssl folder. I also added include_directories(src/main/cpp/include) in CMakeList.txt.
Lastly I added line #include <ssl.h> to native-lib.cpp - nothing else, no openssl function etc.
When I try to make my project I get a compile error: fatal error: 'ssl.h' file not found. If I take out the "include" line everything compiles and runs fine. I also tried #include "ssl.h"- same error.
I am using Windows 10.
My project tree looks like this:

...
v main
  |
  cpp
    |
    > include
    CMakeList.txt
    native-lib.cpp
...

If I open the "include" tab it has all the ssl.h etc files.

What am I doing wrong? Why does Android Studio find the header files?

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

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

发布评论

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

评论(1

冷…雨湿花 2025-01-30 09:31:07

经过三天的尝试和尝试,并提出问题,我终于找到了问题所在。
而不是使用:

include_directories(src/main/cpp/include)

我使用了:

include_directories(include)

现在它链接

After 3 days of trying and trying and afer posting the question I finally found what the problem was in my case.
Instead of using:

include_directories(src/main/cpp/include)

I used this:

include_directories(include)

Now it links

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