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.
Related
I'm new to programming so I feel there is something simple I'm missing here.
I'm using the latest version of Mac and I've just installed Code::Blocks along with Xcode so I can use the gcc compiler.
I created a new "console application" project and the code for a hello world program shows up.
I built this code and it gave me 0 errors and 0 warnings so I thought it was off to a good start.
But when I go to run this code all I get is the following in my Terminal window:
*/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
Ryan-McMullens-iMac:~ Ryan$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
sh: /Users/Ryan/Documents/C++: No such file or directory
Process returned 127 (0x7F) execution time : 0.003 s
Press ENTER to continue.*
I've checked to make sure its using the gcc compiler. I've also tried creating a C++ directory in my documents folder but that didn't help.
Like I said, I feel like I'm just missing a step somewhere so any help would be really appreciated!
Thanks!
Try avoiding using '+' and spaces in the name of directories.
Many program don't handle escaping of pathnames when running external tools like compiler, linker or when calling the final executable.
Remove spaces from your path. It seems that codeblocks does not quote the paths, so every space will be introducing a new command or parameter. The problem here is this part:
C++ book
because it has a whitespace.
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)
I'm getting a strange problem with my C/C++ dev environment. I had installed gcc, g++ on my linux box(ubuntu 14.04).
With the hello world program being built on my system I'm getting this error:
make all
/bin/sh: 1: Syntax error: Unterminated quoted string
make: *** [src/Banker's.o] Error 2
has anyone encountered to this problem before could help me with this?
It looks like your problem is in the name of the file you're trying to compile: Banker's.c. Rename the source to Bankers.c without the single quote in it.
mv src/"Banker's.c" src/"Bankers.c"
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.
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