Configure kit for Qt automatically - c++

SO!
Let's say I have a number of settings (GCC compiler 9.3.0 built from source, as the distribution I have to use has a very old one, along with environment setup) for a new Kit in QtCreator.
I have managed to setup an environment for compilation and execution of compiled binaries, and made a script to make it work (like qmake -nocache -recursive/make/sudo make install, direct execution of g++, and other stuff).
One thing that script can't do at the moment, is that it cannot create a kit for QtCreator with new compilers and environment being set as required, so after running a script, its user has to go through setting it up himself through GUI, which is bad, because this can cause misconfiguration.
This thing I'm trying to create is going to be used by around ~200 people in my company, so leaving readme.txt with instructions just doesn't go well enough for me - I don't want running around fixing missing "{" and "}" in Environment description in created Kits, and other stuff.
Are there ways to create Kits for QtCreator automatically from command line? Maybe, there's some files to edit?

I've looked into this one a few years back (I wanted to do something similar for registering Buildroot toolchains automatically in QtCreator), and I was unable to find an off the shelf solution. So i think there are 2 ways to implement this:
a) Implementing a command line utility the manipulate the ~/.config/QtProject/qtcreator/{toolchains,profiles}.xml files. Maybe by (re)using the existing C++ implementation within QtCreator, or just re-implement it ie. in Python. Back than I didn't start to work on this as there was no real business need.
b) Switching to qbs, as qbs has support for setting up toolchains from the command line ( see: https://doc.qt.io/qbs/cli-setup-toolchains.html)
If you decide to go with solution a), please let me know and maybe we can partner up to implement it.

Check out the command line sdktool bundled with QtCreator:
The SDK tool can be used to set up Qt versions, tool chains, devices
and kits in Qt Creator.
There still is a lot of knowledge about Qt Creator internals required
to use this tool!
I haven't tried it yet, but I did find the executable under Tools/QtCreator/libexec/qtcreator subdirectory of the Qt Creator installation directory. ./sdktool --help works for me under Linux.

Related

Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update configuration settings

I just want to be able to compile/run my OpenGL C++ projects on my local machine.
Do I need "nRF Connect" if I'm only pursuing local projects?
I have VS Code installed running version 1.71.0 (user setup) on Windows_NT x64 10.0.22000
I am using the mingw64 compiler located in C:\msys64\mingw64\bin\g++.exe
My active kit is GCC 12.1.0 x86_64-w64-mingw64 that is displayed on the bottom faceted pane in the window
I have my "CMakeList.txt" generated with the corresponding "main.cpp" file using the "CMake: Quick start" tool
When I run the "CMake: Build" tool, I get the error "Unable to determine what CMake generator to use". Therefor my CMake "build" directory is never created in my $(workspace)
I have tried running the "CMake: Reset" tool and I don't think that is the problem right now. In my "settings.json" file at the bottom, I see "nrf-connect.toolchain.path: " setting is set to the value "PATH". I think that is one of the issues but don't know what value to change it too. Also my environment variable "Cmake: Configure Environment" located in settings->Extensions->CMake Tools is empty for my key/value pair, also don't know what to add to that as well. I've been combing the internet for weeks so I can articulate my problem to you guys which as much of it solved before I brought the issue here. I was able to compile/run my C++ projects on VS code with no issue prior to installing CMake but am trying to build projects with OpenGL. And from what I seen CMake is one of the options that is required when it comes to building OpenGL projects.
Don't send me some documentation as a solution because I tried it and that is why I'm here. It blows my mind that there isn't a step by step on how to integrate CMake with OpenGL in VS code. The tutorials I've seen, they skip a lot of crucial steps which is the dumbest thing I have ever seen and it leaves us pulling our hair out.
CMake: Configure Environment setting

cmake of minimal_build under Centos7

