This question already has answers here:
Why do you need ./ (dot-slash) before executable or script name to run it in bash?
(9 answers)
Closed 9 years ago.
g++ main.cpp main
./main
why do we use ./ sign? why can't we type "run main" ? Who made this convention? is it purely historical?
Also, can we change this ./ to run main forever? I suppose you can do it with bash script?
It has nothing to do with C++, it's your command shell. It's simply the way of telling it that the file exists in the current directory.
Related
This question already has answers here:
makefile:4: *** missing separator. Stop
(17 answers)
Closed 1 year ago.
I'm new to macOS terminal commands and have recently got introduced to makefiles while learning to program in C++.
The makefile that I was using had the following content:
fact:factorial2.o facth.o
c++ factorial2.o facth.o -o fact
facth.o:facth.cpp
c++ -c facth.cpp
factorial2.o:factorial2.cpp
c++ -c factorial2.cpp
All the files, factorial2.cpp and facth.cpp are present in the same folder as makefile.
On entering 'make' command in the terminal, I received the following:
makefile:2: *** missing separator. Stop.
Kindly help me out with this and tell me where exactly I'm making the mistake as I'm not able to figure out the same. For my friends using Ubuntu, the above works perfectly.
Makefiles use tab delimeters rather than 4 spaces. Replace the spaces with tabs on lines 2, 4, and 6.
This question already has answers here:
How do I run two commands in one line in Windows CMD?
(22 answers)
Closed 2 years ago.
In macOS whenever I compile and execute my code I use
g++ name.cpp && ./a.out
but in Windows it doesn't work for compile and run i use
g++ name.cpp
./a.exe
I'm using command prompt.
g++ name.cpp && ./a.exe doesn't work.
But i want to use a single line command like i used to do in macOS
In Windows, backslash (or yen mark on some font) is used as separator of directory.
g++ name.cpp && .\a.exe
worked on Command Prompt (but not on PowerShell).
Separate the two different commands using &&.
For invoking the application it depends on your terminal:
a - you have to use '\' not '/' when using powershell: (.\a.exe)
b - just call the executable when using the ancient dos terminal: (a.exe)
This question already has answers here:
Using a Single system() Call to Execute Multiple Commands in C
(3 answers)
Closed 8 years ago.
I want to do two steps in my c++ program using system().
open the folder system("cd /d ...")
run another program.exe
However, it seems like when I run step2, the folder opened in step1 is already closed.
What can I do to make sure that the folder won't be closed, so that I can use another cmd call to run .exe?
Thanks!
you can use
system("command1; command2; command3");
or
system("command1 && command2 && command3");
Refer To The following link:
Using a Single system() Call to Execute Multiple Commands in C
This question already has answers here:
How to use variables in a command in sed?
(4 answers)
Closed 8 years ago.
currently I have a file
that contains the text
Your path: ../test/tester [hello] whatever
But I want to change it to: Your path: ../../tested/text [hello] whatever
I've tried sed but I believe ../ is a special character so I'm not too sure how to approach this problem.
This won't work for me.
sed s/tester/..//g;s/tester/tested/text/
Does this solve your problem?
➜ scripts cat example
Your path: ../test/tester [hello] whatever
➜ scripts sed "s|../test/tester|../../tested/text|" example > example2
➜ scripts cat example2
Your path: ../../tested/text [hello] whatever
This question already has answers here:
MinGW error: No such file or directory exists [closed]
(3 answers)
Closed 8 years ago.
System:
g++ version: g++ (TDM-2 mingw32) 4.4.1
windows 7 32 bit
Env path: C:\Python33\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Dwimperl\perl\bin;C:\Dwimperl\perl\site\bin;C:\Dwimperl\c\bin;C:\Program Files\QuickTime\QTSystem\;C:\Cygwin\bin;C:\Program Files\CodeBlocks\MinGW\bin;
Error:
C:\Program Files\CodeBlocks\MinGW\bin>g++ -o first.exe D:\first.cpp
g++: CreateProcess: No such file or directory
I took look on similar questions on SO, but none of them have answers for me.
Per one suggestion, I added Mingw, path to env variable path, as seen above.
Update: First I never believed this, but this worked for me.
MinGW error: No such file or directory exists
This error is most likely caused by a problem with PATH. I suspect that in your case g++ tries to run some utility in PATH, but fails, because of error in PATH, or because wrong g++ is executed with given parameters. For example, you might have some tool in C:\Cygwin\bin.
If that helps anybody, my case for the error was invalid slash in PATH, which was set as:
set PATH=%PATH%;"E:\godot.src\.locally/mingw32\bin"
Replacing the last entry in PATH with the stuff below fixed that:
E:\godot.src\.locally\mingw32\bin