Theme and Icons Problem with GTK3 Installed with vcpkg - c++

I am using Visual Studio 2019 on Windows 10 and am trying to use GTK in C++ and installed it using vcpkg.
I've installed GTK using vcpkg according to the guide from GTK. I'm using Visual Studio 2019 and it is able to compile and run the example program here, but there is an issue regarding the theme and icons. According to the installation guide, under the section Building and distributing your application there are some things that must be done to get themes and icons to work.
I've started by downloading the Windows theme the guide suggests and have it in a share directory and then I've created a settings.ini file in an etc directory. It says to place this in the "install directory", which I assume is where Visual Studio is placing the exe for the program. I've tried it in both build and release, in the source files, in the top project directory - all with no success (and I did make sure it is targeting x64).
Just in case I also tried placing these where vcpkg is installed as well as where vcpkg installs gtk. No luck. When the program runs I get the warning
(gtkExample0.exe:16772): Gtk-WARNING **: Could not find the icon 'window-minimize-symbolic-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases
So it seems that it is never finding the ssettings.ini file telling it to use the Windows 10 theme. Has anyone had any luck with getting this to work (both from VS2019 debugging runs and in deployment)?
To summarize the files:
share\themes\Windows10\gtk-3.0\gtk-3.20\ (downloaded from suggested GitHub repo)
etc\settings.ini contains:
[Settings]
gtk-theme-name=Windows10
gtk-font-name=Segoe UI 9
I've placed these in
<VS2019Project>\x64\Release,
<VS2019Project>\x64\Debug,
C:<path_to_vcpkg>\vcpkg\packages\gtk_x64-windows,
C:<path_to_vcpkg>\vcpkg\installed\x64-windows
All with no change when running from VS2019 under Release or Debug.

Theme and icons considered as external resources are not distributed by vcpkg, and the instructions given in the distribution guide from GTK regarding where these resources should be layout on windows 10 are not crystal clear. The problem has also been reported here vcpkg issue#4417.
The solution proposed hereunder is to install
all the resources in the <VS2019Project>\x64\Release directory of your VS project where your .exe application lives [This is a local solution the problem. A global approach should consider the setting of some user-defined free desktop environment variables which is not discussed here]. Icons can be picked from an ancillary MSYS2 distribution and the theme as indicated in the GTK Guide. The solution should be replicated for the Debug branch.
Supposing you have MSYS2, install mingw-w64-x86_64-adwaita-icon-theme package with the pacman package manager if not already done on your MSYS2 installation pacman -Syu mingw-w64-x86_64-adwaita-icon-theme.
Copy C:\msys64\mingw64\share\icons to <VS2019Project>\x64\Release\share\icons
you should get both hicolor and Adwaita icons as subdirectories of your target dir.
Copy the theme resources downloaded in the source gtk-3.20 directory directly into <VS2019Project>\x64\Release\share\themes\Windows10\gtk-3.0\. Do not locate these resources into a gtk-3.20 subfolder: to understand why consult this article Theme Location [assuming here that no global desktop environment variable has been set].
Create a <VS2019Project>\x64\Release\etc\gtk-3.0 directory, put your settings.ini into it.
Recompile and you should obtain a windows 10 look and feel for your application window.

Related

Building wxWidgets Hello world