I'm trying to compile the examples under cpp starting with minimal_build. I don't have much cmake experience. Must this be run under docker, or can it just be compiled in a Linux shell? I'm running Centos7 on a AWS EC2 instance, and I've installed cmake 3.20.2. Executing sudo ./run.sh, errors immediately with "cd: /io: No such file or directory". When I try and make what I think are the necessary changes to the scripts, I keep hitting errors. So I just want to see is this is even possible before proceeding further.
Thanks.
Yes, it is possible. I recently built Arrow on CentOS 7. With any C++ project there are going to be challenges switching amongst Linux distributions. The docker image is a way to provide a single example that the Arrow project can verify. You will need to adapt your Linux environment based on the issues you encounter. #Tsyvarev is also correct, you will want to use run_static.sh instead of run.sh. In order to do this you will need to dive a bit further into the details.
The build script has two steps. First, it will build the Arrow project itself. This is probably going to be the more challenging step. This guide is helpful for this step and provides a lot more detail into how Arrow builds and what options there are. The second step will be to compile and build the example.
Specifically for CentOS 7 one of the challenges you will face is that you will need a newer version of CMake. I ended up building CMake from source. If you go this route you also need to make sure that CMake is built with curl/https support. I used the --system-curl option for this.
That is all I remember having to do special for CentOS 7 at the moment. As you go about this task if you run into further, more specific, issues, feel free to ask them here or on the Arrow dev/user mailing list.

VSCode c++ configuring for vc toolchain

I'm trying to start a work in vscode , latest C++ plugin version supports ms debugger, so as I'm mostly working under windows it was a signal to try this.
c++ tools plugin from MS and cmake tools were installed.
my test project was however not built . the problem is clear , but I need an advice from experienced vscode users how to solve this right.
cmake doesn't see vc compiler.
(after using QtCreator) I expected that vscode could detect vc installation... however that's not so. ok, I have a two ways:
fill environment variables INCLUDE/LIB/PATH with a headers, libs and binaries
just run vcvarsall.bat x64
Second way is a simple and reliable. so final question is:
how to run .bat at the begining of vscode start?
(I don't mean write another bat/cmd, prepare the environment and run vscode inside the same script after that)
Although the question is fairly old, I'll try to give a useful answer, in case others stumble across, just like I did.
I believe what you are trying to achieve is not possible. Code inherits the environment it was started with. If you did not launch it from a developer command prompt, you will not be able build and debug. (Building might be possible if every task first starts the vcvarsall.bat, but that slows things down by a lot. Debugging I think will still not work.)
If you are willing to, you can check out vector-of-bools CMake Tools extension which does build automation as well as automatic MSVC detection. It builds using CMake (thus you need to write your build scripts using CMake), but it will take care of building just by pressing F7, like what most VS users are familiar with.

How to make Qt4 work using Code::Blocks in Linux Mint

I'm trying to use Qt4 using the Code::Blocks IDE. I'm running Linux Mint and I'm getting some errors. I looked around and found some people that had the same problem as me, but I can't seem to get their solutions working on my computer.
I installed Qt4 using the command
sudo apt-get install qt4-dev-tools
And when I type whereis qt4, I get qt4: /usr/lib/qt4 /usr/include/qt4 /usr/share/qt4
If I select "Create new Projet" in Code::Blocks and Select Qt4 project, it asks for Qt's location, which is $(#qt4) by default. If I click next, it says Code::Blocks doesn't know the "qt4" variable and gives me a prompt to set the base location, the include directory, etc.
Since I don't have any idea as to what I should be putting in there since nothing works (either it says "QTCore cannot be found in the specified directory", or the "lib" directory couldn't be found, etc.).
I tried what was posted on this forum: http://crunchbang.org/forums/viewtopic.php?id=18210, but it didn't solve my problem and I get the same errors.
In the "/usr/share/qt4" directory, there's a link to the "include" directory, but not to the "lib" directory.
I'm pretty new to Linux and all of this, so I'd like it if the answer was very detailed explaining what I did wrong / what I have to do.
Install the QtSDK
As a first step I would advise you to download directly the QtSDK, from the project site here.
Note: You could also use the precompiled version for your Mint version,
but in my personal experience, when working with external SDK,
you have more independence in development, it also allows you to work
freely with multiple versions of Qt simultaneously without move any
dependence of your OS.
You can follow the graphics steps to install the SDK, I advise you to check the option "download source", later this is going to be used for debugging code, and if necessary will allow the recompilation of some classes.
Now your QtSDK is installed on the folder eg "/usr/local"
So, all references inside your IDE should refer to this location.
Install the C::B
You can use the version available in "Software Manager"
Configure the C::B
When we start a new project and asks the location of our SDK we indicate this directory /usr/local/QtSDK/Desktop/Qt/4.8.1/gcc
Now the project is ready!
Note: "/usr/local" and "4.8.1" are variables depending on where
and what version you have installed.
Is very likely that your build directory, is not correctly assigned in "Settings->Compiler and Debugger->Toolchain ...->Compiler's Directory"
will be the default "usr" which should be replaced by "/usr/bin"
Now, when compiling with the standard project ".pro" and if your project has the requirement to use a "moc" tool strategy, the simplest way to do that, is use a customized Makefile, with all stages of compilation.
To learn how to make a customized makefile, you can read this answer.
And although I would advise again:
Although that CB is an optimal environment for working with wxWidgets, and C/C++ in general, I personally think that in the case of working with Qt, QtCreator provides a development environment more native and optimized to work with your projects QT.

