Gnatmake compilation error after compiling .adb on Mac os - macos

I just installed the AdaCore community compiler the dwarvin version (gnat-community-2018-20180523-arm-elf-darwin-bin.dmg), with the GPS. Using the respective installer from adacore. I also managed to add on my starting script the path of gnat. Till here everything works fine, gnat --version return the appriate version etc.
But when I want to compile a .adb file using gnatmake filename.adb
user$ gnatmake filename.adb
gcc -c filename.adb
gcc: error trying to exec 'gnat1': execvp: No such file or directory
gnatmake: "filename.adb" compilation error
And even after using gnatmake -c filename.adb I get
gcc -c filname.adb
gcc: error trying to exec 'gnat1': execvp: No such file or directory
gnatmake: "filename.adb" compilation error
I asked my professor for help he said use the VM provided (for Windows) I just want to avoid using a VM. Please help me resolve this error.
After running the following command gnatmake filname.adb -cargs -c the following came up.
gcc -c -v filename.adb
Using built-in specs.
COLLECT_GCC=/opt/gps//bin/gcc
Target: x86_64-apple-darwin16.7.0
Configured with: ../src/configure --enable-languages=ada,c,c++,objc --enable-lto --with-stage1-ldflags=-static-libstdc++ --with-boot-ldflags=-static-libstdc++ --disable-libcilkrts --with-bugurl=URL:mailto:report#adacore.com --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch --disable-libada --enable-checking=release --disable-multilib --with-mpfr=/gnatmail/sandbox/community/x86_64-darwin/mpfr_stable-c/install --with-gmp=/gnatmail/sandbox/community/x86_64-darwin/gmp_stable-c/install --with-mpc=/gnatmail/sandbox/community/x86_64-darwin/mpc_stable-c/install --with-build-time-tools=/gnatmail/sandbox/community/x86_64-darwin/gcc_current-c/build/buildtools/bin --prefix=/gnatmail/sandbox/community/x86_64-darwin/gcc_current-c/pkg --build=x86_64-apple-darwin16.7.0
Thread model: posix
gcc version 7.3.1 20180524 (for GNAT Community 2018 20180523) (GCC)
COLLECT_GCC_OPTIONS='-gnatea' '-c' '-v' '-gnatez' '-mtune=core2' '-mmacosx-version-min=10.14.2'
gnat1 -quiet -dumpbase filename.adb -auxbase filename -gnatez -gnatea -gnatez -mtune=core2 -mmacosx-version-min=10.14.2 -fPIC filename.adb -o /var/folders/9r/52d5kqc906v4phl9jgjrxdlr0000gn/T//ccQlDd19.s
gcc: error trying to exec 'gnat1': execvp: No such file or directory
gnatmake: "filename.adb" compilation error

Now we can see how the compiler complains (thanks for the update in the question), it looks as though you have an installation problem.
Here, I get (edited down to remove the less significant parts)
[...]
COLLECT_GCC=/opt/gnat-ce-2018//bin/gcc
You have /opt/gps//bin/gcc, so your "prefix" (under which the installation is to be found) is /opt/gps, where mine is /opt/gnat-ce-2018 (I don’t know why there are two slashes there, doesn’t seem to matter). Then,
[...]
/opt/gnat-ce-2018/bin/../libexec/gcc/x86_64-apple-darwin16.7.0/7.3.1/gnat1 -quiet -dumpbase [...]
where you just have gnat1. So, you should have a file /opt/gps/libexec/gcc/x86_64-apple-darwin16.7.0/7.3.1/gnat1, and it should be executable.
I’d try reinstalling.

Related

Caffe compilation fails due to unsupported gcc compiler version

