Generating Qt pro files from sln file - c++

I like to make Qt applications in Visual Studio. But sometimes, there is a need to continue development in Linux space, where Visual Studio is not available. Therefore, there's a need to write down project files manually.
Is it possible to generate .pro files and makefiles from configurated .sln file?

I don't use Microsoft Visual Studio so I never had to deal with .sln files.
But actually, to generate your Qt environment from the command line in linux, you don't need the .sln file.You just have to do as follows:
Create your project directory, let's call it MyQtProject
Copy inside your sources files (.h, .cpp)
Then cd MyQtProject and run qmake -project : It will read your directory and create your .pro file (adding your headers and sources files, ...).
You can edit the generated MyQtProject.pro file to add some specific instructions (for exampleQT += widgets)
Then you just have to run qmake MyQtProject.pro to generate the Makefile.
Finally run make to compile.
Of course, you can create a build directory inside MyQtProject and run qmake ../MyQtProject.pro and make from inside it in order to not pollute your project folder with the moc files and the cmake related files.
I hope it can help you and solve your problem.

Related

How to compile/build/link - the XLNT library?

I downloaded the xlnt library for working with Excel - https://github.com/tfussell/xlnt. Can you please tell me what to do with it further? Honestly, I still can’t understand how among all the files there are in the downloaded archive, and there are 100 of them .hpp and .cpp files, what should I do with them?
1)As far as I understand, they need to be processed by the Cmake program and it seems that the output should appear .lib file, but I absolutely can’t understand how to do it or maybe something else
2)Or how can they be directly processed by Visual Studio 2017?
PS:When I launch Smack, I select the Source folder, the Cmake generates many incomprehensible files, but among them there is not one file with the .lib extension.
Help me please.
With CMake you can obtain the visual studio 2017 project files
and then compile the xlnt library.
Unzip the archive file
Within the xlnt folder, create a new directory and call it build
Launche CMake (GUI)
Browse for the source code folder
Browse for the build folder xlnt/build
With the Configure button select the tool (IDE/compiler) that you want to use
Pressing the Generate button, CMake will generate (inside the build folder)
the visual studio 2017 project files you need to compile the xlnt library
Building the solution, VS 2017 produces the xlnt.lib, xlnt.exp and xlnt.dll files.
The source path you see in the CMake screenshot is incorrect. You must specify the path that contains the "top level" CMakeLists.txt file.
The correct directory is: C:/Users/Zver/source/repos/XLNT Library/xlnt-master.
The CMakeLists.txt file in the above directory tells CMake all necessary subdirectories.
At this point you will see the static compilation option of the library appear.
If you use the MinGW/GCC compiler you must prevent the path from containing empty spaces.
Then you need to rename the directory from "XLNT Library" to "XLNTLibrary". At this point the path would become:
C:/Users/Zver/source/repos/XLNTLibrary/xlnt-master.

Qt, Qmake and Visual Studio 2013

I'm currenlty working on a portable project. To make it easier to compile on linux and windows, I'd like to use a .pro file which will generate a Makefile on linux and a visual studio project on windows.
But, I'm facing a problem on a very basic example.
Here is my .pro file:
TEMPLATE = app
TARGET = client
CONFIG += debug
SOURCES += src/main.cpp
My main.cpp only contains an empty main:
int main(void) { return 0; }
Then, I just open my visual studio console, cd in my project folder and run qmake.exe -spec win32-msvc2013 -tp vc.
This generates the expected vcxproj file, that I can open with visual studio.
The program compiles well with visual, but I got a fail during the execution: Qt5Cored.dll missing.
I've verified:
In the project properties, Qt lib directory has been added to the libraries directories
Qt5Cored.dll exists (and is located in the Qt lib directory)
I'm compiling and executing in debug environment
Additionnal information:
Qt is well installed
When I create a Qt5 project via visual studio, it works well (but this is not what I want).
When I manually import the .pro file using the Qt add-in, the vcxproj generated works well (no error during the execution): what's the difference? why the qmake doesn't work, but manual import does? Have I missed something to make the qmake work?
As someone has said in the comments of my question, the solution is pretty simple: I just needed to add the Qt bin path to the Windows PATH environment variable.
Problem solved :)

CMake and Visual Studio resource files

I am converting a C++ project created using Visual Studio 2005 to CMake and have stumbled upon a bit of a problem with resource files that are included in the project.
The project includes a .rc file, a bunch of .ico files and a .rc2 file.
The regular .rc file works fine in the generated project and uses the resource compiler. The .ico and .rc2 files however are causing problems when they are just being included, because in the generated project Visual Studio attempts to compile them using the C/C++ compiler.
I assume that these files are included by the .rc file, so it would probably work to just not include them in the CMakeLists.txt file, but since it is obviously possible to list them in the project (they are visible in the original project) I would like to do so, so that the user of the generated project can see that these files are being used.
What is the correct way to handle these extra VS resource files in CMake?
Try to set_source_files_properties(your.ico your.rc2 PROPERTIES LANGUAGE RC).
By default it shouldn't do anything with those files. The source file property LANGUAGE should be empty and thus the action for the file should be checked by the file type. Which shouldn't be anything since it's not something it should compile.
Check your CMakeLists.txt that is doesn't contain a set_source_files_properties command that would mess with that property.
If you want to do something with the files, here are two ways to do things:
With add_custom_target you can add them and run custom commands for them when you build the project. Granted that the files have changed.
With configure_file you can easily copy them to a build directory if needed. With the COPYONLY flag.

How do you include LuaPlus into your project?

I downloaded the visual2008 file from here(http://luaplus.org/projects/luaplus/files), but I don't know how to add it to my project. It's not like the other libraries where I just had to add the include directory to my Visual Studio folder and the bin to my system32 or project folder. There are no header files either. I'm using Visual Studio 2010 professional.
I remember downloading LuaPlus for the first time and thinking the same thing--"Where are the headers?" What you'll want to do is just clone the repository located on GitHub and use that to build LuaPlus yourself. The author helpfully included batch files to create different project files (incl. VS2010). You can then use the project files to build LuaPlus and you'll naturally also have the headers & source files as well. I don't recall if it included Lua's source already or if you have to do it yourself manually (this only takes a minute to do, however).

Build C++ Projects with Makefile using Visual Studio 2008

I downloaded cpptest from internet, and I want to build it using Visual Studio 2008.
The problem is that instead of .sln and vcproj file, Makefile.am is distributed, and I believe that all the all the necessary included file is included in the Makefile.am.
How to use Makefile.am to generate VS project files? I tried to use Cmake, but there is no CMakeList in the distribution.
Edit: Thanks to all the answers! There is a sln file distributed after all. But I am still interested to know the answer to my original question.
the visual studio project files for cpptest are in the win directory, not in the src directory where the makefile is..
edit
makefiles are meant to be used with GNU make. If you want that on windows, you can look at Mingw, GnuWin32 or Cygwin. But they also require gcc for compiling, so you won't really be using VS.
However, for most projects that do not have external dependencies it's no big deal if you do not have the VS project file: after all a makefile is just a list of the source files and some compilation options. To successfully build projects like cpptest, you could just create an emtpy VS project, add all source files to it, set output type to executable, build it and you're done. Eventually you can tune optimization options, but for the rest the default options will just do fine.
Go to win\VisualStudio.NET and you will find a VS solution file.
I just downloaded the archive and found the .sln file. It is under: /win/VisualStudio.NET. You can open that with VS2008 and update it, it should work.