GCC not found when running from script - macos

I am trying to make a script to get and compile nginx on OS X. When I run ./configure --prefix=. from terminal I get what you would expect, but when I put it into a bash script, I get:
checking for OS
+ Darwin 13.0.0 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
make: *** No rule to make target `build', needed by `default'. Stop.
Any ideas about what would cause GCC to go missing?

Check the full path of cc (execute which cc).
Extend the path in your script (for example PATH=$PATH:/usr/bin)

Related

CMake: The C Compiler is not able to compile a simple test program

I am trying to cross-compile the Azure IoT SDK C for a Mips processor. Cross-compiling an older version of the same SDK using an older version of CMake (2.8.12.2) works just fine, so I doubt it's the code itself. I am guessing it's the Mips GCC compiler.
Error message:
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_2cc84/fast"
/usr/bin/make -f CMakeFiles/cmTC_2cc84.dir/build.make CMakeFiles/cmTC_2cc84.dir/build
make[1]: Entering directory '/home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_2cc84.dir/testCCompiler.c.o
/usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc --sysroot=/usr/local/mipsisa32r2el/r23 -o CMakeFiles/cmTC_2cc84.dir/testCCompiler.c.o -c /home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_2cc84
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2cc84.dir/link.txt --verbose=1
/usr/local/mipsisa32r2el/r23/bin/mipsisa32r2el-axis-linux-gnu-gcc --sysroot=/usr/local/mipsisa32r2el/r23 -rdynamic CMakeFiles/cmTC_2cc84.dir/testCCompiler.c.o -o cmTC_2cc84
/usr/local/mipsisa32r2el/r23/lib/gcc/mipsisa32r2el-axis-linux-gnu/4.7.2/../../../../mipsisa32r2el-axis-linux-gnu/bin/ld: this linker was not configured to use sysroots
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_2cc84.dir/build.make:97: recipe for target 'cmTC_2cc84' failed
make[1]: *** [cmTC_2cc84] Error 1
make[1]: Leaving directory '/home/axis/azure-iot-sdk-c/cmake/iotsdk_linux/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_2cc84/fast' failed
make: *** [cmTC_2cc84/fast] Error 2
Unfortunately, I am stuck with the Mips GCC compiler I have. Is there a way to disable this test-program check?
Solution was to add these to the toolchain-file:
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)
CMake tries to compile an executable using "standard" (as per what CMake thinks is standard) compiler options and tries to run that executable, so to see if the compiler is working. The executable is simple like int main(int argc, char *argv[]) { return argc - 1; }.
You can't do that when cross-compiling. Because usually you can't link with a proper C standard library, you don't have printf, or _start or _exit or similar, passing arguments to main is implementation-defined, or you need a special linker script, or there's no emulator for your architecture, so can't run cross-compiled source on the host, etc... Simply: you usually can't run the cross-compiled executable on the host, and most of the time even the compilation is hard enough to do.
The common solution is to set before project():
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
So that CMake will try to compile a static library not an executable, as explained in cmake docs CMAKE_TRY_COMPILE_TARGET_TYPE. This avoids running the linker and is intended for cross-compiling.
You can set CMAKE_C_COMPILER_WORKS and it will omit the check in CMakeTestCCompiler.cmake, but CMAKE_TRY_COMPILE_TARGET_TYPE is a more proper solution.
Well this problem is really annoying, i faced this issue for 2 day now I got solution.
Let me explain my issue first
When I delete NDK and Cmake from Sdk folder and Run my application then grable install NDK and Cmake again.
Only that time Application run and when try to run again i get this error The C Compiler is not able to compile a simple test program.
Before i was using ndkVersion "22.0.7026061" then change to thisndkVersion "21.1.6352462" and IT WORKED.
I think this is NDK problem and most of answer are outdated try this i hope this will HELP.
If using CMake GUI, you can add a boolean entry named
CMAKE_CXX_COMPILER_FORCED
then set it to True.
This will skip checking process for this build.
Ran into the same problem while re-compiling a project. Turned out that the compiler had been updated in the meantime.
After removing the build directory and creating it again, the compilation completed without errors.

Cross-compilation of Mali driver fails

