gcc command not found even though it is there - xcode

I downloaded Xcode and the command line tools. When I go to the directory "/usr/bin" and enter "ls" in my terminal, I can see gcc listed among the files and directories. However, when I run the command gcc in this directory, I get a message saying: "-bash: gcc: command not found". Why does it say the command can't be found when I can clearly see it listed among the files in my /usr/bin directory?

Related

MinGW cc1plus.exe fatal error (file exists)

I recently installed a new SSD on my machine, and when I did a clean install of windows I got Visual Studio Code, and was about to get the c++ extension up and running, so I got MinGW, and tried to install the GCC and G++ compilers... And low and behold, after trying a lot of solutions, it is still not working properly on this computer image.
When I try to test the compiler after I got MinGW installed properly, this is what it output:
gcc.exe -Wp,-v -E -xc -dD -x c++ nul
ignoring nonexistent directory
"c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../mingw32/include"
ignoring duplicate directory
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++"
ignoring duplicate directory
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++/mingw32"
ignoring duplicate directory
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++/backward"
ignoring duplicate directory
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include"
ignoring duplicate directory
"/mingw/lib/gcc/mingw32/6.3.0/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include-fixed"
ignoring nonexistent directory
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include-fixed
End of search list.
cc1plus.exe: fatal error: nul: No such file or directory
compilation terminated.
Error: 1
The odd part is that the cc1plus.exe is in the MinGW directory, and I even added it to the include path later to see if that would help, and still nothing. I'm not quite sure how to proceed.
This bug has become the bane of my existence for the last week. If anyone has any ideas I'd really appreciate the help. I've had success with MinGW in the past, but for some reason it's giving me problems this time.
Your commandline is:
gcc.exe -Wp,-v -E -xc -dD -x c++ nul
The error:
cc1plus.exe: fatal error: nul: No such file or directory
is the C++ compiler (cc1plus.exe) telling you that the input file nul
does not exist. That will be because there is no file called nul in the current directory.
The Windows CMD NUL device is a virtual device to which the output of a command may be
redirected ( command >NUL) to throw it away. It is not a file.
If you want to test that the compiler can be successfully invoked with this commandline,
then write a program such as:
main.cpp
int main()
{
return 0;
}
Save it in the current directory and run:
gcc.exe -Wp,-v -E -xc -dD -x c++ main.cpp
Close your IDE and go your program folder and open folder with your IDE. Then run and check to see if your problem is solved.

Cygwin program compiled but not runnable

I just installed CD-HIT and followed these instructions:
Installation
Most CD-HIT programs were written in C++. Installing CD-HIT package is very simple:
download current CD-HIT at http://bioinformatics.org/cd-hit, for example cd-hit-2006-0215.tar.gz
unpack the file with ” tar xvf cd-hit-2006-0215.tar.gz --gunzip”
change dir by “cd cd-hit-2006”
compile the programs by “make”
you will have all cd-hit programs compiled
I followed these steps and indeed .exe files were made:
cdhit.c++ cdhit-est-2d.c++ clstr_select_rep.pl
cd-hit.exe cd-hit-est-2d.exe clstr_size_histogram.pl
cdhit.o cdhit-est-2d.o clstr_size_stat.pl
cdhit-2d.c++ cd-hit-para.pl clstr_sort_by.pl
cd-hit-2d.exe cdhit-utility.c++ clstr_sort_prot_by.pl
cdhit-2d.o cdhit-utility.h clstr_sql_tbl.pl
cd-hit-2d-para.pl cdhit-utility.o clstr_sql_tbl_sort.pl
cdhit-454.c++ ChangeLog clstr2tree.pl
cd-hit-454.exe clstr_cut.pl clstr2txt.pl
cdhit-454.o clstr_list.pl clstr2xml.pl
cd-hit-auxtools clstr_list_sort.pl doc
cdhit-common.c++ clstr_merge.pl FET.pl
cdhit-common.h clstr_merge_noorder.pl license.txt
cdhit-common.o clstr_quality_eval.pl make_multi_seq.pl
cdhit-div.c++ clstr_quality_eval_by_link.pl Makefile
cd-hit-div.exe clstr_reduce.pl plot_2d.pl
cdhit-div.o clstr_renumber.pl plot_len1.pl
cd-hit-div.pl clstr_rep.pl psi-cd-hit
cdhit-est.c++ clstr_reps_faa_rev.pl README
cd-hit-est.exe clstr_rev.pl usecases
cdhit-est.o clstr_select.pl
However when I typ: cd-hit-est in the cygwin command line, it will say: -bash: cd-hit.exe: command not found. I'm not able to figure out why this is happening. Even when I'm in the folder were the .exe files are located it still will give the same error.
When you try to run command without a path, bash tries to find the command name in each directory from the PATH environment variable.
Usually current directory "." is not in the PATH so you have to run command adding absolute or relative path before command name:
./cd-hit.exe
or
/absolute/path/to/your/cd-hit/program/cd-hit.exe
If you want to permanently run command cd-hit.exe from anywhere, just add the directory where cd-hit was compiled to any existing auto-loaded bash profile files:
.profile
.bashrc
.bash_profile
like
PATH=$PATH:/absolute/path/to/your/cd-hit/program
export PATH

