Mac OX 10.10 failed to compile connection by default after updating GCC 4.9.1

Source: Internet
Author: User
Tags gmp

MAC OS X10.10 The earlier version of GCC (as if it were 4.7.x) that was used before the upgrade, the normal compilation can be done, but a warning appears:

couldn‘t understand kern.osversion `14.0.0‘

Users say it seems that the Xcode version is too low (using Xcode6 beta4) and is now upgrading Xcode 6.1. At the same time, use homebrew to upgrade the latest GCC 4.9.1 (x86_64). Later, the compilation found that GCC always ran to clang up! The check found that the original GCC file was deleted, and in path, the GCC is linked to clang in/usr/bin. Then fix the gcc4.9.1 connection, then compile a simple C source code, the following error occurred:

[Email protected]: c_src$gcc-v

Using built-in specs.

collect_gcc=gcc

Collect_lto_wrapper=/usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.1/lto-wrapper

target:x86_64-apple-darwin14.0.0

Configured with:.. /configure--build=x86_64-apple-darwin14.0.0--prefix=/usr/local/cellar/gcc/4.9.1--ENABLE-LANGUAGES=C,C++,OBJC, Obj-c++,fortran--program-suffix=-4.9--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-version-specific-runtime-libs--enable-libstdcxx-time=yes--enable-stage1-checking--enable-checking= Release--enable-lto--disable-werror--with-pkgversion= ' Homebrew gcc 4.9.1 '--with-bugurl=https://github.com/ Homebrew/homebrew/issues--enable-plugin--disable-nls--enable-multilib

Thread Model:posix

GCC version 4.9.1 (Homebrew gcc 4.9.1)

[Email protected]: C_src$gcc-std=c11-o x x.c

Undefined Symbols for Architecture x86_64:

"Start", referenced from:

-U command line option

Ld:symbol (s) not found for architecture x86_64

Collect2:error:ld returned 1 exit status


Search the Internet, some people say that some of the code in the function name is wrong, but I this is obviously not the reason. Look at the error literal meaning may be less linked to a startup library, you can compare Clang's last command line through-V (because Clang does not go wrong), but for the sake of lazy and easy to figure. So through the search to find this connection: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54423 (CIS BS a Niang and a bxxg, can not find, or with a brother over the wall AH), which and my phenomenon is exactly the same, Then add-lcrt1.o, so the mistake disappears the bird. NM CRT1.O found that there is a start symbol:

[Email protected]: C_SRC$NM/USR/LIB/CRT1.O

0000000000000170 s EH_FRAME1

000000000000012A s LC1

000000000000012b s LC2

0000000000000158 s LC3

00000000000001c8 S _NXARGC

00000000000001d0 S _NXARGV

U ___dso_handle

U ___keymgr_dwarf2_register_sections

00000000000001E0 S ___progname

U __cthread_init_routine

0000000000000124 T __dyld_func_lookup

0000000000000022 T __start

U _atexit

00000000000001d8 S _environ

U _errno

U _exit

U _mach_init_routine

U _main

0000000000000110 T Dyld_stub_binding_helper

0000000000000188 s Func.eh

0000000000000000 T Start


But with clang normal connection without this problem, seemingly will not connect to CRT1.O, do not know why GCC must even crt1.o, and why the default does not add CRT1.O? The following is the compiled symbol table for 2 compilers:

[Email protected]: c_src$nm X_GCC X_clang


X_GCC:

0000000100001058 S _NXARGC

0000000100001060 S _NXARGV

U ___keymgr_dwarf2_register_sections

0000000100001070 S ___progname

U __cthread_init_routine

0000000100000e68 T __dyld_func_lookup

0000000100000000 A __mh_execute_header

0000000100000d66 T __start

U _atexit

0000000100001068 S _environ

U _errno

U _exit

U _mach_init_routine

0000000100000e70 S _main

U _printf

U _puts

U _sleep

0000000100000e54 T Dyld_stub_binding_helper

0000000100000D44 T Start


X_clang:

0000000100000000 T __mh_execute_header

0000000100000F00 T _main

U _printf

U _puts

U _sleep

U Dyld_stub_binder


And the clang compiled size is significantly smaller than GCC:

-rwxr-xr-x 1 apple Staff 8.4K 09:54 X_clang

-rwxr-xr-x 1 apple Staff 8.6K 09:53 X_GCC

still after updating Xcode, see if the GCC defaults can be compiled through Oh! (Update results later)

Mac OX 10.10 failed to compile connection by default after updating GCC 4.9.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.