The wxWidgets hello world example does not provide sufficient information to build wxWidgets in any one particular environment.
The Code::Blocks wxWidgets hello world example does provide sufficient information, but it does not seem likely that a newbie, or even a quite sophisticated user, could figure out all the necessary steps on their own, because there are arcane magic words required.
The Code Yarns example uses CMake, thus could run in many particular environments, but seems to assume that you have already set up wxWidgets and compiled it for your particular environment, and there does not seem to be a CMakeLists.txt file to compile wxWidgets for your particular environment.
wxWidgets is supposed to be cross platform and cross environment, and I am trying to set up a project to compile in several environments: on Windows10 Visual Studio, Windows 10 TDM-GCC, Windows 10 Code::Blocks, Ubuntu Code::Blocks, and Ubuntu 10 gcc.
And apart from the Code::Blocks environments, having trouble. Apart from Code::Blocks, I cannot find "Hello World" examples that actually set up wxWidgets on the target so that the Hello World will actually compile and run.
The wxWidgets samples directory is not particularly useful, since the samples assume an environment, and do not describe setting up that environment and the actions that will cause the sample to build and run.
Installation guide
I know this is a old question but I struggled really hard to find a guide for an installation on wxwidgets. You can use the vckpg importer by Microsoft. Make sure you have git installed before you follow this routine. I will write this for Windows with Visual Studio 2017:
Clone the following repository to a directory of your choice:
git clone https://www.github.com/Microsoft/vcpkg
Then open up powershell (ps) (run it as admin) and navigate to the cloned vcpkg folder
Now in ps, while you are in the vcpkg folder run the following command \.vcpkg integrate install so we have a user-wide integration of the vcpkg paket manager and can #include libraries in our c++ projects
Now to install wxwidgets 32-Bit run \.vcpkg install wxwidgets --triplet x86-windows. For the 64-Bit Version run \.vcpkg install wxwidgets --triplet x64-windows
Now open up the properties of your project in Visual Studio.
For the integration of the 64-Bit wxwidgets version choose all configurations and as plattform x64. Then go to C/C++ -> General -> Additional Include Directories and add the following folderpath YOUR_FOLDER_PATH\vcpkg\packages\wxwidgets_x64-windows\include;YOUR_FOLDER_PATH\vcpkg\packages\wxwidgets_x64-windows\lib. Do the same for the x86 configuration but with the wxwidgets_x86-windows folderpath instead.
As a last step go to in the properties under C/C++ -> Preprocessor and under the point Preprocessordefinition add the following as extra point WXUSINGDLL=1 (do it for the x64 and for the x86 plattform configuration if you want to use both)
Now you should be able to use the library and run the hello world project.
To build an app, first you need to have the library compiled. To achieve that you can get precompiled binaries or the sources (see Downloads) and compile them yourself (see Building).
Instructions might still not be perfect for everyone, and you are welcome to improve them - even call it your first contribution ;)
The installation instructions that I was looking for are to be found in wxWidgets/docs/install.txt
There are multiple ways to setup wxWidgets on Windows and use it in a project.
If your project is going to use CMake there are 2 main options (other than compiling stuff yourself some other way):
Use vcpkg - which, in theory, is the easiest, but I couldn't get it to work (in time). Here is some info on that: https://www.wxwidgets.org/blog/2019/01/wxwidgets-and-vcpkg/
The problem is find_package couldn't find the package, so then I just went to 2:
Download the lastest compiled headers, libs & bins from the wxwidgets and put them in a folder like c:/wxwidgets. Then, in your Cmake file, before the call to find_package, do:
SET(wxWidgets_ROOT_DIR "c:/wxwidgets/")
SET(wxWidgets_LIB_DIR "c:/wxwidgets/lib/vc14x_x64_dll")
SET(wxWidgets_CONFIGURATION "mswd")
The LIB_DIR is using VS2019 x64 in my case.
mswd just means build this for Debug
Finally, when adding the executable, do not forget the WIn32:
add_executable(membot WIN32 ${project_SRCS})
P.S.: Remember to extract the headers include folder near the lib.

VS 2017 Setup Project wouldn't install in C:\DestFolder\

Due to the administrative privilege of the application, I need to install my program including .exe and .dll in C:\DestFolder\SubFolder\ but I keep getting C:\Program Files\\[Manufacturer]\\[Product Name]\ where the placeholders are specified in the properties window.
I tried this article but no good.
Please don't give me answer like try changing the defaultlocation to C:\Destination\ of the Application Folder as I have already tried. Also I don't want solution like just change the installation destination path manually during the installation.
I have found the answer from this article:
"[ProgramFilesFolder] is built in, and correctly leads to the Program Files directory on the target machine, no matter how customized the setup of Window is..."
There might be tools out there that allow installing outside of Program Files.
[Edit] Infact I've found out this great extension for VS 2017 community called Wix. There's a guy who did a fabulous tutorial on it.

What must be installed on client machine to run a QT Quick Application?

