Qt Creator Debugging Tools for Windows

After a fresh installation of Qt and Visual Studio 2015 I had some problems in configuring developing kits in the Qt Creator application. The main problem was that it could not find any debugger, so here is a small guide where you can save a little bit more time to setup all correctly:

  1. Download and install Microsoft Visual Studio Community 2015
  2. Download and install Qt
  3. Download the full package Windows 10 SDK
  4. After download execute the setup and select only ‘Debugging Tools for Windows’ for installation

Connect Synology Diskstation with Ubuntu Server

Here is a small manual for setting up a connection between an Ubuntu server and a Synology Diskstation. Prerequesites are that you created a shared folder and configured your Diskstation successfully. After that you can start sharing that content to your Ubuntu server.

  1. Open the Diskstation Web Application
  2. Go to “Control Panel – Shared Folder”
  3. Open “NFS-Access”
  4. Create a new one
    Client: *
    Privilegde: Read/Write
    Root squash: default
    Asynchronous: Yes
  5. Write down the mount path from the bottom of this pop-up, in my case it was “/volume1/Backup”
  6. Open a shell on your Ubuntu server
    sudo apt-get install nfs-common
    sudo mkdir /mnt/diskstation
    sudo mkdir /mnt/backup
    sudo mount -t nfs 192.168.0.X:/volume1/Backup /mnt/backup
  7. Congratulations! You just added a Synology Diskstation to your Ubuntu server.

What now? Perhaps you want to sync your data (like I did):

rsync -rvz /mnt/diskstation /mnt/backup
-r ... include subdirectories
-v ... verbose mode, display output
-z ... compress content for lesser network traffic

Qt QML Compile Sources for OpenGL Visual Studio 2015

To build the Qt sources by your own you have to do the following steps:

  1. Download and install Visual Studio 2015. I took the Community edition.
  2. Download and install Qt. I took the Visual Studio 2015 Desktop version.
  3. Download and install Python. It has to be installed to compile QML.
  4. Open the Visual Studio ‘Developer Command Prompt for VS2015’: Windows Start – Visual Studio 2015 – Developer Command Prompt for VS2015
  5. Than run the following command chain
    >> cd "Path/to/the/Qt/source/folder/" (in my case C:\Qt\5.7\Src)
    
    Follow this link to get more information about the configuration parameters. In my case I recompile the source code to use OpenGL.
    
    >> configure -opengl -desktop -platform win32-msvc2015
    
    The supported platform parameter could be found in this directory: 'C:\Qt\5.7\msvc2015_64\mkspecs'. The parameter title is the directory name.
    
    >> nmake
    
    Now lay back and drink a coffee. It will at least last a hour...
  6. For using OpenGL insert the following to your pro file
    QT += qml quick opengl
    LIBS += 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/OpenGL32.Lib' (in my case, just search for the OpenGL32.Lib)
  7. Congratulations! Now you can start with QML and OpenGL!

OpenCV and Universal Windows Platform UWP

To get OpenCV running on Windows 10 via an UWP project you have to do the following steps:

  • Download and install
    latest Microsoft Visual Studio 2015 Community (or an earlier version, must support UWP)
    latest OpenCV (this tutorial with 3.4.1)
    latest CMake (this tutorial with 3.1)
  • Open CMake
    CMakeGUI OpenCV
    I unchecked BUILD_EXAMPLES, BUILD_PERF_TESTS, BUILD_TESTS.
    Press configure and select Visual Studio 2015 x64. After that generate the project by pressing ‘Generate’. (If you plan to compile the ARM Version, only static libraries can be build, simply uncheck BUILD_SHARED_LIBS).
  • Open the user defined CMake project folder and open the created project solution (*.sln) file. Build both – the debug and the release version. This should work without and problems. After I built OpenCV I copied the debug and release dlls in a separate bin folder and the libs also in a separate libs folder. Because of the OpenCV separation with the suffix d for debug both (debug and release) can exist in one directory.
  • Create a new Visual Studio 2015 Project and select ‘Blank App (Universal Windows)’Visual Studio 2015 OpenCV Project
  • Download and modify the paths inside the file with your favorite text editor: Visual Studio User Defined Properties. This separate properties file can be modified very easily and can be shared with other projects too.
  • Add the properties file to your current Visual Studio 2015 project.
    Visual Studio 2015 Property Window
    Visual Studio 2015 Properties
    You can do this again for the Debug | x64 too. Simply right click on the build type and select ‘Add Existing Property Sheet’. Choose the opencv_x64.probs file again. A macro inside the file will switch between debug and release configuration automatically.
  • Here is the content of my MainPage.cpp
    //
    // MainPage.xaml.cpp
    // Implementation of the MainPage class.
    //
    #include “pch.h”
    #include “MainPage.xaml.h”
    #include <opencv2\core.hpp>
    #include <opencv2\imgcodecs.hpp>
    #include <opencv2\imgproc.hpp>
    #include <robuffer.h>
    using namespace CVProj;
    using namespace Platform;
    using namespace Windows::Foundation;
    using namespace Windows::Foundation::Collections;
    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Controls::Primitives;
    using namespace Windows::UI::Xaml::Data;
    using namespace Windows::UI::Xaml::Input;
    using namespace Windows::UI::Xaml::Media;
    using namespace Windows::UI::Xaml::Navigation;
    using namespace Windows::UI::Xaml::Media::Imaging;
    using namespace Windows::Storage::Streams;
    using namespace Microsoft::WRL;
    MainPage::MainPage()
    {
    InitializeComponent();
     cv::Mat input;
    input = cv::imread(“Image file from the ‘Assets’ folder of your project.“);
     cv::Mat img = cv::Mat(input.rows, input.cols, CV_8UC4);
    cv::cvtColor(input, img, CV_BGR2BGRA);
     cv::resize(img, img, cv::Size(640, 480));
     BitmapImage ^bitImg = ref new BitmapImage();
     WriteableBitmap;
    WriteableBitmap^ wbmp = ref new WriteableBitmap(img.cols, img.rows);
    IBuffer^ buffer = wbmp->PixelBuffer;
    unsigned char* dstPixels;
    ComPtr<IBufferByteAccess> pBufferByteAccess;
    ComPtr<IInspectable> pBuffer((IInspectable*)buffer);
    pBuffer.As(&pBufferByteAccess);
    pBufferByteAccess->Buffer(&dstPixels);
    memcpy(dstPixels, img.data, img.step.buf[1] * img.cols * img.rows);
    cvImg->Source = wbmp;
    }
  • Add this entry to your MainPage.xaml file
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Image Name="cvImg"></Image>
    </Grid>
  • Now it should compile without any problems otherwise you do have to check your properties file.
  • You successfully created a Universal Windows Application with OpenCV support!

