Adding MSVC 2017 to Qt - c++

I want to add the MSVC 2017 compiler correctly inside my Qt 5.13, I know where to add it! But, don't know : "How to? What is required to be filled inside the add compiler's menu?"
I have tried too many things. I have a long long story with Qt's main problem!
My main problem is : "module machine type 'x64' conflicts with target machine 'x86'" which appears in the console when I build the Qt application!
I am going to include some of the things that I have tried :
Tried to build from the Qt app and the Console.
Tried all the compilers that are auto-detected from Qt.
There are more, but no need to mention the rest.
On my default kits, Most of the names were in this order : "Qt 5.13.0 for UWP 64/86-bits (MSVC 2017)".
I thought that it must be MSVC 2017, so I tried to setup MSVC 2017 (I have MSVC 2019). I found the compiler's main program which is : "cl.exe". I went to Qt auto-detected compilers, I did not find it! I tried to add it by copying the commands for qmake.exe and jom.exe from another kits that already made for me.
However, I put the compiler's type 'custom', because I did not find MSVC. Is that wrong, and what does that differ from the other types?
My next thing to fix (actually try) is this :
The picture above contains the compiler's path and Make's path.
I need to find the Make path tool, I think it is required, isn't it?
I tried to run the program without Make step, ONLY qmake step. Which led me into another problem when running the program : "An Error has Occured when trying to Build/Deploy your program".
I filled the compiler's path correctly, but I don't know how to fill the make path, I don't even know what is make path.
Note that Qt is not giving me any result because the make path is not filled correctly!
I hope that everything is described and all the information that you need is already included in the story above!

You cannot add MSVC manually to Qt Creator. You do need to have it auto-detected.
Also the mechanisms of detection changes depending on MSVC version and Qt Creator version. So be sure to use the latest version of Qt Creator (4.9.2 at this time) to make sure all your installed MSVC toolchain are detected.
Also given you comment you seem to confuse 64-bit and 32-bit.
x86 means 32-bit and amd64 means 64-bit.
This gives:
x86 32-bit compiler that produces 32-bit exe
x86_amd64 32-bit compiler that produces 64-bit exe
amd64 64-bit compiler that produces 64-bit exe
amd_x86 64-bit compiler that produces 32-bit exe
So if you wan to produce 32-bit programs, you can use x86 or amd64_x86. If you want to produce 64-bit programs, you can use amd64 or x86_amd64.
If at some point you want to compile a Qt porgam, but Qt Creator does not recognize your MSVC toolchain, you still have a solution:
Open Qt 5.12.4 (MSVC 2017 64-bit) from the start menu
In the prompt run C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64
Run qmake and enjoy

You can't manually add MSVC to Qt Creator. If you want to use it make sure to have the correct Visual Studio version installed.
I suggest reinstalling Visual Studio if the MSVC compiler don't appear in the Compilers tab.

Related

Is it possible to use Visual Studio to compile and debug with GCC? [duplicate]

