How to avoid "Undefined symbols for architecture x86_64"?

Discussion in 'Mac Programming' started by mikezang, Jul 25, 2015.

  1. mikezang macrumors 6502a

    May 22, 2010
    Tokyo, Japan
    I tried to create a cross compile for my old Lego RCX, I use GCC 3.3.6 and NEWLIB 1.13.
    1. Download GCC 3.3.6 and Unzip
      cd ../..
      tar xzvf gcc-3.3.6/gcc-3.3.6.tar.gz
    2. Download NEWLIB 1.13 and unzip
      tar xzvf newlib-1.13.0.tar.gz
    3. Link NEWLIB to GCC
       cd gcc-3.3.6/
       ln -s ../newlib-1.13.0/newlib .
    4. Make h8300-hms build folder
       cd ..
       mkdir build_gcc_h8300-hms
    5. Config
       ../gcc-3.3.6/configure --prefix=/usr/local/h8300-hms --program-prefix=h8300-hms- --target=h8300-hms --enable-languages=c,c++ --with-newlib
    6. Make 
       make CFLAGS="-O2 -fomit-frame-pointer" all
    When I make it, at last I got error as below, what can I do?
    gcc -c   -O2 -fomit-frame-pointer -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes    -DHAVE_CONFIG_H    -I. -Icp -I../../gcc-3.3.6/gcc -I../../gcc-3.3.6/gcc/cp -I../../gcc-3.3.6/gcc/config -I../../gcc-3.3.6/gcc/../include ../../gcc-3.3.6/gcc/cp/cp-lang.c -o cp/cp-lang.o
    gcc   -O2 -fomit-frame-pointer -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long   -DHAVE_CONFIG_H  -o cc1plus \
              cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parse.o cp/ptree.o cp/rtti.o cp/spew.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o cp/mangle.o cp/cp-lang.o attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o c-dump.o  c-pretty-print.o c-opts.o main.o libbackend.a libcpp.a ./intl/libintl.a  -liconv  ../libiberty/libiberty.a
    Undefined symbols for architecture x86_64:
      "_libc_name_p", referenced from:
          _nothrow_libfn_p in except.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cc1plus] Error 1
    make: *** [all-gcc] Error 2
  2. Madd the Sane macrumors 6502a

    Madd the Sane

    Nov 8, 2010
    What is happening is that OS X's linker can't find the specified function in anything it is trying to link. The reason for this could be a missing preprocessor macro, or the compiled code and/or library isn't being linked.
  3. mikezang thread starter macrumors 6502a

    May 22, 2010
    Tokyo, Japan
    Thanks for your message! can you tell me how to solve this problem?
  4. cqexbesd macrumors regular

    Jun 4, 2009
    I'm only guessing here but I think you may need to have gperf installed. Then start building from scratch - i.e. make distclean or similar - or just delete your directory and expand the tar file again.
  5. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Looks like you are using the wrong GCC.

    Either type full path to GCC 3.3.6 or add it to the path with a different name than GCC (because Apple already provides a GCC command which happens to actually run clang). This is why you have the following error:

    You are actually running Clang which compiles to x86_64. You need to run the GCC that you compiled. Normally when compiling GCC as a cross compiler you give it a different name than GCC (which is one of the configure script options for GCC when compiling it) so that you can tell the difference between the GCC provided by the system and your own GCC cross compiler.
  6. mikezang thread starter macrumors 6502a

    May 22, 2010
    Tokyo, Japan

Share This Page