I am developing a desktop application using QT Quick. I have been searching and reading the QT documentation (http://doc.qt.io/qtinstallerframework/ifw-tutorial.html) for creating an installer and how to use windeployqt.exe and binarycreator.exe to deploy on a windows machine. So far so good , but since I want to target this application for windows XP as well.
I want to know exactly what is required to be installed on the target machine to be able to run my application when using MinGW orMSVC2015 during building, so that I may include them in my installer or make the end user download them. Just like we download .Net Framework , Visual C++ Redistributable or DirectX when installing an application.
We use windeployqt to gather all the Qt official dependencis. Two parameters of windeployqt are quite useful:
--debug or --release: determine whether your app is in debug state or release state. windeployqt will put corresponding version of DLLs to your exe's directory;
--qml and put the directory of your QML files after it. windeployqt will search your given directory and put all the QML modules to your exe's directory.
2018-11-05 10:52:34:
It seems the second parameter --qml has been changed to --qmldir.

OpenCV 3.0 include tracker

I want to use a tracker, described on the OpenCV 3.0 documentation site. In OpenCV 2.x, it was necessary to recompile OpenCV including the contrib library. But as it is in the OpenCV 3 documentation, I guess that I do not have to recompile it anymore, right? But what do I have to #include in C++?
I'm trying to do this for quit a while and do not find any solution. Thank you!
EDIT
Thank you! The recompiling-process worked for me without any errors. I got still several errors: He does not find 'opencv_highgui300d.dll', 'opencv_imgcodecs300d.dll'and 'opencv_core300d.dll'.
I fixed this, because I had to change the 'Path' system variable to
...\cmake-output\vc12\x86\install\x86\vc12\bin
As far as I know the tracking module is still in the "contrib" module.
You have to re-compile OpenCV 3.0 using the contrib section that you may download from this github repo. When you compile OpenCV using CMake you have to specify the OPENCV_EXTRA_MODULES_PATH atribute as being the location where you have extracted the module.
If you have any issues, just let me know :)
[EDIT]
Download OpenCV from here and OpenCV_Contrib module from here. Unzip them and place them in the same directory (I have put mine in D:/OPENCV-BUILD)/
Open CMake and set the source code path to D:/OPENCV-BUILD/opencv-master
Set the "Where to build the binaries" path to D:/OPENCV-BUILD/cmake-output/vc12/x86. Here, vc12 is the platform toolset used by VS2013 and x86 is the platform target (you may build it for x64 also)
Press the configure button and select your generator (a.k.a the compiler you'd like to use). Select Visual Studio 12 2013 (for x86 build) or Visual Studio 12 2013 Win64 (for x64 build).
Wait until it's done configuring. A bunch of red lines will appear, dont't worry it's all good :)
Search for the following lines and uncheck them:
WITH_CUDA -> this will disable support for GPU accelerated algorithms using CUDA technology. You can build the library with CUDA support also, but it's a bit more complicated and it takes much longer. If you don't need it, un-check it :)
BUILD_DOCS, BUILD_PERF_TESTS, BUILD_TESTS. These are just some tests of the modules of the library (that I have never ever used)... Again, if you don't need them, un-check them :)
Everything related to Matlab (if you have these options). I have Matlab installed and CMake wanted to create some Matlab bindings for OpenCV. I had some issues at compiling the library with these options, so I deleted them (see the image below)
Search for "extra" and in the OPENCV_EXTRA_MODULES_PATH set the path to your "modules" folder from the contrib module (mine is D:/OPENCV-BUILD/opencv_contrib-master/modules)
Now click again on the "Configure" button. Wait until it says "Configuring done", and after that press on the "Generate" button. We're done with CMake!
In the output folder you have selected (D:\OPENCV-BUILD\cmake-output\vc12\x86) you'll find OpenCV.sln. Open it using VS2013.
In Visual Studio, select the configuration you'd like to build (I recommend you to build both for Debug and Release). Let's say you select 'Debug' first. Now right click on the solution and select "Build Solution". Wait until it's done.
In the 'CMakeTargets' folder you'll find a project named INSTALL. Right click on it and select 'Project Only -> Build Only INSTALL'). This creates a new folder named install and copies the result of the build there (libs, dlls, include files, etc.).
Repeat steps 10 and 11 for the 'Release' configuration.
After these steps, you'll have the files you need in your install folder (mine is D:\OPENCV-BUILD\cmake-output\vc12\x86\install)
The following link points to a very clear and nice explanation of how to install OpenCV properly and not have any problems with compilation and provided libraries.
This is the proper way to get a clean installation on Windows 7:
https://coderwall.com/p/wgaiwa/setup-opencv-with-vs2012-on-win7-64bit?p=1&q=author%3AVentsy
Hope it helps