I'm trying to cross-compile Mali DX910-SW-99002-r7p0-00rel0 Driver in my Linux x86 (Ubuntu) machine for an ARM64 machine linux kernel version 4.4.83.
I followed the instructions given in the readme file:
DX910-SW-99002-r7p0-00rel0/driver/src/devicedrv/ump/readme.txt
select Mali as a module (M) within the menuconfig:
CONFIG_MALI400=m
CONFIG_MALI450=y
KDIR=~/linux-4.4.83 USING_UMP=1 BUILD=debug make
cannot find bingcc
KDIR=./linux-4.4.83 CONFIG=default BUILD=debug make
cannot find bingcc
My question is:
The two compile commands (items 2. and 3. above) both yield the same failure result as the following:
KDIR=~/linux-4.4.83 USING_UMP=1 BUILD=debug make
make: gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/aarch64-linux- gnu/bingcc: Command not found
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CC kernel/bounds.s
/bin/sh: 1: gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/bingcc: not found
Kbuild:44: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 127
Makefile:1007: recipe for target 'prepare0' failed
What should be done to fix these?
If you want to use GNU C compiler from gcc-aarch64-linux-gnu Ubuntu package, then you'd better make sure that the package is indeed installed and then specify one more option to make, in example:
KDIR=~/linux-4.4.83 USING_UMP=1 BUILD=debug ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make.
However, I see linaro mentioned in your output. So, alternatively, you may consider following this guide on toolchain setup and usage.

Wayland cross compiling makefile error

I am trying to cross compile wayland for an arm-linux platform. During the make, I am getting following error..
CC src/scanner.o
CC src/connection.lo
CC src/wayland-util.lo
CC src/wayland-os.lo
CCLD libwayland-util.la
CCLD wayland-scanner
GEN protocol/wayland-server-protocol.h
/bin/sh: ./wayland-scanner: cannot execute binary file
make: *** [protocol/wayland-server-protocol.h] Error 126
If you can install the Wayland package on the build system that comes with the native wayland-scanner binary (e.g., libwayland-bin on Debian/Ubuntu, wayland-dev on Alpine Linux, wayland on Arch Linux), in the latest version of Wayland (currently 1.17.0) you can use the option --with-host-scanner to ./configure:
./configure --host=${target} --with-host-scanner
You need to invoke the disable-scanner option at the autogen stage.
./autogen.sh --disable-scanner --build=arm-linux --host=arm-none-linux-gnueabi --prefix=$WLD

compiling z3 4.1 on OS X to use Boogie

I'm trying to install Boogie (22 Oct 2012 version) on Mac OS X 10.8. I downloaded the Boogie from here, and installed Mono 3.4.0. Boogie without the verify option worked fine for me.
Next, I needed to install Z3. I tried the nightly OS X build because I thought that would be simplest, but Boogie gave a lot of errors along the lines of:
Prover error: line 5 column 22: the parameter 'model_v2' was renamed to 'model.v2', invoke 'z3 -p' to obtain the new parameter list, and 'z3 -pp:model.v2' for the full description of the parameter
So I tried to download the source for Z3 version 4.1 and compile it. I ran autoconf, and configure without any problems, but make had many errors:
$ autoconf
$ ./configure
checking for dos2unix... /usr/local/bin/dos2unix
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether make sets $(MAKE)... yes
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
checking how to run the C++ preprocessor... g++ -E
configure: creating ./config.status
config.status: creating Makefile
Z3 was configured with success.
Host platform: osx
Arithmetic: internal
Type 'make' to compile Z3.
$ make
Makefile:271: obj/external/act_cache.d: No such file or directory
Makefile:271: obj/external/add_bounds.d: No such file or directory
Makefile:271: obj/external/add_bounds_tactic.d: No such file or directory
Makefile:271: obj/external/aig.d: No such file or directory
....
(many like this)
....
Makefile:273: obj-test/external/array_property_expander.d: No such file or directory
Makefile:273: obj-test/external/arith_rewriter.d: No such file or directory
Makefile:273: obj-test/external/arith_simplifier_plugin.d: No such file or directory
Makefile:273: obj-test/external/ast.d: No such file or directory
....
(and more like this)
....
Making dependency file 'obj-test/external/bits.d' ...
clang: warning: argument unused during compilation: '-fopenmp'
clang: warning: argument unused during compilation: '-mfpmath=sse'
In file included from test/bits.cpp:5:
In file included from lib/mpz.h:29:
lib/z3_omp.h:23:9: fatal error: 'omp.h' file not found
#include"omp.h"
^
1 error generated.
Any idea what could be wrong? My g++ version is:
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
EDIT: I followed Christoph's suggestions, and I could start the build successfully, but at some point I got the following errors:
clang: warning: argument unused during compilation: '-mfpmath=sse'
lib/hwf.cpp:27:14: warning: pragma STDC FENV_ACCESS ON is not supported, ignoring pragma [-Wunknown-pragmas]
#pragma STDC FENV_ACCESS ON
^
In file included from lib/hwf.cpp:50:
/usr/bin/../lib/clang/5.0/include/emmintrin.h:1388:22: error: expected expression
return (__m128)__in;
^
/usr/bin/../lib/clang/5.0/include/emmintrin.h:1394:23: error: expected expression
return (__m128i)__in;
^
/usr/bin/../lib/clang/5.0/include/emmintrin.h:1400:23: error: expected expression
return (__m128d)__in;
^
/usr/bin/../lib/clang/5.0/include/emmintrin.h:1406:23: error: expected expression
return (__m128i)__in;
^
/usr/bin/../lib/clang/5.0/include/emmintrin.h:1412:22: error: expected expression
return (__m128)__in;
^
/usr/bin/../lib/clang/5.0/include/emmintrin.h:1418:23: error: expected expression
return (__m128d)__in;
^
1 warning and 6 errors generated.
Any ideas?
This one is a bit tricky as Boogie doesn't support the new Z3 (see also here), but the old 4.1.2 version of Z3 doesn't support the new compiler (clang) on OSX 10.9. This is mainly because clang lacks support for OpenMP. We can build this version of Z3 without support for OpenMP though, by adding -D_NO_OMP_ to the CPPFLAGS line in the Makefile, or by running
CPPFLAGS=-D_NO_OMP_ LDFLAGS=-stdlib=libstdc++ ./configure
on the command line (the LDFLAGS setting is required because clang selects an unsuitable standard C++ library by default; see here for details). We then need to replace all occurrences of -fopenmp in the Makefile, e.g., by running
sed -i '' "s/-fopenmp//" Makefile
Once that is done, Z3 4.1.2 should build successfully.

