I succeeded in building a program in visual studio 2012 that runs QT without the plugin. I included the QT include folder and manually added the libraries to the resources. And it compiled and ran.
Now I wanted to use QCustomPlot in the same way, without the QtAddin plugin. I tried multiple projects, where I added QCustomPlot's .h and .cpp and tried to compile, but it gives me tons of linker problems(http://pastebin.com/SWVXktBk). Can someone point me in the right direction?
Windows 7 x64, QT 5.4.1,
After hours, I found it.
As UldisK pointed, I had to moc the header.
I followed everything in here: http://ldmartin68.com/QTSetup4VSNET.html
In windows cmd
moc qcustomplot.h > moc_qcustomplot.cpp
then simply add the generated file to the project, and voila worked.
In the end you should have in the project:
the original qcustomplot.h
the original qcustomplot.cpp
the generated moc_qcustomplot.cpp
Related
I work in a project using Qt compiled with Visual Studio C++ compiler.
I noticed after migrating from VS2017 to VS2019 that when building the application, VS always find qrc cpp files as modified and try to rebuild them.
Is not happening for all projects though, only some unit tests.
Does someone notice this behavior?
I've had the same issues when upgrading from vc141 (2017) to vc142 (2019). It's old but the only post I found, so:
The difference in the toolkits is that in vc142 "Custom Build Tools" are now appended to include inherited values. If your project is configured to use a build tool projectwide by default (for example meta objects from QTs signal/slot), the compiler will try to do that as well when trying to rcc the qrc files, and ultimately failing without throwing an error.
Simply removing ;%(Outputs) in Properties->Custom Build Tool->General->Outputs solved it for me.
When I'm loading a certain project using Qt Creator, I get this message repeated twice in the General Messages pane:
Project MESSAGE: You are running qmake on a generated .pro file. This may not work!
Project MESSAGE: You are running qmake on a generated .pro file. This may not work!
Screenshot:
This happens only on one of the projects (this project was created by a colleague, not me, so I don't know what's different about it).
What does this message mean? Is there something that should be fixed in the .pro file?
Project Message: usually indicates that the following text was printed in the qmake file using message(text).
In that case, your best hope is to grep for the message in all .pro files, find out where it comes from and asking your colleague what that message is supposed to mean if you can't figure it out.
Edit: I just found out that the Qt Visual Studio Integration puts this message in autogenerated qmake files. If you or your colleague are using the VS integration, you could remove that message if you do not intend to re-generate the .pro file. The message is basically there to tell you that you might have to adjust some things to make the project build correctly (which it seems to do in your case).
In that case, the code generally looks like this:
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Add-in.
# ------------------------------------------------------
# This is a reminder that you are using a generated .pro file.
# Remove it when you are finished editing this file.
message("You are running qmake on a generated .pro file. This may not work!")
I have a Qt project with QML files. Whenever I change these files, I have to manually right click the .qrc (resources) file and recompile it.
How do I tell visual studio to always compile a certain file, not only when it thinks it has changed?
(Here are similar questions others have asked for eclipse and flashdevelop)
I encountered the same problem while building qt apps using Qt Creator.(Especially while using QML files as resources.) I solved the problem using a little hack.
Created a batch file say touch.bat in my source directory.
This batch file contains a single line copy qml.qrc /B+ ,,/Y where qml.qrc is the resource file name.
Opened my project in QtCreator and went to Project->Build Steps->Add Build Step->Custom process step and entered touch.bat
Whenever the project build starts, the qml.qrc is touched. The build system thinks that qml.qrc is modified and builds it.
You can modify this hack for Visual Studio also.(I have not tried). Try adding touch.bat as a build step in Visual studio. The idea is to fool the build system to think that your .qrc is modified.
I guess this is a known bug which remains unresolved. Check this bug report.
Thanks.
I'm using Qt4.8 with Visual Studio 2012 with Qt VS add-in 1.1.8. And I have a problem with moc_ files generation. If I add new class (with .h and .cpp files) to my project, where Q_OBJECT is supplied, then moc_ file is not being generated correctly and I get linking errors.
In .h file's custom build tool's command line, moc.exe's commands should be filled automatically. It seems everything is OK in Production configuration, but in Debug and Release configurations custom build tools command lines are empty and every time I have to write them, build and add moc_ file to my project manually, which is quite inconvenient.
So what can be problem for automatic generation? Which solution can be?
Thank you in advance!
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.