Qt5 Application Does Not Run

I created an application using Qt 5 (compiled with Visual Studio '12). It works on my machine.
However, it doesn't work when I attempt to run it on another machine. The output I collected through cmd yielded an empty file.
The directory structure is as follows:
myapp.exe
icudt52.dll
icuin52.dll
icuuc52.dll
libEGL.dll
libGLESv2.dll
msvcp120.dll
msvcr120.dll
Qt5Core.dll
Qt5Gui.dll
platforms/qminimal.dll
platforms/qwindows.dll
The most relevant post I found was Application deployed with QT5 libraries does not start on Windows 7 - yet the solution (including qwindows.dll & qminimal.dll) didn't work.
Any ideas?
Windows will report a number of launch errors just when you double click on your exe outside Qt Creator. It looks like you have included most or all of these already.
Your development machine typically will not have problems launching and running its qt plugins because of the LibraryPaths that are searched by your exe. http://qt-project.org/doc/qt-5/qcoreapplication.html#libraryPaths
Dependency Walker will do the job and show you what you need to know, but the output is pretty complex and can be hard to decipher.
The easiest way I have found to figure out what Qt plugin dlls I am using at runtime on Windows is to do the following:
Exit Qt Creator.
Open the install folder for the compiler you are using with Qt in Explorer. For example:
C:/Qt/5.3/msvc2010_opengl/
Create a copy of the plugins folder in place (Copy of plugins folder in the same path as plugins, so its parent is msvc2010_opengl in this case).
In another explorer window, open your exe (Qt program) on your development machine. Run a minimal test of your program to make sure the major features are working. (Many runtime plugins don't get loaded until QObjects that use them are instantiated).
Delete the plugins folder in the Qt path.
Windows will lock up all the dlls that are in use by your exe and prevent you from deleting a number of dlls. Click skip for all the un-deletable folders and files.
Now go into each of the folders that you couldn't delete before and try to delete all the individual dll's in each folder. Click skip for all the un-deletable dlls.
Now when you are all done, you are left with a skeleton of a plugins folder, only showing dlls that your application is using.
It will probably include the folders: accessibility, platforms and imageformats and more depending on what you included in your .pro file.
Close your exe.
Copy the contents of your stripped down plugins folder to sit right next to your exe.
Restore your backup of the plugins folder (delete the stripped down plugins folder from your Qt path and restore the Copy of plugins).
Now you should be good to go. Test on a non-development machine.
A Note on VS C++ Runtimes
Also on some machines when deploying Qt with MSVC, the msvcrXXX.dll doesn't match what the rest of the system is using. Instead of deploying msvcrXXX.dll, instead in our installers at our office, we include the Microsoft C++ Redistributable Installer and run it in the install script. And on a few machines they had corrupted Redistributables, and we had to do a force install of redistributables to fix the `Referral from server' error we would sometimes get.
You can find the latest installer for MSVC Redistributables here Latest Supported Visual C++ Downloads.
Hope that helps.
You have to deploy your application before copying dll files manually.
To deploy your Qt application on Windows you can use windeployqt which can be found in:
< QTDIR >/bin/windeployqt
Example batch script may work on deploying your Qt Application (run with PowerShell or cmd):
C:\Qt\Qt5.x.x\5.x.x\MSVCx_x\bin\windeployqt <APP_PATH>/myapp.exe
After deploying your app, try to run your myapp.exe and note which dll files are missing.
Copy / paste required dll files from QTDIR/bin to your < APP_PATH >
for more information about deploying:
Windows Deploying Tool - windeployqt
Deploying on Windows