I am creating a very large project (a few thousand lines) and so would rather not use Notepad++. An IDE would make it so much easier. I have experience with Microsoft Visual Studio and love it. Is there some easy way to use Cygwin's GCC from within Microsoft Visual Studio?
Alternately, are there any other good Windows IDEs for GCC besides NetBeans and Eclipse? (I hate both of them with a passion.)
There are several ways to go here:
Option 1: Create a Custom Build Tool
Visual Studio 2005 and newer will let you register custom build tools. They tell the IDE how to transform files of one form (e.g. a .cpp file) into another form (e.g. an .obj file).
So far as I know, no one has done this yet for GCC. And, doing it yourself requires writing COM code, which is probably too deep a pool to dive into just for a single project. You'd have to have a compelling reason to take this project on.
You then have to manually adjust each project to tell it to use the custom build tool instead of the default, since you're using a file name extension (.cpp, probably) that Visual C++ already knows about. You'll run into trouble if you try to mix the VC++ and g++ compilers for a single executable built from multiple modules.
On the plus side, if you were looking to start an open source project, this sounds like a good one to me. I expect you'd quickly gather a big user base.
Option 2: Makefile Project
Start Visual Studio and say File > New Project.
In the Visual C++ section, select Makefile Project
Fill out the Makefile Project Wizard:
Build command line: make
Clean commands: make clean
Rebuild command line: make clean all
You can leave the Output (for debugging) field alone if you've named your executable after the project name and it lands where Visual Studio expects to find it.
Leave the rest of the fields alone unless you know what they are and why you want to change them. As an example, you might choose to pass a -D flag on the Preprocessor definitions line to get separate debug and release outputs. If you know you want this, you know how to set it up, so I'm not going to make this long answer even longer in order to explain it.
You'll be asked the same set of questions for the Release build. If you want to bother with separate debug and release builds, you'd make any changes here.
Having done all this, you still have to create the Makefile, and add a make.exe to your PATH. As with the debug vs. release question, going into that level of detail would push this answer off topic.
As ugly as this looks, it's still easier than creating custom build tools. Plus, you say you need to port to Unix eventually, so you're going to need that Makefile anyway.
Option 3: Cross-Platform Development
You say you want to port this program to Unix at some point, but that doesn't mean you must use GCC on Windows now. It is quite possible to write your program so that it builds under Visual C++ on Windows and GCC/Makefiles on *ix systems.
There are several tools that make this easier. One very popular option is CMake, which is available as an installation time option in newer versions of Visual Studio. There are many alternatives such as SCons and Bakefile.
Clang
You can use the Clang compiler with Visual Studio to target Android, iOS, and Windows.
If you are targeting Android, you can use the Clang/LLVM compiler that ships with the Android NDK and toolchain to build your project. Likewise, Visual Studio can use Clang running on a Mac to build projects targeting iOS. Support for Android and iOS is included in the “Mobile Development with C++” workload. For more information about targeting Android or iOS check out our posts tagged with the keywords “Android” and “iOS”.
If you are targeting Windows, you have a few options:
Use Clang/LLVM; “Clang for Windows” includes instructions to install Clang/LLVM as a platform toolset in Visual Studio.
Use Clang to target Windows with Clang/C2 (Clang frontend with Microsoft Code Generation).
GCC
If your project targets Linux or Android, you can consider using GCC. Visual Studio’s C++ Android development natively supports building your projects with the GCC that ships with the Android NDK, just like it does for Clang. You can also target Linux – either remotely or locally with the Windows Subsystem for Linux – with GCC.
Check out our post on Visual C++ for Linux Development for much more info about how to use Visual Studio to target Linux with GCC. If you are specifically interested in targeting WSL locally, check out Targeting WSL from Visual Studio.
Source: https://devblogs.microsoft.com/cppblog/use-any-c-compiler-with-visual-studio/
I'm from the future.
I keep (poking at) a C/C++ toolchain using Visual Code on Win/Lin/Mac and MinGW installed from Choclatey.
(This was done for my sanity - install GDB and GCC however you want)
I've run it with GCC and GDB with IntelliSense using MS's own weird JSON makefiles.
Someday, someone (you?) will write a Gradle or Python script to generate these; for now the examples online in the docs seem to work.
It seems to require three types of JSON thing;
a single IntelliSense configuration for the whole workspace
a Debugging Configuration entry for each binary you want to debug
these can invoke the build tasks
a Build Task per-artifact
I don't think that there's a "require" or "dependency" thingie-mah-bob; sorry

No option for C++ project in Qt Creator (QtSDK Community Installation)

I have installed (and reinstalled) the QtSDK Community version on Windows 7 64-bit. When I launch Qt Creator there is no option for C++ Project. Others have solved this problem by making sure qmake.exe is properly detected under Tools-->Options-->Build & Run-->Qt Versions but it appears to be in my installation:
First go to File->New and check the drop-down box in the top right: Is it set to show the relevant templates ("All templates" is the save bet).
If it does: Please check the Kits tab in Tools>Options>Build & Run: Is there a kit using the desktop device type with a compiler and Qt version? Do compiler and Qt version match (same type and version)?
With the Qt in the screenshot you need to have MSVC 2013 set up and detected. MSVC 2010 or any other version does not work, nor does mingw since the binaries that result from building with one compiler and linking to a Qt built with a different compiler does tend to crash more or less randomly.
Once you have a Kit with a Qt version the additional wizards should become available.

Is there any difference between Qt's MinGW, Code::Blocks' MinGW and MinGW it self?

