Build release version of shared *.so library with Android Studio - c++

I am making a C++ share library for Android. I created new project with Android Studio and enabled C++.
I also enabled C++ 11 ans Exception support.
New project was created and the build.gradle and CMakeLists.text files were generated. The problem is that Adnroid Studio is only generating a Debug version of the *.so library. I need the release version to be generated too.
The debug library is being generated at
\app\build\intermediates\cmake\debug\obj\\libnative-lib.so
I noticed there is another directory at
\app\build\intermediates\cmake\debug\obj\
but it is empty. It does not have the release version of the library.
How can I force Android Studio to build/compile the release version of the *.so library. I put those images up to make sure that I didn't miss any step.
Using Android Studio 2.3.

Played around with Android Studio and discovered that this can be changed by selecting the Root of your project (app) going to Build --> Select Build Variant... then change the Build Variant from Debug to Release.

You can also use the gradle target assembleRelease in the commandline. This will automatically build for all architectures. gradlew should be in the root of the Android Studio project.
./gradlew assembleRelease

Related

Why Qwt extension does not work in Qt Visual Studio?

Im currently woking in Visual Studio 2022 with Qt extension with MSVC 2019 Qt version 5.12.2 x64. I succesfully executed qmake in Qt Creator 6.4.0 and obtained build (msvc2019 x64) release folder. Then I ran nmake and nmake install which got me Qwt-6.2.0 folder in my C drive with doc,features,include,lib and plugins folders. I also added qwt_designer_plugin.dll to plugins designer. After that I tried to add qwtPlot in Qt designer but when I ran programme I get this error message:
Error message
I tried to add libs and include files via project properties but nothing worked at all. Any suggestions please?
I figure it out myself. Note that Qt (as least up to the 5 releases) have a consistent naming of their files, modules and libraries: With or without a d suffix. If a DLL have a d suffix (like Qt5Cored.dll) then it's a library for debug builds, make sure you build with the debug libraries for your debug build.
So you just add qwtd.lib for debug and qwt.lib for release in Additional Dependencies.

Trouble generating a deployable binary for a C++ wxwidgets project using Visual Studio

I’m having trouble generating a deployable binary for a C++ wxwidgets project using Visual Studio. After the build completes, the exe that is generated does not seem to get installed in any other Windows machine.
Visual studio 2019 is used to create GUI library with openCV included in it. I’m trying to create a standalone executable .exe to run it in any other Windows computer without installing visual studio or opencv in it.
Earlier, while opening the executable file in other computer, it gave error that dll’s are missing for openCV and wxwidgets. So, I have copied the required dll’s from the directories of openCV and wxwidgets bin folder. Now, when I try to execute the exe file, it shows the following error. Kindly help me to resolve this issue.
Applications built with the C/C++ runtimes dynamically linked (/MD[d]) require the appropriate x86 (32-bit) or x64 (64-bit) VC++ redistributables on the target machine. They can be installed from The latest supported Visual C++ downloads, or they can be included alongside the application for local deployment.
Also, be sure to only send out non-debug (Configuration = Release) builds.
MSVCP140D.dll
VCRUNTIME140D.dll
VCRUNTIME140_1D.dll
ucrtbased.dll
The 'D' suffix in the names of those missing DLLs stands for "Debug". Those are the debug C/C++ runtime DLLs, which are used by the Configuration = Debug builds, and are installed as part of the Visual Studio setup. They are to be used during development, but not otherwise deployed, per Determining Which DLLs to Redistribute:
Debug versions of applications and the various Visual C++ debug DLLs are not redistributable.
It also seems that you are using DLL build of wxWidgets and you build OpenCV as DLL.
If you yourself does not create a DLL and your software is one self contained binary ou will be better off using static linking wxWidgets and OpenCV.
And on top of what #dxiv, not everything in MS CRT can be used statically linked. That's why it is strongly recommended to install MS CRT by creating an installer, which should take care of all those dependencies.
HTH.
Thank you.

How to fix error MSVCP120D.dll in Visual Studio 2015?