I struggle with Caffe compilation. Unfortunately I failed to compile it.
Steps I followed:
git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build
cd build
cmake ..
make all
Running make all fails with the following error message:
[ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o
In file included from /usr/include/cuda_runtime.h:59:0,
from <command-line>:0:
/usr/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.9 and up are not supported!
#error -- unsupported GNU version! gcc 4.9 and up are not supported!
^
CMake Error at cuda_compile_generated_im2col.cu.o.cmake:207 (message):
Error generating /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_im2col.cu.o
Software version:
OS: Debian.
gcc version: 5.3.1.
nvcc version: 6.5.12.
cat /proc/driver/nvidia/version result:
NVRM version: NVIDIA UNIX x86_64 Kernel Module 352.63 Sat Nov 7 21:25:42 PST 2015
GCC version: gcc version 4.8.5 (Debian 4.8.5-3)
Attempts to solve the problem
1st try
Simple solutions are often best ones, so (as suggested here) I tried to comment out macro checking gcc version from /usr/include/host_config.h (line 82). Unfortunately it doesn't work and compilation fails badly:
1 catastrophic error detected in the compilation of "/tmp/tmpxft_000069c2_00000000-4_im2col.cpp4.ii".
2nd try
I tried to run:
cmake -D CMAKE_CXX_COMPILER=g++-4.8 ..
make
but it fails with exactly the same error message (even though g++-4.8 should be accepted).
3rd try
I've found similar problem (though not related to Caffe) and I tried to solve it as suggested in the accepted answer.
What I did:
I've ran grep -iR "find_package(CUDA" caffe command and found Cuda.cmake file which has find_package(CUDA 5.5 QUIET) in line 225.
I added set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8) to Cuda.cmake, line before line: find_package(CUDA 5.5 QUIET).
I removed everything from build directory and ran cmake and make again - with and without -D CMAKE_CXX_COMPILER=g++-4.8.
Unfortunately result is exactly the same. Caffe probably overwrites it somehow - I didn't figure it out how.
make VERBOSE=1 2>&1 | grep -i compiler-bindir returns nothing.
What's interesting, make VERBOSE=1 prints command that fails, which is:
/usr/bin/nvcc -M -D__CUDACC__ /mydir/caffe/src/caffe/util/im2col.cu -o /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -DUSE_LMDB -DUSE_LEVELDB -DUSE_OPENCV -DWITH_PYTHON_LAYER -DGTEST_USE_OWN_TR1_TUPLE -Xcompiler ,\"-fPIC\",\"-Wall\",\"-Wno-sign-compare\",\"-Wno-uninitialized\",\"-O3\",\"-DNDEBUG\" -gencode arch=compute_20,code=sm_21 -Xcudafe --diag_suppress=cc_clobber_ignored -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=useless_using_declaration -Xcudafe --diag_suppress=set_but_not_used -Xcompiler -fPIC -DNVCC -I/usr/include -I/mydir/caffe/src -I/usr/include -I/mydir/caffe/build/include -I/usr/include/hdf5/serial -I/usr/include/opencv -I/usr/include/atlas -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/mydir/caffe/include -I/mydir/caffe/build
when I add --compiler-bindir /usr/bin/gcc-4.8 flag manually, it prints error:
nvcc fatal : redefinition of argument 'compiler-bindir'
which may be related to this bug report.
Edit: I didn't notice that --compiler-bindir and -ccbin are the same options, and the latter is already set in above command that failed. When I changed -ccbin /usr/bin/cc to -ccbin /usr/bin/gcc-4.8 in above command that failed, it completes successfully. Now I need to find option in Caffe's CMake file that overwrite -ccbin in all subsequent Caffe's CMakes. Looking at cmake/Cuda.cmake:252:list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA} seems to be good way to go.
How can I successfully complete my compilation? Any help is appreciated.
Related SO questions:
host_config.h:unsupported GNU version! gcc versions later than 4.9 are not supported.
CUDA 6.5 complains about not supporting gcc 4.9 - what to do?.
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. && make causes successful compilation.
Now another problem showed up: linking Google's libgflags or libprotobuf fails probably due to fact that it was compiled with newer gcc version but it's not related to asked question.
My machine runs Ubuntu 15.10, and my default compiler version is gcc 5.2.1 .
Commenting out the #error directive in line 115 of file
/usr/local/cuda-7.5/include/host_config.h
(or whatever the path on your system is) did the trick for me. Caffe compiled fine, all tests ran smoothly.
On the other hand, if one chooses to ignore this and proceed to compile part of the project with one compiler version, part of the project with another (for me it was gcc-4.8 and gcc-5.2.1), linking problems will arise. The linking problems of protobuf and libgflags another answer mentions are not unrelated to this.

cmake error using the mingw-w64-x86_64 gcc toolchain under Windows 7 : "this program has been built without plugin support"

