Configure Visual Studio 2017 to use existing Android SDK and NDK components - c++

I have set up Visual Studio 2017 to work with Android NDK by installing Visual C++ Android tools, Apache ANT and configuring the locations of existing SDK, NDK and JDK locations.
I have installed LLDB, configured the clang.exe location and included all the headers from /ndk-bundle/sources.
I am trying to build the default Android Native Activity project. An older version can be found here: https://msdn.microsoft.com/en-us/library/dn707595.aspx
But still I am getting a lot of errors and all of the #includes underlined. When I try to build the solution I get the following error.
Severity Code Description Project File Line Suppression State
Error TRK0002 Failed to execute command:
"C:\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
#C:\Users\Saminda\AppData\Local\Temp\tmpcecf4937c8a14139b9405a2aae30e2e6.rsp".
The handle is
invalid. NDKSample.NativeActivity C:\Users\Saminda\source\repos\NDKSample\NDKSample\NDKSample.NativeActivity\TRACKER 1
Any help would be appreciated.

Ant is no longer used by Android projects, replaced by Gradle.
After several experiments from the Android team, they ended up settling with Gradle + CMake, with ndk-build for legacy NDK projects.
Here is the Android documentation how to migrate to Gradle + CMake.
https://developer.android.com/studio/projects/add-native-code
https://developer.android.com/ndk/guides/cmake
I imagine you would need to update the build scripts in the generated project.

Related

Installing OR-Tools to Visual Studio 2022

I am trying to write a code using Google's OR-Tools on Microsoft Visual Studio 2022.
I followed the following steps:
Download OR-Tools from Binary on Windows on their website.
Extracted the .zip file in D:\CodeField
Wrote the complete TSP programs of their website on VS.
In Visual Studio, went to Project > Properties > C/C++ > Additional Include Directories
Added "D:\CodeField\or-tools_x64_VisualStudio2022_cpp_v9.5.2237\include"
Clicked Apply then OK then compiled my code.
I am getting a bunch of linking errors "1>ortools.lib(scip_callback.obj) : error LNK2001: unresolved external symbol SCIPconshdlrGetData".
what should I do?
Try adding the lib folder in linker settings and link ortools_full.lib. If there are other errors try changing the runtime library to /MD. Make sure you use C++17.
Visual Studio
To build and run OR-Tools on Windows, you must have Visual Studio 2019 or later installed on your computer with the C++ toolset for Visual Studio.
You can find more details here.
To build OR-Tools programs from the command line you must use a x64 Native Tools Command Prompt (not the Developer Command Prompt).
You can find more details here.
Git
Git, which can be downloaded from https://git-scm.com/.
CMake
CMake (>= 3.18), which can be downloaded from https://www.cmake.org/download. When installing CMake, select the option for a command-line accessible cmake.
.NET Core 3.1 SDK
You must install the package .NET Core 3.1 SDK version 3.1.100 or higher from the following location: sdk-3.1.425-windows-x64-installer
.Net 6.0 SDK
You must install the package .NET 6.0 SDK from the following location: sdk-6.0.403-windows-x64-installer
Download the source code
There are two distinct branches of the OR-Tools source code on GitHub: stable and main.
The stable branch has been thoroughly tested and should work flawlessly on all supported platforms.
The main branch is where the latest updates and improvements have been applied; it's more current, but less stable.

Visual Studio 2019 x64 app using mongocxx driver

I'm trying to get a windows x64 C++ project working with the latest mongocxx driver using Visual Studio 2019. I installed the driver libraries using vcpkg:
vcpkg install mongo-cxx-driver[boost]
In VS 2019 I created a new console app and inserted the example code from the mongo driver page into main(). I built the app and ran it; everything works great. Then I noticed that it built as a win 32 app and switched it over to x64. Now the project won't build b/c it can't find the header files. Specifically (1rst error only...the others are similar)
Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'bsoncxx/json.hpp': No such file or directory
What do I need to do to make it work on the x64 platform?
As I suspected, it was something I just didn't know to do. From Neumann-A on the vcpkg github site:
vcpkg install mongo-cxx-driver[boost]:x64-windows
or
vcpkg install mongo-cxx-driver[boost] --triplet x64-windows
or
set VCPKG_DEFAULT_TRIPLET=x64-windows
vcpkg install mongo-cxx-driver[boost]

Android SDK Build Tools different versions in Android Studio and Visual Studio

I use Android Studio to build native Android projects and I installed the latest version of the Android SDK.
I also use Visual Studio to build Xamarin.Android projects. However when the build process runs in Visual Studio, it uses a previos version of the Build Tools.
I checked the SDK managers and found the following:
Both manager uses the same SDK path (C:\Android\SDK)
The latest Build Tools are installed (v28.0.3 as of time)
Visual Studio can't find the latest version
I already targeted API level 28 but it didn't help
Here you can see side-by-side the managers:
Any ideas how to fix this?

Unable to add Google Test NuGet package to a Visual Studio Linux C++ project

I have a Linux C++ project in Visual Studio 2017 which contains unit tests, and I'm trying to add the Google test framework to it. I have added the gtest NuGEt package to the project, and in every file that uses this, I have a #include "gtest/gtest.h". This works fine in a Windows-based unit test project, but in the Linux C++ project (all else being equal as far as I can tell), the NuGet package doesn't seem to be able to work, and when I compile I get the following error :
gtest/gtest.h: No such file or directory.
Does anyone know why this doesn't work?
That's because VS Linux projects are compiled and executed on a connected Linux machine (see Tools / Options / Connection Manager). Which in your case does not have Gtest installed.

Visual Studio 2017 with CUDA cannot open include file 'cuda.h'

I am working on the Nvidia SDK with Visual Studio and I have been running into the error of this whenever I am trying to compile the sample from Nvidia:
Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'cuda.h': No such file or
directory AppDecPerf
c:\users\administrator\desktop\video_codec_sdk_8.1.24\samples\appdecode\appdecperf\appdecperf.cpp 12
I do have CUDA installed on my computer and it looks like I have to link it with the IDE somehow but I just cannot find 'cuda.h' file anywhere.
Any help is appreciated. Thanks!
Install cuda library( static or dynamic) for Windows in vc++ 2017 using vcpkg.exe. Use .\vcpkg integrate install to automatically link the project to your solution.
Use .\vcpkg install cuda:x64-windows-static to install.
Right click your project, choose Build Dependencies then Build Customizations. From here you can choose the version of the CUDA Toolkit that you'd like to work with (amongst other things it will add the $(CudaToolkitDir) variable, and a new CUDA C/C++ tab to the project properties). The samples from NVIDIA should already be configured this way, but I've noticed that they can break when upgrading the SDK.
Further details are available here:
https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html#build-customizations-for-existing-projects