how to create installer file

I am currectly finishing my project in C++ and i'm looking for a way to create my own C++ installer file
which will create the project dll's and exe files into a specific path
what is the easier way to learn how to do it?
There are several ways to build an installer. While you can of course always make one yourself, you should google for something like "create an installer". Some prebuilt solutions include "InstallShield", or the ".msi" file format, which you can create on your own using something like "Advanced Installer".
Of course, if you want your users to build your project from source, then you need a makefile and to make sure you bundle all the libraries. There are also kits like autotools to do that for you.
If you use VS 2010, Installshield LE would suffice as it is integrated into VS 2010.
If you have access to Installshield IDE, there is nothing better available for your packaging needs.
There are two ways of packaging:
a) The LEGACY way
b) The Windows Installer way, Basic MSI is the keyword here.
The LEGACY way involves creating your own scripts for:
a) Installing the files to their locations
b) Writing registry entries, if needed
c) Registering COM components, if needed
d) Creating shortcuts etc...
Tools that can be used for LEGACY approach are:
a) NSIS - very good and has a scripting language of its own.
b) Installshield - has a project type called Installscript Project. Installscript is the scripting language to be used.
The Windows Installer way is a bit hard comapred to the LEGACY way.
One has to learn the basics of MSI technology which can be daunting.
The package created has .msi as extension. This file is a database that the developer configures and the Windows Installer takes care of all other things. This is called TRANSACTIONAL installation procedure.
Even the UI presented during install is configured in the Database using tables like Dialog, Controls etc...
Tools that can be used for Windows Installer approach are:
a) Installshield - has a project type called Basic MSI
b) Wix - Opensource and xml based. You configure appropriately named xml files and various utilities in the Wix package will help you to create an MSI package.
First after completing your project click save. Second click on file tab,Add,New Project.
In new Project Click other Project types , Setup and Deployment and in that You can click InstallShield LE or Visual Studio Installer.
Hope this Helped you
I always recommend NSIS. You might also investigate HM Nis Edit - it's an IDE for NSIS that has a useful wizard feature. It will generate an installer script for you which you can further customize. The documentation is extensive.
can't believe no one mentioned install creator pro(there is also a free version with a branded message that displays after installing). Its feature set is pretty limited, though it has options for writing registry values and specifying custom paths to %AppData% or any other place you may want to install some files. it also has an optional wizard interface, and with each step you have the oppurtunity to preview each individual page.
the paid version offers the option for adding serial number/registration to your program. i've never tried it so i'm not sure how effective it may be. its also quite and expensive little program, but i would recommend it atleast to the beginner or someone who is more concerned with maintaining the codebase of their program and less concerned with how fancy and decorated their installer program is.
i know its been a long time since this was posted but for future reference this program is far easier for any beginner to creating installation packages for the first time