I want to build "gcc cross-compiler" to compile "c/c++" applications on "Linux" environment but for "Windows" target.
I have made this so far:
Installed the necessary tools and packages for building GCC listed on "Prerequisites for GCC" page.
Downloaded required sources:
"gcc-core-4.4.1", "gcc-g++-4.4.1", "binutils-2.19.1", "w32api-3.13-mingw32", "mingwrt-3.16-mingw32"
Created this directory hierarchy:
"${HOME}/gcc/" - for final cross-compiler
"${HOME}/src/" - for sources
"${HOME}/src/build-binutils/i386-mingw32/" - for building binutils to "i386-mingw32" target
"${HOME}/src/build-gcc/i386-mingw32/" - for building gcc to "i386-mingw32" target
Builded binutils package:
cd "${HOME}/src/build-binutils/i386-mingw32/"
../../binutils-2.19.1/configure --prefix="${HOME}/gcc" --target=i386-mingw32 --disable-nls
make
make install
Copied "w32api" and "mingwrt" headers to the install directory:
cp -R "${HOME}/src/w32api-3.13-mingw32/include" "${HOME}/gcc/i386-mingw32"
cp -R "${HOME}/src/mingwrt-3.16-mingw32/include" "${HOME}/gcc/i386-mingw32"
And now when I am trying to build the "c (only) cross-compiler":
cd "${HOME}/src/build-gcc/i386-mingw32/"
../../gcc-4.4.1/configure --prefix="${HOME}/gcc" --target=i386-mingw32 --enable-languages=c --with-headers="${HOME}/gcc/i386-mingw32/include" --disable-nls
make<br>
it was building something about 4 minutes and then gives me these errors:
${HOME}/gcc/i386-mingw32/bin/ld: dllcrt2.o: No such file: No such file or directory
collect2: ld returned 1 exit status
make[2]: *** [libgcc_s.dll] Error 1
make[2]: Leaving directory `${HOME}/src/build-gcc/i386-mingw32/i386-mingw32/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `${HOME}/src/build-gcc/i386-mingw32'
make: *** [all] Error 2
From that error message I really don't know what to do now :-((( .
Does anybody know where is the problem?
Thanks.
That's actually OK: the way things go, you need to
build binutils
install headers
build the a partial C compiler: enough to create object files, but not enough to link
build the win32api and mingw runtime (which includes your missing dllcrt2.o)
build a complete C compiler (and other front-ends, such as C++, Fortran, Ada, whatever, if you want them)
You have successful performed step 3 above; it fails building libgcc (which is a GCC support library), but that means the C compiler core is functionnal (although it won't be able to link, it can still create valid object files). You can check that by looking at the gcc/xgcc file in your GCC build directory.
So, you need to go to the next step, not worrying about your current failure.
(To actuall install the partial C compiler, you should run make with the -k option, to have it do it best, even in the face of errors. For example, use make -k install.)
There are precompiled cross-compilers of MinGW-w64 available.
This allows to compile native 32- and 64-bit Windows binaries from Linux, a two minute tutorial is available at http://www.blogcompiler.com/2010/07/11/compile-for-windows-on-linux/
Just in case you don't want to spend a lot of time trying to build it yourself.
I grepped through the MinGW sources, and found that dllcrt2.o is something built off the mingwrt package. I assume you have to compile and install that, not just copy the headers?
Related
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.
I am trying to bootstrap GCC during OpenELEC compilation. I need to add libatomic for the target system so as to compile some packages.
When I try to add libatomic for the target system, I get a compilation error with:
/home/mathieu/tmp/OpenELEC.tv/build.OpenELEC-ci20.mips-8.0-devel/toolchain/mipsel-openelec-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/home/mathieu/tmp/OpenELEC.tv/build.OpenELEC-ci20.mips-8.0-devel/toolchain/mipsel-openelec-linux-gnu/bin/ld: cannot find -lc
/home/mathieu/tmp/OpenELEC.tv/build.OpenELEC-ci20.mips-8.0-devel/toolchain/mipsel-openelec-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
Using the following package.mk file:
https://github.com/malaterre/OpenELEC.tv/blob/fd5a5558104ed38aee1c53bb6d31ba73e8eb6e57/packages/lang/gcc/package.mk
If that matter I am targetting a MIPS system, specifically the Creator CI20:
https://github.com/malaterre/OpenELEC.tv/blob/master/config/arch.mips
I am not clear about the OpenELEC build system, but it seems as if the host compiler and target compiler are build at the same time, while I would need to build binutils in between:
http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
You might need to have a GCC built without libatomic to build one with libatomic. The intermediary compiler will serve to build your CRT (if you do not have it already) and libatomic, so that a second compiler can use these "prebuilt" things.
That was not hard at all. Basically one need to create first a minimal gcc (bootstrap) and then build the full one with libatomic:
https://github.com/malaterre/OpenELEC.tv/blob/70dbe25c1647f01eb83c108939c470437a2db259/packages/lang/gcc/package.mk
My environment:
QT: Qt_5_0_2
QWT: qwt-6.1-rc3
MinGW: mingw47_32
OS: win7_32
I follow the introduction file "INSTALL"'s step:
C) Win32/MinGW
Check that your Qt version has been built with MinGW - not with MSVC !
Start a Shell, where Qt4 is initialized. ( F.e. with
"Programs->Qt by Trolltech ...->Qt 4.x.x Command Prompt" ).
Check if you can execute "make" or something like "mingw32-make".
qmake qwt.pro
make
make install
I get the error in the step "make":
C:\qwt-6.1-rc3>qmake qwt.pro
C:\qwt-6.1-rc3>mingw32-make
cd src\ && ( if not exist Makefile E:\Qt\5.0.2\5.0.2\mingw47_32\bin\qmake.exe C:
\qwt-6.1-rc3\src\src.pro -o Makefile ) && mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'C:/qwt-6.1-rc3/src'
mingw32-make -f Makefile.Release all
mingw32-make[2]: Entering directory 'C:/qwt-6.1-rc3/src'
Makefile.Release:305: *** missing separator. Stop.
mingw32-make[2]: Leaving directory 'C:/qwt-6.1-rc3/src'
Makefile:40: recipe for target 'release-all' failed
mingw32-make[1]: *** [release-all] Error 2
mingw32-make[1]: Leaving directory 'C:/qwt-6.1-rc3/src'
makefile:44: recipe for target 'sub-src-make_first-ordered' failed
mingw32-make: *** [sub-src-make_first-ordered] Error 2
The lines 304,305 in "Makefile.Release" are:
304 qmake: FORCE
305 #$(QMAKE) -o Makefile.Release src.pro
Where is wrong?
thanks
Makefile.Release:305: *** missing separator. Stop.
This usually means this Makefile is not of the right format for mingw32-make;
Since the Makefile is generated by qmake, you should check the QMAKESPEC of your qmake. It should be win32-g++, not win32-mvsc.
This issue is strongly linked to the first warning of the qwt INSTALL note :
Check that your Qt version has been built with MinGW - not with MSVC !
Guess your broken Makefile is leftover from some earlier attempts - remove the Qwt build directory completely and start from scratch.
For loading the Qwt designer plugin in the Qt creator you need to have a version that is compatible with how the creator had been built. AFAIR the 5.0.2 mingw package contains a version 2.7.0 of the creator, that had been built for Qt 4.8 with MSVC ( see About->Qt creator ). If true it means you need to have 2 different builds of Qwt - one for your application, the other one for the designer plugin.
For the future I'm planning to offer precompiled versions of the designer plugin that are compatible with current binary packages of the Qt creator.
Also note that in SVN trunk the default settings for building the plugin have been changed since rc3: on windows the library is statically linked into the plugin and on better systems you have a similar effect with compiling in the install path of the library ( see RPATH ).
I had the same problem. The reason was that I wanted to prepare sources second time. I had sources in svn floder. I solved proble erasing folder and update sources again. After this operation I was able to run 'qmake proj.pro' correctly.
While building ARM toolchain , I got the following error
checking for suffix of object files... configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory `<path>/gcc-4.3.2-arm-elf'
make: *** [all] Error 2
what might be the problem?
Did you read http://gcc.gnu.org/wiki/FAQ#configure_suffix ?
Have you installed GMP, MPFR and MPC? Are they in your library search path?
See http://gcc.gnu.org/wiki/InstallingGCC and make sure you've followed the basic instructions. By far the simplest way to build GCC (including as a cross compiler) is to follow these instructions:
Alternatively, after extracting the GCC source archive, simply run the ./contrib/download_prerequisites script in the GCC source directory. That will download the support libraries and create symlinks, causing them to be built automatically as part of the GCC build process.
"*Building GCC is not trivial, but is not difficult if you follow the instructions carefully.
Many people rush into trying to build it without reading the installation docs properly and make one or more of these common mistakes:
1) do not run ./configure from gcc src dir (this is not supported) => you need to run configure from outside the gcc source directory
2) Note: if GCC links dynamically to the prerequisite libs (GMP/MPFR/MPC) then the shared libraries must be in the dynamic linker's path (LD_LIBRARY_PATH), both when building gcc and when using the installed compiler.*"
Simple example (without dynamic link to GMP/MPFR/MPC):
tar xzf gcc-4.8.0.tar.gz
cd gcc-4.8.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.0/configure --prefix=/opt/gcc-4.8.0
make
make install
Sources:
Advogato Doc -
GNU Doc
export LD_LIBRARY_PATH=/path/for/libraries:$LD_LIBRARY_PATH
path/for/libraries is where the GMP MPFR and MPC libraries are present.
I was compiling GCC on ubuntu 12.04 and these linraries present in the path /usr/local/lib
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).