Error fatal - No such file or directory

I have installed the cds library with command ./build.sh -b 64 -z '-std=c++0x' -l '-L /usr/lib/x86_64-linux-gnu' --with-boost /usr/include/boost --amd64-use-128bit at build folder.
After I tried to compile the example init.cpp of src folder, I typed this in terminal: g++ init.cpp -o init, and terminal showed: fatal error: cds/init.h: No such file or directory.
What should I do for compilation command in this case?
Thanks.
For general troubleshooting in cases like this, i would recommend finding where on the system the file got installed (if your build.sh actually installed the file). You would be able to find the missing header file using
find / -path '*/cds/init.h' 2>/dev/null
Then you need to supply two parameters to g++:
First one gets the compiler to know about the include files from the install directory
-I path_to_folder_one_step_above_cds_folder
Second one gets the linker to know about the librarys location. If the library file is called libcds.so, you can find it by running
find / -name libcds.so 2>/dev/null
So for linking, you supply the flag
-L path_to_folder_one_step_above_libcds.so
In your case you might not need the -L flag, since most of your library supposedly is header only.
UPDATE: the build.sh script is printing out important information at the top, starting with "Building with the following options:". The important bits will be "Compile options:" and "Link options:". Those should be enough to solve your specific option.
UPDATE2: build.sh also exports some flags which might include more options. You can print them out directly after running build.sh by running
echo LDFLAGS=$LDFLAGS
echo CFLAGS=$CFLAGS
echo CXXFLAGS=$CXXFLAGS
you are likely to need to pass all these options to g++ when compiling and linking against that library. LDFLAGS are specific to the linker only. Both the other ones are needed for compiling c++ files.

How to get NDK toolchain utilities to list symbols (function names) of NDK-built library on Mac OS X?

I have a couple of libraries built by the NDK for which I am trying to view the exported symbols, the available function names to be precise. One is a .so file and the other a .a file. I was helped in this question (How to obtain readelf and objdump binaries for OS X?) to find the utilities that I think I need. They are specific to the NDK installation. I am on OS X fyi.
In my NDK installation I found nm and objdump in prebuilt/darwin-x86_64/arm-linux-androideabi/bin. Their file type is "Alias". When I ran nm -g libMylib.so nothing happened -- at all. When I ran objdump -TC libMylib.so I got: "objdump: command not found". Then I found the arm-linux-androideabi-nm and arm-linux-androideabi-objdump files (file type listed as "Unix Executable File" in Finder) in the prebuilt/darwin-x86_64/bin dir. The attempt to use both of them resulted in "command not found". In all these attempts I placed libMylib.so right in the very folder with the utility I'm trying to run.
I think this is basically a general issue about how to call binaries in unix; even if you are in the same directory when you run nm -g libMylib.so, since . normally isn't part of your $PATH. To run the right one, do ./nm -g libMylib.so, or without using cd to enter this directory first, just do path/to/your/NDK/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-nm -g libMylib.so, or add this directory to your path first:
export PATH=path/to/your/NDK/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin:$PATH
arm-linux-androideabi-nm -g libMylib.so
(It's preferrable to add this directory to the path instead of the arm-linux-androideabi directory, since it is clear which tool you want to invoke when you call when you do arm-linux-androideabi-nm, while if you add the other directory and call nm, it is up to the order of the directories in $PATH.)
See e.g. Why do you need ./ (dot-slash) before script name to run it in bash? for more explanations about $PATH.

mac command line command not found

Ok so I've been trying to run some things from the command line and I'm having a 'permission denied' problem and then when I 'sudo ./(file.c' I get a 'command not found'. It's weird because other .c files in the same directory work ok.
I've downloaded and installed Xcode and command line tools. Also, I have #include some other things that are also in the same directory.
When I echo $PATH I'm getting this output:
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Thanks for any help that could be provided!
You're running sudo ./file.c but file.c looks like the name of a source code file which would usually not be executable. Probably the problem you're having is that you're trying to run something which cannot be run. If you really want to force the computer to run it, you can do chmod +x file.c before trying to run it. But if it is indeed C source code, it won't do anything useful.

Resources