Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt with Visual Studio 2017



  • I am trying to use Qcustoomplot in visual studio c++ by custom building. I am getting following error
    1>------ Build started: Project: Project5, Configuration: Debug Win32 ------
    1>Compiling qcustomplot.h using MOC
    1>moc: C:\Users\user\source\repos\Project5\qcustomplot.h -o C:\Users\user\source\repos\Project5\moc_qcustomplot.h: No such file
    1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
    1>Done building project "Project5.vcxproj" -- FAILED.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    qcustomplot.h is at the correct directory


  • Lifetime Qt Champion

    hi and welcome to the forums.
    Does your visual studio work with a normal Qt project ?
    Im wondering if its setup to use moc.exe properly.



  • Hi,
    With this kind of problem (I encounter it regularly), the best way is to open a command window and try to execute manually the comman moc C:\Users\user\source\repos\Project5\qcustomplot.h -o C:\Users\user\source\repos\Project5\moc_qcustomplot.h
    Unfortunately, calling Qt applications, like moc, under Visual only gives the result (fail or pass) without the error traces that are much more explicit.

    In every cases, even if it is not the case for you, I suggest that you change the props that contains the call to moc (and other functions). Because, regarding your traces, quotes around the file names seems to be missing. Thus, the day you will use a path with space inside, the command will systematically fail.



  • thanks for the reply

    I made a mistake by typing moc_qcustomplot.h instead of moc_qcustomplot.cpp


Log in to reply