I have a setup with Windows 7, MSYS2, Mingw-w64-x86_64 gcc toolchain, CMake, and I am trying to build the nanomsg library.
Here is what I obtain :
$ cmake --debug-trycompile
-DCMAKE_TOOLCHAIN_FILE=../toolchain_i686-pc-mingw32.cmake -DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32 -G "MinGW Makefiles" ../nanomsg
debug trycompile on
-- The C compiler identification is GNU 4.8.2
-- Check for working C compiler: C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe
-- Check for working C compiler: C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe -- broken CMake Error at
C:/cmake-win32-x86/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61
(message): The C compiler
"C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe" is not able to compile a
simple test program.
It fails with the following output:
Change Dir:
C:/msys64/home/Laurent/Dev/nanomsg-build/CMakeFiles/CMakeTmp
Run Build Command:C:/mingw64/bin/mingw32-make.exe
"cmTryCompileExec910276652/fast"
C:/mingw64/bin/mingw32-make.exe -f
CMakeFiles\cmTryCompileExec910276652.dir\build.make
CMakeFiles/cmTryCompileExec910276652.dir/build
mingw32-make.exe1: Entering directory
'C:/msys64/home/Laurent/Dev/nanomsg-build/CMakeFiles/CMakeTmp'
C:\cmake-win32-x86\bin\cmake.exe -E cmake_progress_report
C:\msys64\home\Laurent\Dev\nanomsg-build\CMakeFiles\CMakeTmp\CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec910276652.dir/testCCompiler.c.obj
C:\mingw64\bin\x86_64-w64-mingw32-gcc.exe -o
CMakeFiles\cmTryCompileExec910276652.dir\testCCompiler.c.obj -c
C:\msys64\home\Laurent\Dev\nanomsg-build\CMakeFiles\CMakeTmp\testCCompiler.c
Linking C executable cmTryCompileExec910276652.exe
C:\cmake-win32-x86\bin\cmake.exe -E cmake_link_script
CMakeFiles\cmTryCompileExec910276652.dir\link.txt --verbose=1
C:\cmake-win32-x86\bin\cmake.exe -E remove -f
CMakeFiles\cmTryCompileExec910276652.dir/objects.a
x86_64-w64-mingw32-gcc-ar cr
CMakeFiles\cmTryCompileExec910276652.dir/objects.a
#CMakeFiles\cmTryCompileExec910276652.dir\objects1.rsp
sorry - this program has been built without plugin support
CMakeFiles\cmTryCompileExec910276652.dir\build.make:91: recipe for
target 'cmTryCompileExec910276652.exe' failed
mingw32-make.exe1: * [cmTryCompileExec910276652.exe] Error 1
mingw32-make.exe1: Leaving directory
'C:/msys64/home/Laurent/Dev/nanomsg-build/CMakeFiles/CMakeTmp'
Makefile:116: recipe for target 'cmTryCompileExec910276652/fast'
failed
mingw32-make.exe: * [cmTryCompileExec910276652/fast] Error 2
CMake will not be able to correctly generate this project. Call
Stack (most recent call first): CMakeLists.txt:29 (project)
Here is my toolchain file:
$ cat ../toolchain_i686-pc-mingw32.cmake
# http://www.cmake.org/Wiki/CMake_Cross_Compiling#The_toolchain_file
# http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=8959
# http://stackoverflow.com/questions/19754316/cross-compiling-opencv-with-mingw-using-cmakein-linux-for-windows
# this one is important
SET(CMAKE_SYSTEM_NAME Windows)
#this one not so much
#SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(PREFIX x86_64-w64-mingw32)
SET(CMAKE_MAKE_PROGRAM mingw32-make)
SET(CMAKE_C_COMPILER ${PREFIX}-gcc)
SET(CMAKE_CXX_COMPILER ${PREFIX}-g++)
SET(CMAKE_AR ${PREFIX}-gcc-ar)
SET(CMAKE_NM ${PREFIX}-gcc-nm)
SET(CMAKE_RC_COMPILER windres)
# specify the cross linker
SET(CMAKE_RANLIB ${PREFIX}-gcc-ranlib)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /opt/mingw64 /usr/${PREFIX})
# search for programs in the build host directories
#SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
#SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
It looks like it fails to build on an auto test because the toolchain misses plugin support.
Here is my gcc version and options:
$ /opt/mingw64/bin/x86_64-w64-mingw32-gcc.exe -v
Using built-in specs.
COLLECT_GCC=C:\mingw64\bin\x86_64-w64-mingw32-gcc.exe
COLLECT_LTO_WRAPPER=C:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.8.2/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw482/x86_64-482-posix-seh-rt_v3-rev3/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-cloog=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x86_64-posix-seh-rev3, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw482/x86_64-482-posix-seh-rt_v3-rev3/mingw64/opt/include -I/c/mingw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw482/x86_64-482-posix-seh-rt_v3-rev3/mingw64/opt/include -I/c/mingw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw482/x86_64-482-posix-seh-rt_v3-rev3/mingw64/opt/lib -L/c/mingw482/prerequisites/x86_64-zlib-static/lib -L/c/mingw482/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 4.8.2 (x86_64-posix-seh-rev3, Built by MinGW-W64 project)
Is it related to the "--enable-plugin" option (missing in my gcc) ?
Is there somewhere a toolchain build available with this option set ? I looked for it in MSYS2, Mingw-w64, rubenvb repositories, but it is not there. Or shall I build it myself ?
Possibly nanomsg does not need it ? Does the autotest requires it because nanomsg needs it ? Or can I prevent this autotest from being run ? Or can I set something to avoid the need of the "--enable-plugins" option ?
I think you are using the MSYS2 shell here, and not MSYS2 itself. If you were using an up to date MSYS2 then you'd be using the following mingw-w64 x86_64 GCC:
$ pacman -Ss mingw-w64-x86_64-gcc
mingw64/mingw-w64-x86_64-gcc 4.9.1-6
$ PATH=/mingw64/bin:$PATH gcc -v
Configured with: ... --enable-lto ...
--enable-lto implies --enable-plugins which is the default now and so doesn't appear in the list.
To build nanomsg with MSYS2, install https://master-dl.sourceforge.net/project/msys2/Base/x86_64/msys2-x86_64-20141003.exe, untick "Run MSYS2 shell now" (you want a mingw-w64 shell instead). Run the mingw-w64 shell (Start->MSYS2 64Bit->MinGW-w64 Win64 Shell). From within that shell:
$ pacman -S git make mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc
$ git clone https://github.com/nanomsg/nanomsg.git
$ mkdir nanomsg-build
$ cd nanomsg-build
$ cmake --debug-trycompile -DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32 -G "MSYS Makefiles" ../nanomsg
$ make install
But if you are a developer, we'd appreciate the contribution of a PKGBUILD for nanomsg

