如何使用-ng在clang中获取未定义引用错误的详细输出(Android-Studio)
每当您在Android Studio中遇到链接器错误时,都建议您使用-v来查看调用,但是在哪里放置-v命令获得“详细输出”(according to llvm clang command guide)?如何使用-ng在clang中获取未定义引用错误的详细输出(Android-Studio)
已经尝试过:
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions -v"
}
}
未在输出进行任何更改,据我注意到和
--stacktrace --debug
在
Settings > Compiler > Command-line Options
这是显示方式更多的输出,但不是我在找什么!
非常感谢您的帮助!
编辑
,因为我编译C文件,我显然不得不使用CFLAGS。现在gradle这个文件看起来如下(感谢@Alex科恩):
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'
}
EDIT 2
在几个C-类我没有注意到它们不具有添加以下预处理器指令它,我能摆脱我的链接错误关于丢失的引用:
#ifdef __cplusplus
extern "C"
{
#endif
// your includes and your code here
#ifdef __cplusplus
}
#endif
cppFlags "-frtti -fexceptions -v"
作品,以及cppFlags "-frtti", "-fexceptions", "-v"
for 铿锵++任务,即得到详细输出为.cpp或.cxx文件编译。cFlags "-v"
工作产生详细输出为.c文件编译。-
为了生产用于链接步骤的详细输出,编辑您的CMakeLists.txt文件,添加
-v
到相关target_link_libraries语句,例如target_link_libraries(myjnilib android log -v)
- 上述所有可能没有足够的理解和固定未定义参考错误。
In我的情况下,链接器错误是在几个C文件中丢失的预处理器命令(请参阅我的答案中的更新2)。我需要该命令,因为我使用Android Studio创建的默认.cpp文件作为我的Java接口class ...非常感谢您的帮助和时间@Alex Cohn –
还有什么帮助我将“--debug”设置为设置>构建,执行,部署(AS 3.0)中的命令行选项。能够看到一些缺失的链接器引用 - 考虑将其添加到列表中 –
你试过'cppFlags“-frtti”,“-fexceptions”,“-v”'? –
刚刚尝试没有任何成功。 cppFlags“-frtti -fexceptions”是自动生成的,我只添加了-v那里btw –
这很奇怪;实际上,对于我来说,用逗号分隔的列表和带空格的引号字符串都是可行的。你应该检查你的'app/.externalNativeBuild/cmake/debug/armeabi-v7a/android_gradle_build.json'文件。但我有一个假设:也许你正在编译一个C文件? –