![](/img/trans.png)
[英]Generate signed apk fails with build\app\intermediates\flutter\profile\libs.jar (The system cannot find the path specified)
[英]CMake fails in build because cannot find STL libs
我正在嘗試在Android Studio項目中使用.c和.cpp文件,我已經使用包含的所有文件配置了CMakeList。
我的CMakeList是這樣的:
file(GLOB SOURCES "src/main/cpp/B/*.cpp")
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
src/main/cpp/native-lib.cpp
src/main/cpp/A/B/src/a.c
src/main/cpp/A/B/src/b.c
src/main/cpp/A/B/src/c.c
src/main/cpp/A/B/src/d.c
src/main/cpp/A/a.cpp
src/main/cpp/A/B/src/e.c
src/main/cpp/B/a.cpp
${SOURCES})
考慮到我有這樣的目錄:
+--- /cpp
| +--- /A
| | +--- /B
| | | +--- /include
| | | | +-- *.h
| | | +--- /src
| | | +-- *.c
| | |
| | |
| +--- /B
| | +--- /include
| | | +-- *.h
| | +--- /src
| | +-- *.cpp
當我運行項目時,我得到了這個
../include/a.h:68:10: fatal error: 'algorithm' file not found
在啊,我有這個宣言
#include <algorithm>
此外,在我擁有的一行中:使用命名空間std,IDE表示使用無法解析類型
我認為cmake有點以不正確的方式混合了.c和.cpp文件。
您正在C源文件( .c
)中包含C ++標頭。 您不能期望gcc
(當Cmake遇到.c
時由Cmake調用的C源代碼編譯器)理解C ++。
它可以在g++
工作,因為它是C ++編譯器。 請注意,g ++會將.c
文件當作C ++處理( .cxx
和.cpp
)。 CMake不會這樣做,因為C和C ++之間存在許多不同的不兼容性 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.