when i was trying to run my c++ program with these 2 command:
g++ subtitle_modifier.cpp -o subtitle_modifier
subtitle_modifier subtitle.srt 3000
I got some error:
zsh: command not found: subtitle_modifier
How can i solve this problem?
Prefix your binary with ./ such as ./subtitle_modifier to invoke it from the current directory. Only writing the name assumes it is present in path, which in your case is not true.
Related
I have created a file, 1.sh, as
c++ -c file1.cpp
c++ file1.o -o file1
And I tried to execute it on bash Ubuntu on windows. It tells me
: No such file or directory
c++: fatal error: no input files
compilation terminated.
However, if I execute
c++ -c file1.cpp
c++ file1.o -o file1
directly, the file (file1.cpp) can be complied normally.
My question is, what is the reason .sh file does not work and how to fix it?
Actually, I would like to write this as comment but there is not this formatting available. (I will delete this answer when it becomes obsolete.)
I just tried this (with g++ on cygwin's bash):
$ g++ -c nothing.cc
g++: error: nothing.cc: No such file or directory
g++: fatal error: no input files
compilation terminated.
$
Of course, where is no file nothing.cc in my current working directory...
So, it might be that my guess (C++ is running in the wrong working directory when started from shell script) might be reasonable...
As I already suggested: insert a
echo "$PWD"
at the beginning of your shell script to be sure.
Update:
Out of curiosity, I tried this also (cygwin, bash again):
$ c++ -c nothing.cc
c++: error: nothing.cc: No such file or directory
c++: fatal error: no input files
compilation terminated.
$
Now, it looks very similar to the OP.
The only fact that's puzzling me: The error message of the OP looks like whether the compiler didn't get any input:
$ c++
c++: fatal error: no input files
compilation terminated.
$
but I believe that's not the case because in the OP it starts with
: No such file or directory.
Thus, it rather looks like there is missing some text...
I see that same question has been asked many times but my problem is different.
I installed gcc on ubuntu 14.04 and and it works fine with root user.
When I attempt to compile using non-root user it throws
error gcc: error trying to exec 'cc1': execvp: No such file or
directory
Once I compile the file with root user, non-root user is able to execute the file without any error but it is not able to compile the file.
I suspect there is a problem with file permissions and I have checked permissions for cc1 and non root user had execute permission on the file.
First way:
Under the root account use the command:
which gcc
which cc1
ls -l $Output of previous command
It will show you where are cc1 and gcc and rights of cc1
Check that you have proper rights for cc1 file
Then under "regular" user:
which gcc
Output of which gcc should be the same as for root.
If right is ok and path to gcc the same as under the root, add PATH to cc1 for user.
Second way:
Under the root account:
gcc -v hello_world.c 2>&1 | grep cc1
And do the same under the "regular" account.
It will show you the real commands that was used for compilation.
Compare them and check rights and PATH as in first way
To add PATH use: export PATH=$PATH:$add_new_path_to_folder_here
In my case, this error was occurring while attempting to compile an updated version of ffi, nokogiri and other gems on Ubuntu. gcc -v revealed I was using gcc and g++ 4.8.
The fix was to switch my gcc/g++ symlinks to use 4.9 instead of 4.8.
$ which gcc
$ ls -ld /usr/local/bin/gcc
$ sudo rm /usr/local/bin/gcc
$ sudo ln -s /usr/bin/gcc-4.9 /usr/local/bin/gcc
$ ls -ld /usr/local/bin/gcc
Repeat for g++.
I've come across a weirdest problem I ever met. I'm cross-compiling an app for ARM CPU with Linux on-board. I'm using buildroot, and all goes well until I'm trying to run the application on the target: I'm getting -sh: ./hw: not found. E.g.:
$ cat /tmp/test.cpp
#include <cstdio>
#include <vector>
int main(int argc, char** argv){
printf("Hello Kitty!\n");
return 0;
}
$ ./arm-linux-g++ -march=armv7-a /tmp/test.cpp -o /tftpboot/hw
load the executable to the target; then issuing on the target:
# ./hw
-sh: ./hw: Permission denied
# chmod +x ./hw
# ./hw
-sh: ./hw: not found
# ls -l ./hw
-rwxr-xr-x 1 root root 6103 Jan 1 03:40 ./hw
There's more to it: upon building with distro compiler, like arm-linux-gnueabi-g++ -march=armv7-a /tmp/test.cpp -o /tftpboot/hw, the app runs fine!
I compared executables through readelf -a -W /tftpboot/hw, but didn't notice much defference. I pasted both outputs here. The only thing I noticed, are lines Version5 EABI, soft-float ABI vs Version5 EABI. I tried removing the difference by passing either of -mfloat-abi=softfp and -mfloat-abi=soft, but compiler seems to ignore it. I suppose though, this doesn't really matter, as compiler doesn't even warn.
I also thought, perhaps sh outputs this error if an executable is incompatible in some way. But on my host PC I see another error in this case, e.g.:
$ sh /tftpboot/hw
/tftpboot/hw: 1: /tftpboot/hw: Syntax error: word unexpected (expecting ")")
sh prints this weird error because it is trying to run your program as a shell script!
Your error ./hw: not found is probably caused by the dynamic linker (AKA ELF interpreter) not being found. Try compiling it as a static program with -static or running it with your dynamic loader: # /lib/ld-linux.so.2 ./hw or something like that.
If the problem is that the dynamic loader is named differently in your tool-chain and in your runtime environment you can fix it:
In the runtime environment: with a symbolic link.
In the tool-chain: use -Wl,--dynamic-linker=/lib/ld-linux.so.2
I'm currently running ubuntu 13.10 with codeblocks and when I try to build it comes up with this message:
g++ -c /home/rhys/Documents/Progamming/c++/Class_private/main.cpp -o /home/rhys/Documents/Progamming/c++/Class_private/main.o
/bin/sh: 0: Can't open g++ -c /home/rhys/Documents/Progamming/c++/Class_private/main.cpp -o /home/rhys/Documents/Progamming /c++/Class_private/main.o
Process terminated with status 127 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
It used to work fine but it does not work now, I have downloaded the build-essential, then the gcc complier which it is set to in the settings.
Can anyone help??
check "Settings -> Environment -> General settings -> Shell to run commands in:" and make sure it says "/bin/sh -c" you must have the -c argument. Either this or it could a file path problem with the compiler or source files themselves.
I think you must set the access for your files and/or your whole working directory. So go there, and change permission with chmod:
cd /home/rhys/Documents/Progamming/c++/Class_private/
chmod 755 *
If this not works maybe you should check if g++ is accessible. Run:
g++ --version
See if it prints the information or another error.
Another solution could be to open Code::Blocks as a superuser and then try again as you normally did.
Installed Ocaml on my cygwin machine but simple compiles fail. Permissions are fine as you can see by the interaction below. OCAMLLIB is right; What is wrong?
$ cat t.ml
print_string "hi";
$ ocamlopt t.ml
>> Fatal error: cannot open pervasives.cmi
Fatal error: exception Misc.Fatal_error
$ echo $OCAMLLIB
/cygdrive/c/OCaml/lib
$ ls -l /cygdrive/c/OCaml/lib/pervasives.cmi
-rwxrwxrwx+ 1 Lyn None 15094 Oct 8 01:30 /cygdrive/c/OCaml/lib/pervasives.cmi
A possible solution is to run this command in cygwin:
export OCAMLLIB=C:\\OCaml\\lib
The clue came from this message thread.