Issue linking g++-4.8 Mac OSX 10.8

I downloaded gcc v4.8 from homebrew so that I could update gcc and g++ to 4.8 instead of using the 4.2.1 supplied from apple.
I installed gcc48 with the following command:
$brew install gcc48 --enable-all-languages
This installed all the required dependancies and when I run,
$gcc-4.8 -v
I get:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc48/4.8.1/gcc/libexec/gcc/x86_64-apple-darwin12.4.0/4.8.1/lto-wrapper
Target: x86_64-apple-darwin12.4.0
Configured with: ../configure --build=x86_64-apple-darwin12.4.0 --prefix=/usr/local/Cellar/gcc48/4.8.1/gcc --datarootdir=/usr/local/Cellar/gcc48/4.8.1/share --bindir=/usr/local/Cellar/gcc48/4.8.1/bin --enable-languages=c,c++,fortran,java,objc,obj-c++ --program-suffix=-4.8 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-plugin --enable-lto --disable-werror --disable-nls --with-ecj-jar=/usr/local/opt/ecj/share/java/ecj.jar --disable-multilib
Thread model: posix
gcc version 4.8.1 (GCC)
I created the symbolic link using
$ln -s gcc-4.8 gcc
while in the /usr/local/bin folder and it created the symbolic link and
$gcc -v
gives me the same output as:
$gcc-4.8 -v
I tried doing the same thing with g++-4.8 and created a symbolic link using,
$ln -s g++-4.8 g++
and got no errors. But now, when I do
$g++ -v
I get:
g++-4.8: error trying to exec '/usr/local/bin/../Cellar/gcc48/4.8.1/bin/i686-apple-darwin11-llvm-g++-4.2': execvp: No such file or directory
Here's my $PATH:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin:/Developer/Intel/ispc-v1.3.0-osx:/Developer/NVIDIA/CUDA-5.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
It seems to be looking for 4.2 for some reason and I have no idea why! It worked perfectly fine for gcc and am just not sure what is the problem with g++?
which g++
returns
/usr/local/bin/g++
Try running:
$ hash
And check if gcc is in the list. If it is you may need to run:
$ hash -r
If you use bash or:
$ rehash
For zsh. This refreshes the hash, which provides a way for the shell to find the command without rechecking the entire path each time.
Looks to me that your g++ symbolic link points to the wrong thing.
Try:
ls -l `which g++`
And if that looks OK, see if the target is not a symbolic link too, etc..
Be mindful that symbol links use relative paths. If you move a symbolic link around, it doesn't point to the same location anymore.
Hope that helps.

