clang toolchain + ndk build in android studio missing include paths

463 views
Skip to first unread message

Iliya

unread,
Jan 8, 2016, 5:54:32 PM1/8/16
to adt-dev
Just switched the toolchain to clang in and gladle.build file and now seem to be missing a bunch of include paths that were working previously
seems to be related to the C files only

android.ndk {
    moduleName = "NdkTest"
    toolchain = "clang"
    toolchainVersion = "3.6"

    // Generic stuff
    cppFlags += "-O2"
    cppFlags += "-frtti"
    cppFlags += "-fexceptions"
    cppFlags += "-fpermissive"
    cppFlags += "-std=gnu++11"

    cppFlags += "-DHAVE_CONFIG_H"
    cppFlags += "-DUSE_FILE32API"

    def jniPath = "src/main/jni"
    def srcPath = "-I${file(jniPath)}".toString()
    file(jniPath).eachDirRecurse { dir ->
        srcPath += "-I${file(dir)}".toString()
    }

    cppFlags += srcPath
    CFlags += srcPath

    ldLibs += ["android", "EGL","GLESv2", "dl", "log", "jpeg", "png", "tiff"]
    stl = "c++_static"
}

example of error:
compiling mat4.c failed.
/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/src/mat4.c:33:10: fatal error: 'kazmath/utility.h' file not found
#include "kazmath/utility.h"


file is in:
/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/include/kazmath/utility.h


and the options.txt file shows the directory being included:
-I/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath
-I/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/include
-I/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/include/kazmath
-I/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/include/kazmath/GL
-I/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/src
-I/Users/ik/git/mobile/android/androidStudioProjects/ndkTest/ndkTest/src/main/jni/src/cocos2d/cocos2dx/kazmath/src/GL



Raymond Chiu

unread,
Jan 11, 2016, 3:18:53 PM1/11/16
to adt-dev
Hi Iliya,

I don't see any obvious issue with your build.  One thing to try is the run the gradle command with the "-i" flag.  It will give you the compiler command that was used and you can check if the command works on its own.  Double check the options.txt you are looking at is for compiling C and not C++.  Sorry if these are obvious to you and you have already tried it.

Also, the plugin you are using seems to be quite old.  Consider switching to a newer plugin version.  An unfortunate effect is that you will need to replace += with .add(...). 

Raymond

Iliya

unread,
Jan 20, 2016, 11:36:44 AM1/20/16
to adt-dev
Okay, checked, those, and updated to 0.6.0-alpha6. Fixed all the += to .add, did the other modifications mentioned in the docs (nested the config, etc.) now getting this error on gradle sync:

2016-01-20 10:07:29,280 [86644079]   WARN - nal.AbstractExternalSystemTask - Exception thrown while executing model rule: AndroidComponentModelTestPlugin#createConnectedTestTasks 
com.intellij.openapi.externalSystem.model.ExternalSystemException: Exception thrown while executing model rule: AndroidComponentModelTestPlugin#createConnectedTestTasks
at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:457)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:158)
at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:349)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:373)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:339)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:230)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:97)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:65)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:419)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:500)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:365)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)

Seems to be related to proguard somehow from what I can tell but haven't found anything at all about this anywhere on stackoverflow or any of the android groups here. Any ideas on what might be the solution for this, am I missing an argument somewhere.
Reply all
Reply to author
Forward
0 new messages