Error 1 & 2 when compiling GCC 4.4.2 on OpenSolaris 2009.06

My problem:
I've been trying to compile, build, and install GCC 4.4.2 in my installation of OpenSolaris 2009.06 on my VirtualBox 3 i386 machine. But I keep getting this same error when running make:
> checking whether ln -s works... yes
checking for i386-pc-solaris2.11-gcc... /src/gcc-4.4.2/host-i386-pc-solaris2.11/gcc/xgcc -B/src/gcc-4.4.2/host-i386-pc-solaris2.11/gcc/ -B/usr/gnu/i386-pc-solaris2.11/bin/ -B/usr/gnu/i386-pc-solaris2.11/lib/ -isystem /usr/gnu/i386-pc-solaris2.11/include -isystem /usr/gnu/i386-pc-solaris2.11/sys-include
checking for suffix of object files... configure: error: in `/src/gcc-4.4.2/i386-pc-solaris2.11/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/src/gcc-4.4.2'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/src/gcc-4.4.2'
make: *** [all] Error 2
Attempted solutions:
I tried the answer to this question:
Problem compiling gcc 4.4.0 on OpenSolaris 2009.6 i.e.
./configure --prefix=/usr/gnu --with-gmp=/usr/gnu --with-mpfr=/usr/gnu --with-as=/usr/sfw/bin/gas --with-gnu-as --with-gnu-ld
I tried GNU GCC's platform specific solution:
GNU Solaris specific build instructions
i.e.
./configure --prefix=/usr/gnu --with-gmp=/usr/gnu --with-mpfr=/usr/gnu --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-shared
I am still getting the same errors despite running ./configure with the two solutions above
Any help would be appreciated!
Thanks!
Can you compile programs with the existing GCC?
If not, you need to resolve that.
If you can, then you need to look at that monstrous 7-argument command (the one where it says 'checking for i386-pc-solaris2.11-gcc' - why those 7 arguments?).
Are you running 'make bootstrap'?
If not, what happens when you do?
If so, whereabouts in the processing is it? (Is this stage 1, or stage 2, or what?)
Are you using the recommended setup, with the source for GCC in, say, /src/gcc-4.4.2 and the object files in, say, /src/gcc-4.4.2-obj?
If not, do so. Use: cd /src/gcc-4.4.2-obj; ../gcc-4.4.2/configure ...
Which shell do you use?
On regular Solaris 10 (not OpenSolaris - and SPARC, not Intel), I have to set CONFIG_SHELL=/bin/ksh in the environment to make things compile (by default, it uses /bin/sh, but the /bin/sh on Solaris 10 is Bourne shell and there's a script deep down in the Java section (IIRC) that uses Bash/Korn/POSIX shell notations like $(cmd ...)). However, that normally affects a much later stage in the processing.
However, I have got GCC 4.4.2 on Solaris 10 without problem (using GCC 4.4.1 as the bootstrap compiler).

Resources