gfortran: error trying to exec 'f951': execvp: No such file or directory

I'm trying to compile a code found on the internet. Actually I'm trying to compile the code found at http://www.cs.berkeley.edu/~fowlkes/BSE/.
I tried to install gfortran and all the other libraries that are needed for compiling it in my MAC. But when I run the command make I get the following error:
$ make
(cd trlan && make -f Makefile.gcc)
gfortran -O3 -ffixed-line-length-132 -c dsort2.f
gfortran: error trying to exec 'f951': execvp: No such file or directory
make[1]: *** [dsort2.o] Error 1
make: *** [trlan/libtrlan.a] Error 2
I believed that the error is related to the version of my c++ compiler, that is not compatible with gfortran.
When I run the command gcc --version:
$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
And when I run the command gfortran --version:
$ gfortran --version
GNU Fortran (GCC) 4.8.0 20120930 (experimental)
The Makefile under the directory that I'm running the command make is here: https://www.dropbox.com/s/q7mxvhnqg62ioum/Makefile.gcc
The Makefile under the directory trlan is here: https://www.dropbox.com/s/jydwpkg3f1upbgf/Makefile.gcc
Anyone has an idea of how to solve this problem or how to find tools that can help me solve it?
I'm trying this:
http://eftrunk.blogspot.com/2011/11/how-to-fix-error-trying-to-exec-f951.html
The simplest solution I found (perhaps not cleanest), is to statically link f951 in the path to the binary of gfortran:
find /usr/local/ -name f951
which for me returned:
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin11/4.6.2/f951
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.1.0/f951
so I put a link to the one that fits my system most closely in /usr/local/bin:
sudo ln -s /usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.1.0/f951 /usr/local/bin/.
And now gfortran works again. No need to uninstall XCode or any other exaggerated workload.
The answer can be found in the following website:
http://eftrunk.blogspot.com/2011/11/how-to-fix-error-trying-to-exec-f951.html
Basically it's necessary to delete Xcode, reinstall gcc and gfortran using http://hpc.sourceforge.net/ and then reinstall Xcode.

GCC warning "incompatible implicit declaration of built-in function ‘printf’" under Mac OS X Snow Leopard

After a very long time away from C programming, I've decided to try and get familiar with it again. I am trying to compile a hello.c program but am having problems. Here's the code:
#include <stdio.h>
main()
{
printf("Hello\n");
}
And here's the output from gcc:
$ gcc -o hello hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
$
I am working on a Mac running Snow Leopard (10.6.8) and Xcode 3.2.6.
Here's the 'gcc -v' output:
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
$
gcc is not able to find stdio.h which is located in /Developer/SDKs/MacOSX10.6.sdk/usr/include. Wondering about how to set an environment variable so I don't have to specify the include path on the command line. I get another error when I specify it on the command line:
$ gcc -I/Developer/SDKs/MacOSX10.6.sdk/usr/include -o hello hello.c
ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status
$
My LD_LIBRARY_PATH environment variable is:
$ echo $LD_LIBRARY_PATH
/Developer/SDKs/MacOSX10.6.sdk/usr/lib
$
Any help is appreciated.
Thanks,
Keith
You need to re-run the Xcode installer and check the option for UNIX Development:
Without this option you can still use Xcode but you will not get /usr/include etc for gcc command-line builds.
You already have an answer for your particular problem, but I have seen this problem on OS X for a different reason, so this may be helpful to other people.
If you have tried installing a custom compiled version of GCC and it is in /usr/local/bin or you have added a PATH entry to /opt/sw or something similar, you can get this error.
Possible reasons for having the custom GCC but no headers are:
You tried to remove the custom compiled version but forgot to delete the gcc binary.
You used the wrong configure options when building the custom GCC.
You installed the header files to the wrong directory. (Very similar to the last option.)

Resources