Cant build stanford CS106L projects using QTCreator
-
Change in your
GraphViz.pro
the following lines:SOURCES += $$PWD/src/*.cpp SOURCES += $$PWD/src/*.h HEADERS += $$PWD/src/*.h # set up flags for the compiler and Stanford C++ libraries QMAKE_CXXFLAGS += -std=c++11 \
to these lines:
SOURCES += $$files(src/*.cpp) SOURCES += $$files(src/*.h) HEADERS += $$files(src/*.h) # set up flags for the compiler and Stanford C++ libraries QMAKE_CXXFLAGS += -std=c++17 \
And your project will compile with MinGW 11.2.0.
The first part fixed my issue, the second part will fix your issue 😀
-
I deleted the
build
directory and then right click on the project and then selected Build and the output looks like this:19:16:06: Running steps for project GraphViz... 19:16:06: Starting: "C:\Qt\6.7.2\mingw_64\bin\qmake.exe" C:\Projects\stanford\01_GraphViz\GraphViz.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" Info: creating stash file C:\Projects\stanford\01_GraphViz\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug\.qmake.stash 19:16:09: The process "C:\Qt\6.7.2\mingw_64\bin\qmake.exe" exited normally. 19:16:09: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -f C:/Projects/stanford/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/Makefile qmake_all mingw32-make: Nothing to be done for 'qmake_all'. 19:16:09: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally. 19:16:09: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j8 C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Projects/stanford/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' g++ -c -fno-keep-inline-dllexport -std=c++17 -Wall -Wextra -Wreturn-type -Werror=return-type -Wunreachable-code -g -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -IC:/Qt/6.7.2/mingw_64/include -IC:/Qt/6.7.2/mingw_64/include/QtWidgets -IC:/Qt/6.7.2/mingw_64/include/QtGui -IC:/Qt/6.7.2/mingw_64/include/QtCore -Idebug -I/include -IC:/Qt/6.7.2/mingw_64/mkspecs/win32-g++ -o debug\main.o ..\..\src\main.cpp g++ -c -fno-keep-inline-dllexport -std=c++17 -Wall -Wextra -Wreturn-type -Werror=return-type -Wunreachable-code -g -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -IC:/Qt/6.7.2/mingw_64/include -IC:/Qt/6.7.2/mingw_64/include/QtWidgets -IC:/Qt/6.7.2/mingw_64/include/QtGui -IC:/Qt/6.7.2/mingw_64/include/QtCore -Idebug -I/include -IC:/Qt/6.7.2/mingw_64/mkspecs/win32-g++ -o debug\SimpleGraph.o ..\..\src\SimpleGraph.cpp g++ -fno-keep-inline-dllexport -std=c++17 -Wall -Wextra -Wreturn-type -Werror=return-type -Wunreachable-code -g -Wall -Wextra -Wextra -dM -E -o debug\moc_predefs.h C:\Qt\6.7.2\mingw_64\mkspecs\features\data\dummy.cpp xcopy "C:\Projects\stanford\01_GraphViz\res" "C:\Projects\stanford\01_GraphViz\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug" /e /y C:\Projects\stanford\01_GraphViz\res\10clique C:\Projects\stanford\01_GraphViz\res\10grid C:\Projects\stanford\01_GraphViz\res\10line C:\Projects\stanford\01_GraphViz\res\127binary-tree C:\Projects\stanford\01_GraphViz\res\2line C:\Projects\stanford\01_GraphViz\res\30clique C:\Projects\stanford\01_GraphViz\res\30cycle C:\Projects\stanford\01_GraphViz\res\31binary-tree C:\Projects\stanford\01_GraphViz\res\32wheel C:\Projects\stanford\01_GraphViz\res\3grid C:\Projects\stanford\01_GraphViz\res\50line C:\Projects\stanford\01_GraphViz\res\5clique C:\Projects\stanford\01_GraphViz\res\5grid C:\Projects\stanford\01_GraphViz\res\60cycle C:\Projects\stanford\01_GraphViz\res\63binary-tree C:\Projects\stanford\01_GraphViz\res\64wheel C:\Projects\stanford\01_GraphViz\res\8wheel C:\Projects\stanford\01_GraphViz\res\bull C:\Projects\stanford\01_GraphViz\res\cube C:\Projects\stanford\01_GraphViz\res\desargues C:\Projects\stanford\01_GraphViz\res\dodecahedron C:\Projects\stanford\01_GraphViz\res\doodad-1 C:\Projects\stanford\01_GraphViz\res\doodad-2 C:\Projects\stanford\01_GraphViz\res\doodad-3 C:\Projects\stanford\01_GraphViz\res\durer C:\Projects\stanford\01_GraphViz\res\heawood C:\Projects\stanford\01_GraphViz\res\icosahedron C:\Projects\stanford\01_GraphViz\res\mobius-kantor C:\Projects\stanford\01_GraphViz\res\moser-spindle C:\Projects\stanford\01_GraphViz\res\octahedron C:\Projects\stanford\01_GraphViz\res\petersen C:\Projects\stanford\01_GraphViz\res\star C:\Projects\stanford\01_GraphViz\res\tesseract C:\Projects\stanford\01_GraphViz\res\tietze C:\Projects\stanford\01_GraphViz\res\triangle 35 File(s) copied C:\Qt\6.7.2\mingw_64\bin\moc.exe -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include C:/Projects/stanford/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/debug/moc_predefs.h -IC:/Qt/6.7.2/mingw_64/mkspecs/win32-g++ -IC:/Projects/stanford/01_GraphViz -IC:/Qt/6.7.2/mingw_64/include -IC:/Qt/6.7.2/mingw_64/include/QtWidgets -IC:/Qt/6.7.2/mingw_64/include/QtGui -IC:/Qt/6.7.2/mingw_64/include/QtCore -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -IC:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include ..\..\src\SimpleGraph.h -o debug\moc_SimpleGraph.cpp g++ -c -fno-keep-inline-dllexport -std=c++17 -Wall -Wextra -Wreturn-type -Werror=return-type -Wunreachable-code -g -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -IC:/Qt/6.7.2/mingw_64/include -IC:/Qt/6.7.2/mingw_64/include/QtWidgets -IC:/Qt/6.7.2/mingw_64/include/QtGui -IC:/Qt/6.7.2/mingw_64/include/QtCore -Idebug -I/include -IC:/Qt/6.7.2/mingw_64/mkspecs/win32-g++ -o debug\moc_SimpleGraph.o debug\moc_SimpleGraph.cpp ..\..\src\SimpleGraph.cpp: In member function 'virtual void WorkerThread::run()': ..\..\src\SimpleGraph.cpp:95:22: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 95 | int _userMain(); | ^~ ..\..\src\SimpleGraph.cpp:95:22: note: remove parentheses to default-initialize a variable 95 | int _userMain(); | ^~ | -- ..\..\src\SimpleGraph.cpp:95:22: note: or replace parentheses with braces to value-initialize a variable g++ -Wl,-subsystem,console -mthreads -o debug\GraphViz.exe debug/main.o debug/SimpleGraph.o debug/moc_SimpleGraph.o C:\Qt\6.7.2\mingw_64\lib\libQt6Widgets.a C:\Qt\6.7.2\mingw_64\lib\libQt6Gui.a C:\Qt\6.7.2\mingw_64\lib\libQt6Core.a mingw32-make[1]: Leaving directory 'C:/Projects/stanford/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' 19:16:21: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited normally. 19:16:21: Elapsed time: 00:15.
I don't see a reason why this should fail. You can check:
- that the build path doesn't contain spaces or something weird
- disable the antivirus, which for some reason would want to block something
-
Hey many thanks for taking the time.
Your solution got rid of all errors except 1 (copyResources Error 4), I have tried a few things recommended by chatGPT but still no luck :/
@d14bl0 In addition to what @cristian-adam said: Please show the compile output (best as text) so we see what actually goes wrong.
Regards
-
This is the compile output after disabling antivirus:
11:12:33: Running steps for project GraphViz... 11:12:33: Configuration unchanged, skipping qmake step. 11:12:33: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j20 C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' xcopy "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\res" "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug" /e /y Invalid number of parameters mingw32-make[1]: *** [Makefile.Debug:91: copyResources] Error 4 mingw32-make[1]: Leaving directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' mingw32-make: *** [Makefile:45: debug] Error 2 11:12:33: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project GraphViz (kit: Desktop Qt 6.7.2 MinGW 64-bit) When executing step "Make" 11:12:33: Elapsed time: 00:00.
and this is the .pro file
QT += widgets CONFIG += no_include_pwd CONFIG += console CONFIG -= app_bundle SOURCES += $$files(src/*.cpp) SOURCES += $$files(src/*.h) HEADERS += $$files(src/*.h) QMAKE_CXXFLAGS += -std=c++17 \ -Wall \ -Wextra \ -Wreturn-type \ -Werror=return-type \ -Wunreachable-code \ defineTest(copyToDestdir) { files = $$1 for(FILE, files) { DDIR = $$OUT_PWD win32:FILE ~= s,/,\\,g win32:DDIR ~= s,/,\\,g !win32 { copyResources.commands += cp -r '"'$$FILE'"' '"'$$DDIR'"' $$escape_expand(\\n\\t) } win32 { copyResources.commands += xcopy '"'$$FILE'"' '"'$$DDIR'"' /e /y $$escape_expand(\\n\\t) } } export(copyResources.commands) } !win32 { copyToDestdir($$files($$PWD/res/*)) } win32 { copyToDestdir($$PWD/res) } copyResources.input = $$files($$PWD/res) OTHER_FILES = $$files(res/*) QMAKE_EXTRA_TARGETS += copyResources POST_TARGETDEPS += copyResources macx { cache() QMAKE_MAC_SDK = macosx }
-
This is the compile output after disabling antivirus:
11:12:33: Running steps for project GraphViz... 11:12:33: Configuration unchanged, skipping qmake step. 11:12:33: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j20 C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' xcopy "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\res" "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug" /e /y Invalid number of parameters mingw32-make[1]: *** [Makefile.Debug:91: copyResources] Error 4 mingw32-make[1]: Leaving directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' mingw32-make: *** [Makefile:45: debug] Error 2 11:12:33: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project GraphViz (kit: Desktop Qt 6.7.2 MinGW 64-bit) When executing step "Make" 11:12:33: Elapsed time: 00:00.
and this is the .pro file
QT += widgets CONFIG += no_include_pwd CONFIG += console CONFIG -= app_bundle SOURCES += $$files(src/*.cpp) SOURCES += $$files(src/*.h) HEADERS += $$files(src/*.h) QMAKE_CXXFLAGS += -std=c++17 \ -Wall \ -Wextra \ -Wreturn-type \ -Werror=return-type \ -Wunreachable-code \ defineTest(copyToDestdir) { files = $$1 for(FILE, files) { DDIR = $$OUT_PWD win32:FILE ~= s,/,\\,g win32:DDIR ~= s,/,\\,g !win32 { copyResources.commands += cp -r '"'$$FILE'"' '"'$$DDIR'"' $$escape_expand(\\n\\t) } win32 { copyResources.commands += xcopy '"'$$FILE'"' '"'$$DDIR'"' /e /y $$escape_expand(\\n\\t) } } export(copyResources.commands) } !win32 { copyToDestdir($$files($$PWD/res/*)) } win32 { copyToDestdir($$PWD/res) } copyResources.input = $$files($$PWD/res) OTHER_FILES = $$files(res/*) QMAKE_EXTRA_TARGETS += copyResources POST_TARGETDEPS += copyResources macx { cache() QMAKE_MAC_SDK = macosx }
-
This is the compile output after disabling antivirus:
11:12:33: Running steps for project GraphViz... 11:12:33: Configuration unchanged, skipping qmake step. 11:12:33: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j20 C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' xcopy "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\res" "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug" /e /y Invalid number of parameters mingw32-make[1]: *** [Makefile.Debug:91: copyResources] Error 4 mingw32-make[1]: Leaving directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' mingw32-make: *** [Makefile:45: debug] Error 2 11:12:33: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project GraphViz (kit: Desktop Qt 6.7.2 MinGW 64-bit) When executing step "Make" 11:12:33: Elapsed time: 00:00.
and this is the .pro file
QT += widgets CONFIG += no_include_pwd CONFIG += console CONFIG -= app_bundle SOURCES += $$files(src/*.cpp) SOURCES += $$files(src/*.h) HEADERS += $$files(src/*.h) QMAKE_CXXFLAGS += -std=c++17 \ -Wall \ -Wextra \ -Wreturn-type \ -Werror=return-type \ -Wunreachable-code \ defineTest(copyToDestdir) { files = $$1 for(FILE, files) { DDIR = $$OUT_PWD win32:FILE ~= s,/,\\,g win32:DDIR ~= s,/,\\,g !win32 { copyResources.commands += cp -r '"'$$FILE'"' '"'$$DDIR'"' $$escape_expand(\\n\\t) } win32 { copyResources.commands += xcopy '"'$$FILE'"' '"'$$DDIR'"' /e /y $$escape_expand(\\n\\t) } } export(copyResources.commands) } !win32 { copyToDestdir($$files($$PWD/res/*)) } win32 { copyToDestdir($$PWD/res) } copyResources.input = $$files($$PWD/res) OTHER_FILES = $$files(res/*) QMAKE_EXTRA_TARGETS += copyResources POST_TARGETDEPS += copyResources macx { cache() QMAKE_MAC_SDK = macosx }
@d14bl0 said in Cant build stanford CS106L projects using QTCreator:
SOURCES += $$files(src/*.cpp) SOURCES += $$files(src/*.h) HEADERS += $$files(src/*.h)
is this correct ? From personal experience I would say no, adding header files to sources usually leads to compile problems!?
-
This is the compile output after disabling antivirus:
11:12:33: Running steps for project GraphViz... 11:12:33: Configuration unchanged, skipping qmake step. 11:12:33: Starting: "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" -j20 C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' xcopy "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\res" "C:\Users\DELLPHOTO\Downloads\01_GraphViz_2\01_GraphViz\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug" /e /y Invalid number of parameters mingw32-make[1]: *** [Makefile.Debug:91: copyResources] Error 4 mingw32-make[1]: Leaving directory 'C:/Users/DELLPHOTO/Downloads/01_GraphViz_2/01_GraphViz/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug' mingw32-make: *** [Makefile:45: debug] Error 2 11:12:33: The process "C:\Qt\Tools\mingw1120_64\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project GraphViz (kit: Desktop Qt 6.7.2 MinGW 64-bit) When executing step "Make" 11:12:33: Elapsed time: 00:00.
and this is the .pro file
QT += widgets CONFIG += no_include_pwd CONFIG += console CONFIG -= app_bundle SOURCES += $$files(src/*.cpp) SOURCES += $$files(src/*.h) HEADERS += $$files(src/*.h) QMAKE_CXXFLAGS += -std=c++17 \ -Wall \ -Wextra \ -Wreturn-type \ -Werror=return-type \ -Wunreachable-code \ defineTest(copyToDestdir) { files = $$1 for(FILE, files) { DDIR = $$OUT_PWD win32:FILE ~= s,/,\\,g win32:DDIR ~= s,/,\\,g !win32 { copyResources.commands += cp -r '"'$$FILE'"' '"'$$DDIR'"' $$escape_expand(\\n\\t) } win32 { copyResources.commands += xcopy '"'$$FILE'"' '"'$$DDIR'"' /e /y $$escape_expand(\\n\\t) } } export(copyResources.commands) } !win32 { copyToDestdir($$files($$PWD/res/*)) } win32 { copyToDestdir($$PWD/res) } copyResources.input = $$files($$PWD/res) OTHER_FILES = $$files(res/*) QMAKE_EXTRA_TARGETS += copyResources POST_TARGETDEPS += copyResources macx { cache() QMAKE_MAC_SDK = macosx }
@d14bl0 You could just comment the whole copyResources part and do the copy of the
res
directory manually.This way QMake won't try to do smart things that fail in weird ways.
-
@cristian-adam Hey thank you very much! that worked :D I was just about to give up.
Thanks again!!!
-
@cristian-adam Hey thank you very much! that worked :D I was just about to give up.
Thanks again!!!
@d14bl0 said in Cant build stanford CS106L projects using QTCreator:
@cristian-adam Hey thank you very much! that worked :D I was just about to give up.
Thanks again!!!
Don't forget to mark the thread as Solved.
-