Update

I added a new menu entry: University. There you can perhaps find some useful helpers and information for your studies.

Gitlab and Apache

Using Gitlab with Apache server isn’t quite difficult to manage but it costs me some time to find the right resources and hints. To avoid this search again, here are some useful steps to get it work.

First of all this is my configuration:

Preparation

  • Download the following configuration files from the Gitlab Apache Server Configuration Files site:gitlab-omnibus-ssl-apache24.conf
    gitlab-omnibus-apache24.confCopy them to /etc/apache2/sites-available and create a system link to /etc/apache2/sites-enabled

    >> ln -s /etc/apache2/sites-available/gitlab-omnibus-ssl-apache24.conf /etc/apache2/sites-enabled/gitlab-omnibus-ssl-apache24.conf
    >> ln -s /etc/apache2/sites-available/gitlab-omnibus-apache24.conf /etc/apache2/sites-enabled/gitlab-omnibus-apache24.conf
  • Install missing mod and enable dependencies for Apache (listed in the *.conf files)
    >> apt-get install libapache2-mod-proxy-html
    >> a2enmod rewrite
    >> a2enmod ssl
    >> a2enmod proxy
    >> a2enmod proxy_http
    >> a2enmod headers

Configuration

  • Add new domain to your /etc/hosts configuration
    /etc/hosts
    ...
    123.123.123.123 gitlab.yourdomain.com
  • If you do have a static IP, configure your DNS on your domain hoster website for correct redirection
  • Change in the configuration files (*.conf) the YOUR_SERVER_FQDN entries to your domain name, e.g. gitlab.yourdomain.com
  • For the Gitlab configuration follow these steps:
    /etc/gitlab/gitlab.rb
    add
    gitlab_workhorse['listen_network'] = "tcp"
    gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
    
    set
    nginx['enable'] = false
    ...
    web_server['external_users'] = ['www-data']
    
    >> gitlab-ctl reconfigure
  • Restart Apache server
    >> service apache2 restart | systemctl status apache2.service

Hint

If you are using Letsencrypt for SSL then change the following lines in the gitlab-omnibus-ssl-apache24.conf file

/etc/apache2/sites-available/gitlab-omnibus-ssl-apache24.conf
...
SSLEngine on
#strong encryption ciphers only
#see ciphers(1) http://www.openssl.org/docs/apps/ciphers.html
#SSLProtocol all -SSLv2
#SSLHonorCipherOrder on
#SSLCipherSuite "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS"
#Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
#SSLCompression Off
SSLCertificateFile /etc/letsencrypt/live/gitlab.yourdomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/gitlab.yourdomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
#SSLCACertificateFile /etc/httpd/ssl.crt/your-ca.crt
...

Free HTTPS Certificate from Let’s Encrypt

If you want to secure the connection of your server with a valid and free certificate – that also modern browser will recognise – you should go to this website and follow the instructions there. Currently big companies like Akamai, Cisco, Mozilla and Facebook are supporting Let’s Encrypt so I guess there is no argument not encrypting the communication to your server. Additional this tool configures your existing Apache server so that your HTTPS connection is set up in less than 5 minutes.

Here is the link: https://letsencrypt.readthedocs.org

After that you can test your website on security issues: https://www.ssllabs.com/ssltest/analyze.html

Hint: non www to www
Now if you have a certificate for your www.domain.com and you want to redirect domain.com to www.domain.com you have to add the following commands to your default-ssl.conf located in /etc/apache2/sites-available directory:

<VirtualHost *:443>
...
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^localservername -->used for local access
RewriteCond %{HTTP_HOST} !^www\. -->check if www is missing
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 [R=301,L] -->add www.
</VirtualHost>

Your default.conf located in /etc/apache2/sites-available should be modified as shown below:

<VirtualHost *:80>
	...
	# redirect all http queries to https
	Redirect permanent / https://www.domain.com 
</VirtualHost>
or
<VirtualHost *:80>
  RewriteEngine On
  RewriteCond %{SERVER_PORT} ^80$
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</VirtualHost>