googlesamples / vulkan-basic-samples

Other
498 stars 111 forks source link

Build errors on Windows with latest Android Studio / SDK / NDK #22

Closed daveh-lunarg closed 6 years ago

daveh-lunarg commented 6 years ago

Samples fail to build on latest Win10 setup.

Steps to reproduce:

  1. Fresh install of Android Studio on Windows
  2. Config AS to install latest platform-tools (28.0.0), NDK (17.1.4828580), SDK Tools (26.1.1)
  3. Config AS to install platforms 23-28.
  4. Install VulkanAPISamples via AS, which fetches this repo. Decline offer to upgrade to gradle 4.x. 4a. Project requests to use older 25.0 build-tools - allow and install.
  5. Follow README.md instructions to build shaderc within NDK, with STL=gnustl_static and ABI=all
  6. Attempt to run any of the samples on an ADB device fails to compile, e.g.
Error while executing process C:\Android\SDK\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\android\draw_textured_cube\.externalNativeBuild\cmake\debug\x86 --target vulkan_sample}
[1/5] Building CXX object utils/CMakeFiles/vsamputils.dir/util.cpp.o
FAILED: C:\Android\SDK\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=i686-none-linux-android --gcc-toolchain=C:/Android/SDK/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64 --sysroot=C:/Android/SDK/ndk-bundle/sysroot   -IC:/Android/git/android-ndk/API-Samples/data -IC:/Android/SDK/ndk-bundle/sources/third_party/shaderc/third_party/glslang -IC:/Android/git/android-ndk/VulkanAPIsamples/API-Samples/utils -IC:/Android/SDK/ndk-bundle/sources/android/native_app_glue -IC:/Android/git/android-ndk/VulkanAPIsamples/API-Samples/utils/../android/vulkan_wrapper -IC:/Android/git/android-ndk/VulkanAPIsamples/API-Samples/utils/../data -IC:/Android/SDK/ndk-bundle/sources/third_party/shaderc/include -isystem C:/Android/SDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem C:/Android/SDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem C:/Android/SDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -isystem C:/Android/SDK/ndk-bundle/sysroot/usr/include/i686-linux-android -D__ANDROID_API__=24 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security   -std=c++11  -Werror -DVK_USE_PLATFORM_ANDROID_KHR -O0 -fno-limit-debug-info  -fPIC -MD -MT utils/CMakeFiles/vsamputils.dir/util.cpp.o -MF utils\CMakeFiles\vsamputils.dir\util.cpp.o.d -o utils/CMakeFiles/vsamputils.dir/util.cpp.o -c C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp
C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp:232:9: error: use of undeclared identifier 'strncmp'
    if (strncmp(magicStr, "P6", sizeof(magicStr))) {
        ^
C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp:515:44: error: use of undeclared identifier 'strlen'
        compiler.CompileGlslToSpv(pshader, strlen(pshader), MapShadercType(shader_type), "shader");
                                           ^
C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp:564:37: error: use of undeclared identifier 'strlen'
    if (strncmp(option, optionLine, strlen(option)) == 0)
                                    ^
C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp:815:13: error: use of undeclared identifier 'memcpy'; did you mean 'wmemcpy'?
            memcpy(writebuf, this->pbase(), this->pptr() - this->pbase());
            ^~~~~~
            wmemcpy
C:/Android/SDK/ndk-bundle/sysroot/usr/include\wchar.h:175:10: note: 'wmemcpy' declared here
wchar_t* wmemcpy(wchar_t* __dst, const wchar_t* __src, size_t __n);
         ^
C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp:815:20: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [129]'
            memcpy(writebuf, this->pbase(), this->pptr() - this->pbase());
                   ^~~~~~~~
C:/Android/SDK/ndk-bundle/sysroot/usr/include\wchar.h:175:27: note: passing argument to parameter '__dst' here
wchar_t* wmemcpy(wchar_t* __dst, const wchar_t* __src, size_t __n);
                          ^
C:\Android\git\android-ndk\VulkanAPIsamples\API-Samples\utils\util.cpp:955:12: error: use of undeclared identifier 'EACCES'
    return EACCES;  // can't provide write access to the apk
           ^
6 errors generated.
ninja: build stopped: subcommand failed.
ggfan commented 6 years ago

may you check to see adding string.h into that util.cpp would get you going for now? I will be able to get to this in the evening at the earliest.

daveh-lunarg commented 6 years ago

Yes, adding

#include "string.h"
#include "errno.h"

to util.cpp solves the problem.

Thanks!

ggfan commented 6 years ago

Upstream is updated, need to be pull down to this repo

ggfan commented 6 years ago

this should be fixed now, thanks