Qt and Code blocks download package have their MinGW compiler. And there's standalone MinGW itself. Is there any difference between them?
Can I use Qt's MinGW to build Code blocks project or vice versa?
Did I need another MinGW if i want to build C++ project without Qt Creator or Code Blocks?
Or, can I just use Qt's or Code Blocks' MinGW without standalone version of MinGW?
Both Qt Creator and CodeBlocks just bundle a version of MinGW (GCC) in their installations for convenience, so that users don't have to install it and configure it manually. In both cases, you can choose to download or install the IDE without installing MinGW (GCC), in which case, you need to configure the IDE to use whatever compiler you want it to use (which not only can be any standalone MinGW/GCC installation, but also any other compiler, including MSVC (Microsoft compiler), ICC (Intel's compiler), or Clang).
Here are instructions to configure a custom compiler for Qt Creator. And here are instructions for CodeBlocks.
Is there any difference between them?
As far as I know, there is no significant difference between them, except for the version, of course. IDEs that are bundled with MinGW-GCC will typically come with one particular (and often a bit older / more stable) version of it. When you install a standalone MinGW-GCC, it can be whatever version you choose. There are differences between versions, but usually not anything that would "break" code, just faster / better compilations or additional advanced features (which are not used by "default" projects in any case).
Can I use Qt's MinGW to build Code blocks project or vice versa?
I'm pretty sure you can. I don't see any reason why not. Of course, you have to get the configuration right, as per the instructions I linked to above.
Did I need another MinGW if i want to build C++ project without Qt Creator or Code Blocks?
If you want to build things outside of an IDE that is configured with a particular compiler or installation of MinGW, then you will have to make sure to setup a few things. This process is easier when doing a standalone installation of MinGW, but you can also figure out how to take an existing MinGW installation (that came from Qt / CodeBlocks) and make it work under CMD / PowerShell / MSYS, but it's a bit trickier and more unusual.

How to obtain 64-bit binaries of Intel Fortran libraries for which I lack source code?

I have the source code for an application which currently builds as 32-bit, and I want to rebuild it to target a 64-bit machine, using Visual Studio 2010 on Windows 7.
I have attempted to do this by going to Project > Properties > configuration Properties > Configuration Manager > Active Solution Platform > and selecting x64, and also Copy settings from Win32. Then I proceed to build the solution. The building process gives a lot of warnings (but this also happens with the 32-bit build, and I think has to do with the fact that the original application was built using VS2005). The build has a single error:
lnk1112 module machine type x86 conflicts with target machine type x64
From what I researched in the internet, this had to do with the 64-bit solution trying to use libraries compiled for a 32-bit machine. I verified this using dumpbin.exe -headers <*.lib file> for all the *.lib files in the source code. All of them say "x86" on the header.
I am fairly confident that I can rebuild the libraries I have source code for, however there are a number of libraries (the dreaded Intel Fortran Libraries) that are also provided and used in the original solution, that were written for 32-bit:
IFCONSOL.lib
LIBIFCORE.lib
LIBIFCOREMT.lib
libirc.lib
libm.lib
Evidently, I do not have the source code for these libraries, and thus I would be unable to obtain "64-bit" versions. I have searched in the internet for "ifconsol.lib 64 bit" and the like, etc., but I have not found nothing meaningful.
My question is then, what are my options? If my solution needs these libraries, how can I obtain similar ones for 64-bit?
This is little more than a "let me google that for you" answer. Using the search term "intel fortran redistributable libraries" will give you lots of hits, the first of which is Redistributable libraries for the Intel® C++ and Visual Fortran Compiler 11.1 for Windows. The libraries are for the 11.1 version of IVF and you may need a different version (it is unclear from your post). These libraries can also be found in any licensed release of the intel compilers.
NOTE: for x64 download the "Intel 64" version of the packages. The "IA-64" version is for Itanium processors, which will not work for you.

Compile A MSVC++2010 Project So It Can Run On Ubuntu

I have a MSVC++ 2010 project. All the libraries it's using are cross platform (SDL, OpenGL and FLTK).
Obviously, all I have to do right now is press the debug button and it will compile a nice old .exe for me which can now run on Windows, as long as the DLL files are with it.
I had thought before that if you use cross platform libraries, then the generated .exe would run fine on Ubuntu too. I recently found out that this is not possible, and that the program must be compiled in a special way to run on a certain platform.
Is it possible to compile my project in this magical way with MSVC++ 2010 so that it can run on a Ubuntu computer? If so, then could you please answer my question with some clear steps as to what I should do to compile it this way, keeping in mind I'm new to how all this cross platform stuff works?
EDIT:
If I cannot compile a MSVC++ 2010 project for Ubuntu, is there an IDE I could use that could compile the project for both Windows and Ubuntu?
Thanks.
I suggest you use QT. http://qt.digia.com/
It's probably the best cross platform IDE that can let you compile for Windows, Mac and Linux(ubuntu) systems.
Nope, not possible. While the binary code corresponding to the program can be portable, that's not enough. Executable formats on various file systems are different and not compatible. The executable format is essentially a packaging of the binary data and wrapping it with a header that the target file system understands. In order to produce executables for Ubuntu, the linker must support it. MSVC++ doesn't support Linux formats.