Hello I have downloaded and unzipped OpenCV-2.4.10.exe on my PC. Then created a new Win32 Console application project in VS 2015, set all the Paths in Project properties, set the environmental variables in Win8.1. When I'm trying to start the program in debugging mode I get the "The program can't start because MSVCP120D.dll is missing from your computer. Try reinstalling the program to fix this problem".
Then, I downloaded the Visual C++ redistributable for Visual Studio 2015 But the problem still remains. What should I do to use OpenCV in VS 2015?
OpenCV-2.4.10.exe comes with runtime binary dlls built to work with runtimes from vc10 (vs2010), vc11 (vs2012) and vc12 (vs2013).
These DLL files use MSVCP100.dll, MSVCP110.dll and MSVCP120.dll respectively, and if you have installed Visual Studio 2015 you should find them in your System32 (or SysWOW64) directory.
The MSVCP120D.dll error appears when your application tries to load the DEBUG version of the DLL binaries. You do not have MSVCP120D.dll unless you have Visual Studio 2013 installed on your system. To solve this problem, use the Release runtime instead of the Debug runtime.
All you need to do is exclude the DEBUG lib files from your project. This means including only the lib files without the suffix 'd'. (ie. include opencv_core2410.lib instead of opencv_core2410d.lib)
HTH
Extras:
You don't really need to load the Debug binaries, unless you need to debug openCV's source code. If you do, there's still a way. Download the openCV source code, use CMake to create a VS2015 project. You can then build your own dll binaries using the latest runtime from VS2015.
VS2015 uses vc14 while OpenCV2.4.10 doesn't come with pre-built binaries associated with vc14. This answer should help you to understand. Accordingly you should choose the right folder (vc14) for Linker>General>Additional Library Directories in project properties.
You can use cmake to build binaries using VS2015 or you can download a later version of OpenCV which has prebuilt binaries for vc14.

How to build on TFS a c++ native project targeting Win10 platform

A migrated VS2013 c++ native project to vs2015 targeting Windows 10 (instead of Win 8.1) gives me some issues on the TFS Build Server. I use TFS2013 and the Release12 Build Process Template.
The TFS2013 is installed on a Win10 machine with VS2015 installed on it.
When I run the build the build throws an exception in one of the tasks from the target files saying that it can't compare the numeric number 10.0.4 ... something, because that is the Target Platform set in the native project file. Obviously this is not a number with it's two dots in the version number.
Am I doing something wrong? The TF Build uses MS Build v12 by the way and not the MS Build v14 that ships with VS2015. Do I need to change to MSBuild v14 to make this work? If yes, how can I actually change the used MSBuild version?
Can you provide more information about your exception and build file?
I'm not sure is it realed to MSBuild V14.
If You want to amend the build templates to point to MS Build version 14.0. You can folow below steps :
Use the Default Template (TfvcTemplate.12.xaml) in Visual Studio
Open the template and find the Run MSBuild for Project MSBuild activity.
Set ToolVersion to "14.0".
Set ToolPath to target to MSBuild14 (by default: "C:\Program Files (x86)\MSBuild\14.0\Bin").
Check in this build process template and re-queue the build.
If you still have the same problem after you use MSBuild V14.0.
There is a realted version with 10.0.4... in VS2015. MinimumVisualStudioVersion = 10.0.40219.1 .It means the minimum visual studio version supported in VS2015. Maybe you build a file that created by a visual studio which version is earlier than the version10.0.40219.

Building an OpenCV application with Visual Studio 2008 and running it from another computer

I've made a simple OpenCV application with Visual Studio 2008 and I've built it in both release mode and debug mode.It works fine from my computer but when I try to run it from another computer which doesn't have OpenCV installed or has another version of Visual Studio with OpenCV it doesn't work.
How can I make the app work from a computer which doesn't have either Visual Studio or OpenCV installed ?
I'm thinking to add the external dependencies ( lib's and dll's ) into the app's folder, change the path in Visual Studio and rebuild it.
Thanks in advance and sorry for the ultranoobish question :)
You don't need to distribute the libs; those are just needed for building the executable.
Just copy the dlls somewhere where the executable can see them (either in the same dir as the exe, or in a dir that's on the system path) and you should be golden.
Copying DLL's with the application or to the path is a good start, but may not be enough. It took me a long time to find out why OpenCV application didn't work on another machine. Visual Studio runtime and OpenMP are used by OpenCV. Those are not installed by default and error messages, if any, are not all that helpful.
You need to build OpenCV and your application with setting (in Visual Studio):
Configuration Properties -> C/C++ -> Code Generation -> Runtime Library -> Multi-threaded (/MT)
You need to disable OpenMP support too if that's the problem. Build system changed with OpenCV 2.0. If I remember right, older version had different project files for version without OpenMP.