gpt4 book ai didi

android - 如何在 clang (Android-Studio) 中使用 -v 获取 undefined reference 错误的详细输出

转载 作者:太空狗 更新时间:2023-10-29 13:52:17 25 4
gpt4 key购买 nike

每当您在 Android Studio 中遇到链接器错误时,它会建议您使用 -v 来查看调用,但是将 -v 命令放在哪里以获得“详细输出”(according to llvm clang command guide)?

已经尝试过:

externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions -v"
}
}

据我所知,这并没有改变输出中的任何东西

--stacktrace --debug

Settings > Compiler > Command-line Options  

这显示了更多的输出,但不是我要找的!
非常感谢您的提前帮助!

编辑

因为我正在编译 C 文件,所以我显然必须使用 cFlags。现在 gradle 文件如下所示(感谢@Alex Cohn):

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "<my_id>"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cFlags "-v"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
}

编辑 2

在几个 C 类中添加以下预处理器命令我没有注意到它们丢失了它,我能够摆脱关于缺少引用的链接器错误:

#ifdef __cplusplus
extern "C"
{
#endif

// your includes and your code here

#ifdef __cplusplus
}
#endif

最佳答案

  1. cppFlags "-frtti -fexceptions -v"cppFlags "-frtti", "-fexceptions", "-v" 一样适用于 < strong>clang++ 任务,即为 .cpp.cxx 文件编译获取详细输出。

  2. cFlags "-v" 用于为 .c 文件编译生成详细输出。

  3. 要为链接步骤生成详细输出,请编辑您的 CMakeLists.txt 文件,将 -v 添加到相关的 target_link_libraries 语句,例如

    target_link_libraries(myjnilib android log -v)
  4. 以上所有内容可能不足以理解和修复 undefined reference 错误。

关于android - 如何在 clang (Android-Studio) 中使用 -v 获取 undefined reference 错误的详细输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44882729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com