Closed JamesBremner closed 1 year ago
I installed Visual Studio Code, installed Git 2.40.0, cloned the repository to my desktop, started Visual Studio Code, opened the folder containing the repository, and pressed F9, but nothing happened. Visual Studio Code keeps popping up messages asking if I want to install extensions; do I need those?
OK. Try this.
In VSCODE
I get an error saying that "mingw32-make.exe" does not exist.
Ah-Ah!
You need to install mingw.
Give me a moment to dig up the instructions.
Instructions to download and install the latest g++ 64 bit compiler from http://www.msys2.org/
Follow installation instructions on(http://www.msys2.org/).
Note that you will have to stop and restart the MSYS2 command line tool several times. To do this, close the window and then run C:\msys64\msys2_shell.
When pacman ( package manager ) reports "there is nothing to do" run it once more with the command
pacman -S mingw-w64-x86_64-toolchain
Ensure the compiler is in the path.
What timezone are you in? I will be quitting for the day in about 30 mins.
I am sorry that I forgot how complex doing a first build is when you have never done so before. I promise it becomes very straightforward once you have everything you need.
All this stuff, version control, coding collaboration and building is vital to become familiar with if you want to code at a serious or professional level. If that is not your ambition, it would be perfectly understandable to stop now.
I need to stop as well. I'm in Eastern Standard Time. I'll try and get mingw working tonight. Thank you for your patience and assistance!
I think I've got msys2 installed and updated according to the instructions from msys2.org, and I ran the command you gave, and I found the file that Visual Studio Code said it wanted and copied it into the directory where it said it was looking, and it put the following in the terminal:
g++ -std=c++17 -g -Dmingw \ -c -o .vscode/obj/main.o ./src/main.cpp -I./include process_begin: CreateProcess(NULL, g++ -std=c++17 -g -Dmingw -c -o .vscode/obj/main.o ./src/main.cpp -I./include, ...) failed. make (e=2): The system cannot find the file specified. mingw32-make: *** [.vscode/makefile:29: .vscode/obj/main.o] Error 2
I think I've got msys2 installed and updated according to the instructions from msys2.org,
Well done
I found the file that Visual Studio Code said it wanted and copied it into the directory
What file? What directory?
Do not copy, move are create files in the repo clone folder - it will mess up your next commit. If you have done this, remove all such files before you do anything else
Have you ensured that the compiler is in your path?
To check, run the compiler from a terminal. It should look like this
C:\Users\James>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Users/James/code_ext/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-11.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --with-boot-ldflags='-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc' 'LDFLAGS_FOR_TARGET=-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high' --enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ -pipe\ -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high\ -Wl,--stack,12582912'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Rev2, Built by MSYS2 project)
Instructions for editing your path https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/
In my case, I installed MSYS64 to C:\Users\James\code_ext
so I addedC:\Users\James\code_ext\msys64\mingw64\bin
to my path.
I had never heard of PATH before today. I thought you meant the file path, so I had copied "mingw32-make.exe" from "...\msys64\mingw64\bin" to the main "...\workshoplocator" folder because that's where Visual Studio Code said it was looking for that file. I have deleted that copy and updated my PATH according to the instructions you linked, after some experimentation added a line of code to "main.cpp", and I finally got "Terminal → Run Task... → starter" to run without errors.
How do I keep the files on my computer in sync with the files on GitHub
There are several different ways, of course To keep things simple, I will reccomend just one:
When you cloned your repo, you saw this:
You should choose the red circled option. ( I guess you chose something else! )
This will download a GUI application ( called GitHub Desktop ) that makes it very easy to keep things in sync.
Okay, I was DEFINITELY doing this the hard way. 😑
I installed GitHub Desktop and edited the files in Visual Studio Code on my computer, but when I try to run "starter", I get the error that "Path to shell executable '[...]\Documents\GitHub\workshoplocator\mingw32-make.exe' does not exist" again. I verified that the folder for mingw32-make.exe is still in my PATH variable, so I'm not sure why it stopped working.
I think I did something wrong again, I committed my changes in the desktop application to see if it would work but they're not showing up in the browser version.
Please do not commit anything until you have done a successful build and test run. How many time do I need to say this? Once everything is working THEN you commit.
I will look at the build problem tomorrow. I have cloned your repository and it builds just fine here. It is obvious that your build is incorrectly configured. Try building by hand.
mingw32-make.exe -f .vscode/makefile starter
I'm not sure what you mean by "cd to the vscode folder".
cd stands for "change directory". Just type "cd (path to vscode folder)"
Like this:
cd C:\Users\James\code\workshoplocator\.vscode
Entering "g++ -v" produces the output you said it should. Changing to the "[...]\workshoplocator.vscode" folder and entering "mingw32-make.exe -f .vscode/makefile starter" produces the output:
mingw32-make: .vscode/makefile: No such file or directory mingw32-make: *** No rule to make target '.vscode/makefile'. Stop.
For what it's worth, I can clearly see that there exists a file called "makefile" inside the folder ".vscode", so I don't know why the program can't find it.
Does it matter that I install programs on a (small, SSD) C drive and save documents on a (larger, HDD) E drive? If that does matter, I don't know why it worked when I was struggling with command-line Git but not when I switched to the seemingly-much-more-intuitive GitHub Desktop. Both Git and GitHub Desktop (and Visual Studio Code) are installed on C and reading files in the Documents folder on E.
Also, I do apologize for not following procedures. I'm accustomed to a more exploratory side of things, and all of my instinct and experience is to "just try it and see what happens". It's taking some adjustment to get used to this more strict methodology. I haven't taken formal, technical programming classes; my actual coding experience before now is pretty much entirely self-taught, using JavaScript and XML to automate mathematical constructions and calculations and a bit of HTML and CSS to make it look good. My thought going into this was: "This problem seems like it would be really tedious to solve by hand. Computers were BUILT to solve problems that are too tedious to reasonably do by hand. Can a computer solve this particular problem for me?" I don't know if this will ultimately be easier, but it is at the very least a new experience and not nearly as tedious (so far).
I think I have found the problem with the hand build!
The command should be typed into a terminal in the repository folder ( NOT the .vscode folder as I had assumed without actually testing it :-(
Like this:
C:\Users\James>cd code\workshoplocator
C:\Users\James\code\workshoplocator>mingw32-make.exe -f .vscode/makefile starter
g++ -g \
-o bin/starter.exe .vscode/obj/main.o \
-static-libstdc++ -static-libgcc -static -lComctl32 -lgdiplus -lgdi32 -lcomdlg32 -lstdc++fs
I get:
E:\Users\Zachary\Documents\GitHub\workshoplocator>mingw32-make.exe -f .vscode/makefile starter g++ -std=c++17 -g -Dmingw \ -c -o .vscode/obj/main.o ./src/main.cpp -I./include g++ -g \ -o bin/starter.exe .vscode/obj/main.o \ -static-libstdc++ -static-libgcc -static -lComctl32 -lgdiplus -lgdi32 -lcomdlg32 -lstdc++fs
Does that mean we're good?
If you still want the other commands, the results are:
E:\Users\Zachary\Documents\GitHub\workshoplocator>dir Volume in drive E is File Data Volume Serial Number is 80AD-F0A8
Directory of E:\Users\Zachary\Documents\GitHub\workshoplocator
2023-04-16 04:13 PM
. 2023-04-16 04:13 PM .. 2023-04-16 04:13 PM 68 .gitattributes 2023-04-16 04:13 PM 333 .gitignore 2023-04-16 04:35 PM .vscode 2023-04-17 08:43 AM bin 2023-04-16 04:13 PM doc 2023-04-16 04:13 PM 160 README.md 2023-04-16 04:13 PM src 3 File(s) 561 bytes 6 Dir(s) 80,861,409,280 bytes free E:\Users\Zachary\Documents\GitHub\workshoplocator>g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-12.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev10, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++ Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Rev10, Built by MSYS2 project)
Does that mean we're good?
That looks very good.
Now do a test run.
I made sure I cloned MY repository with GitHub Desktop, opened it in Visual Studio Code, went to "Terminal" → "Run Task..." → "starter", and got this in the Terminal:
* Executing task: C:\msys64\mingw64\bin\mingw32-make.exe -f .vscode/makefile starter
g++ -std=c++17 -g -D_mingw_ \
-c -o .vscode/obj/main.o ./src/main.cpp -I./include
g++ -g \
-o bin/starter.exe .vscode/obj/main.o \
-static-libstdc++ -static-libgcc -static -lComctl32 -lgdiplus -lgdi32 -lcomdlg32 -lstdc++fs
* Terminal will be reused by tasks, press any key to close it.
Now do a test run
I notice from the log of your build that cWorkshop.cpp is missing. Looks like you have not updated your fork.
Okay, I figured out how to update the fork in GitHub Desktop. Running "starter" again produces this output:
* Executing task: C:\msys64\mingw64\bin\mingw32-make.exe -f .vscode/makefile starter
g++ -std=c++17 -g -D_mingw_ \
-c -o .vscode/obj/main.o ./src/main.cpp -I./include
g++ -std=c++17 -g -D_mingw_ \
-c -o .vscode/obj/cWorkshop.o ./src/cWorkshop.cpp -I./include
g++ -g \
-o bin/workshopLocator.exe .vscode/obj/main.o .vscode/obj/cWorkshop.o \
-static-libstdc++ -static-libgcc -static -lComctl32 -lgdiplus -lgdi32 -lcomdlg32 -lstdc++fs
* Terminal will be reused by tasks, press any key to close it.
Now do a test run
I take it that running "starter" is not what you mean by "do a test run"? What do you want me to do instead?
g++ -g \
-o bin/workshopLocator.exe ...
Now run the application.
Surely you are familiar with edit, build, test, repeat
Now you have to add another step because you are collaborating on a project with another coder
edit, build, test, repeat until test success, commit
Got it. I didn't realize we had a runnable EXE file yet.
It launches a command-prompt window successfully and asks for the Workshop mix. I entered "5 4 3 0 0" and it crashed after outputting the following:
terminate called after throwing an instance of 'std::runtime_error'
what(): cWorkshop::cWorkshop unrecognized type
I added the changes to the text files for the other Workshop types, ran "starter" again, launched the EXE file again, entered the same Workshop mix, and it still crashed but now the output was:
terminate called after throwing an instance of 'std::runtime_error'
what(): cWorkshop::CalcActualTemp unrecognized module type
I have not committed anything.
cWorkshop::cWorkshop unrecognized type
You need to fix all exceptions before you commit
I'm not seeing why I'm getting the cWorkshop::CalcActualTemp unrecognized module type
error. It looks like all Module types are accounted for and I don't see any typos.
Never mind, immediately after I posted that I looked again and realized that you left out an "i" in "artificial".
Never mind the never mind, even after fixing the spelling of "artificial" everywhere it appears in "main.cpp" and "workshop.h", I still get the same error after running "starter", launching the EXE, and entering the Workshop mix "5 4 3 0 0".
And entering the Workshop mix "12 0 0 0 0" causes the Command Prompt window to close without even an error message.
Do you want me to look at this?
Unfortunately, the only way I can "see" you code is if you commit it to your repo - even though it does not work.
If you prefer to work on this yourself, then you will need to use the debugger to track down what and where the problem is.
Do you know how to use the debugger?
I don't know how to use the debugger. I will commit the code to my repository so you can look at it.
Knowing how to use the debugger is the most important skill a coder should possess!
Debugger intro:
I will commit the code to my repository so you can look at it.
Let me know when you have done so - I will not get a notification.
I fixed that problem, but now I'm getting the error multiple definition of 'cWorkshop::text[abi:cxx11]()'
. It looks like that object is now defined in both "cWorkshop.cpp" and "main.cpp". Should I remove it from one of those files?
Please post the complete build log
Should I remove it from one of those files?
Yes. It is a method of the cWorkshop class, so it belongs in cWorkshop.cpp
Removed it from "main.cpp". The new build log is:
* Executing task: C:\msys64\mingw64\bin\mingw32-make.exe -f .vscode/makefile starter
g++ -std=c++17 -g -D_mingw_ \
-c -o .vscode/obj/main.o ./src/main.cpp -I./include
g++ -g \
-o bin/workshopLocator.exe .vscode/obj/main.o .vscode/obj/cWorkshop.o \
-static-libstdc++ -static-libgcc -static -lComctl32 -lgdiplus -lgdi32 -lcomdlg32 -lstdc++fs
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .vscode/obj/cWorkshop.o: in function `std::__new_allocator<eModuleType>::~__new_allocator()':
E:\Users\Zachary\Documents\GitHub\workshoplocator/./src/cWorkshop.cpp:9: multiple definition
of `cWorkshop::cWorkshop(eWorkShopType)'; .vscode/obj/main.o:E:\Users\Zachary\Documents\GitHub\workshoplocator/./src/main.cpp:64: first defined here
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .vscode/obj/cWorkshop.o: in function `std::__new_allocator<eModuleType>::~__new_allocator()':
E:\Users\Zachary\Documents\GitHub\workshoplocator/./src/cWorkshop.cpp:9: multiple definition
of `cWorkshop::cWorkshop(eWorkShopType)'; .vscode/obj/main.o:E:\Users\Zachary\Documents\GitHub\workshoplocator/./src/main.cpp:64: first defined here
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [.vscode/makefile:34: starter] Error 1
* The terminal process "C:\msys64\mingw64\bin\mingw32-make.exe '-f', '.vscode/makefile', 'starter'" terminated with exit code: 2.
* Terminal will be reused by tasks, press any key to close it.
Try a rebuild:
Run task 'clear' Run task 'starter'
I had to remove "cWorkshop::cWorkshop" from "main.cpp" as well, and it now builds cleanly.
Still crashes, though. I committed it so you can look at it.
Do you get an error message? Have you run it under the debugger?
Please stop committing tiny little commits with bits and pieces of code.
Steps to build: