[ad_1]
I apologize if my question is basic or irrelevant, I’m new to programming..
So learning C++ I have used the shortcut arrow to run my code so far, here is what it does in my powershell:
PS C:\Users\antdu953\Desktop\SAUVEGARDE TESLA\Documents\STUDIES\DOCTORAT\WAVE ENERGY\RESEARCH\DataSimon\Version08\Code> cd "c:\Users\antdu953\Programing\C\" ; if ($?) { g++ source.cpp -o source } ; if ($?) { .\source }
I noticed that is uses “ld.exe”. I now want to use multiple files, for function declaration for instance, and running with the shortcut arrow doesn’t work anymore, it seems to not recognize/read the .cpp files where function are defined and hence isn’t able to run my main.cpp. Here is the error message:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\antdu953\AppData\Local\Temp\ccI25RGR.o:source.cpp:(.text+0x18): undefined reference to `example(int, int)'
collect2.exe: error: ld returned 1 exit status
However I can run the multiple file by compiling in the terminal since it uses “g++.exe”:
Starting build...
C:\msys64\mingw64\bin\g++.exe -g -std=c++20 C:\Users\antdu953\Programing\C\*.cpp -o C:\Users\antdu953\Programing\C\test.exe
Build finished successfully.
I can also run it in powershell by writing:
PS C:\Users\antdu953\Programing\C> cd "c:\Users\antdu953\Programing\C\" ; if ($?) { g++ functionsExample.cpp source.cpp -o source } ; if ($?) { .\source }
However, to gain in efficiency (and knowledge), I would like to know if I can configure the arrow shortcut to be able to still run from the shortcut when using multiple files…Do you know if it is possible to do so ?
[ad_2]