每當您在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那裏btw –
這很奇怪;實際上,對於我來說,用逗號分隔的列表和帶空格的引號字符串都是可行的。你應該檢查你的'app/.externalNativeBuild/cmake/debug/armeabi-v7a/android_gradle_build.json'文件。但我有一個假設:也許你正在編譯一個C文件? –