ld: symbol(s) not found for architecture arm64

Hi All,

I'm writing a c program on my m1 macbook, but when i compiled the project, error occurs:

Undefined symbols for architecture arm64:
  "_fp", referenced from:
      _main in main.c.o
  "_init", referenced from:
      _main in main.c.o
ld: symbol(s) not found for architecture arm64

and also, when i exec ld command, it will return some warnings:

ld: warning: platform not specified
ld: warning: -arch not specified
ld: warning: No platform min-version specified on command line
ld: no object files specified

I only install the xcode command line tools and use vscode, i believe it's a link problem but have no idea if it's a bug or my config fault.

Someone has any idea?Thanks

Replies

It’s hard to say what’s going on here because you’ve not provided any details about your code or the commands you use to compile your code. Here’s a minimal example of compiling code on an Apple silicon Mac using command-line tools:

% mkdir test
% cd test
% cat > main.c
#include <stdio.h>

int main(int argc, char ** argv) {
    printf("Hello Cruel World!\n");
}
^D
% clang main.c
% ./a.out
Hello Cruel World!

Does this example work on your machine? If so, tweak it to replicate the problem and then post the details here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Hi, I'm facing the same error! You example is Passed! But it doesn't work when I compile NCURSES. It seems that there are something wrong with my ld

    `nullnull@NulldeMBP ncurses-6.3 % ld -v

    @(#)PROGRAM:ld  PROJECT:ld64-711

    BUILD 18:11:19 Aug  3 2021

    configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em

    LTO support using: LLVM version 13.0.0, (clang-1300.0.29.3) (static support for 27, runtime is 27)

    TAPI support using: Apple TAPI version 13.0.0 (tapi-1300.0.6.5)`

    nullnull@NulldeMBP ncurses-6.3 % clang -v Apple clang version 13.0.0 (clang-1300.0.29.3) Target: arm64-apple-darwin21.1.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin Here are the configuration and error. ** Configuration summary for NCURSES 6.3 20211021:        extended funcs: yes        xterm terminfo: xterm-new         bin directory: /usr/local/bin         lib directory: /usr/local/lib     include directory: /usr/local/include/ncurses         man directory: /usr/local/share/man    terminfo directory: /usr/local/share/terminfo ** Include-directory is not in a standard location

    `gcc ../objects/tic.o ../objects/dump_entry.o ../objects/tparm_type.o ../objects/transform.o -L../lib -Wl,-search_paths_first -DHAVE_CONFIG_H -I../progs -I. -I../include -D_DARWIN_C_SOURCE -DNDEBUG -O2 -Qunused-arguments -Wno-error=implicit-function-declaration -no-cpp-precomp  -DNCURSES_STATIC -L../lib  -lncurses -lncurses    -o tic

    ld: warning: ignoring file ../lib/libncurses.a, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 ) Undefined symbols for architecture arm64:   "__nc_boolcodes", referenced from:       _nametrans in dump_entry.o       _dump_init in dump_entry.o   "__nc_boolfnames", referenced from:       _dump_init in dump_entry.o   "__nc_boolnames", referenced from:       _dump_init in dump_entry.o   "__nc_capcmp", referenced from:       _check_termtype in tic.o       _check_sgr in tic.o   "__nc_check_termtype2", referenced from:       _main in tic.o   "__nc_curr_col", referenced from:       _main in tic.o   "__nc_curr_line", referenced from:       _main in tic.o   "__nc_disable_period", referenced from:       _main in tic.o   "__nc_doalloc", referenced from:       _main in tic.o       _fmt_entry in dump_entry.o       _strcpy_DYN in dump_entry.o       _fmt_complex in dump_entry.o       _strncpy_DYN in dump_entry.o   "__nc_find_entry", referenced from:       _check_user_capability_type in tic.o       _nametrans in dump_entry.o   "__nc_find_user_entry", referenced from:       _check_termtype in tic.o       _check_user_capability_type in tic.o   "__nc_first_name", referenced from:       _main in tic.o       _check_termtype in tic.o       _fmt_complex in dump_entry.o       _dump_entry in dump_entry.o   "__nc_get_hash_table", referenced from:       _check_user_capability_type in tic.o       _nametrans in dump_entry.o   "__nc_head", referenced from:       _main in tic.o   "__nc_home_terminfo", referenced from:       _show_databases in tic.o   "__nc_infotocap", referenced from:       _check_termtype in tic.o       _fmt_entry in dump_entry.o   "__nc_name_match", referenced from:       _main in tic.o   "__nc_numcodes", referenced from:       _nametrans in dump_entry.o       _dump_init in dump_entry.o   "__nc_numfnames", referenced from:       _dump_init in dump_entry.o   "__nc_numnames", referenced from:       _dump_init in dump_entry.o   "__nc_pathlast", referenced from:       _valid_db_path in tic.o   "__nc_read_entry_source", referenced from:       _main in tic.o   "__nc_reset_tparm", referenced from:       _check_termtype in tic.o       _check_1_infotocap in tic.o   "__nc_resolve_uses2", referenced from:       _main in tic.o   "__nc_rootname", referenced from:       _main in tic.o   "__nc_set_source", referenced from:       _main in tic.o   "__nc_set_type", referenced from:       _main in tic.o   "__nc_set_writedir", referenced from:       _main in tic.o   "__nc_strcodes", referenced from:       _nametrans in dump_entry.o       _dump_init in dump_entry.o   "__nc_strfnames", referenced from:       _dump_init in dump_entry.o   "__nc_strict_bsd", referenced from:       _main in tic.o   "__nc_strnames", referenced from:       _check_termtype in tic.o      _dump_init in dump_entry.o       _dump_entry in dump_entry.o   "__nc_syntax", referenced from:       _check_termtype in tic.o   "__nc_tail", referenced from:       _main in tic.o   "__nc_tic_dir", referenced from:

          _main in tic.o

          _show_databases in tic.o

      "__nc_tic_expand", referenced from:

          _check_ansi_cursor in tic.o

          _fmt_entry in dump_entry.o

      "__nc_tic_written", referenced from:

          _main in tic.o

      "__nc_tinfo_fkeysf", referenced from:

          _check_termtype in tic.o

      "__nc_tiparm", referenced from:

          _check_termtype in tic.o

          _check_sgr in tic.o

          _check_1_infotocap in tic.o

          _same_color in tic.o

      "__nc_tparm_analyze", referenced from:

          _check_termtype in tic.o

          _check_1_infotocap in tic.o

      "__nc_tparm_err", referenced from:

          _check_termtype in tic.o

          _check_sgr in tic.o

      "__nc_tracing", referenced from:

          _main in tic.o

      "__nc_trim_sgr0", referenced from:

          _check_termtype in tic.o

          _fmt_entry in dump_entry.o

      "__nc_user_definable", referenced from:

          _check_termtype in tic.o

          _fmt_entry in dump_entry.o

          _compare_entry in dump_entry.o

      "__nc_visbuf", referenced from:

          _similar_sgr in tic.o

      "__nc_visbuf2", referenced from:

          _check_termtype in tic.o

          _check_sgr in tic.o

          _similar_sgr in tic.o

      "__nc_warning", referenced from:

          _check_termtype in tic.o

          _check_user_capability_type in tic.o

          _check_sgr in tic.o

          _check_sgr_param in tic.o

          _check_1_infotocap in tic.o

          _check_noaddress in tic.o

          _check_ansi_cursor in tic.o

          ...

      "__nc_write_entry", referenced from:

          _main in tic.o

      "__nc_write_object", referenced from:

          _dump_entry in dump_entry.o

      "_curses_version", referenced from:

          _main in tic.o

      "_keyname", referenced from:

          _check_termtype in tic.o

      "_tgoto", referenced from:

          _check_sgr_param in tic.o

      "_tigetflag", referenced from:

          _check_termtype in tic.o

      "_tigetstr", referenced from:

          _check_termtype in tic.o

      "_tparm", referenced from:

          _check_termtype in tic.o

          _check_1_infotocap in tic.o

         (maybe you meant: _tparm_type, _guess_tparm_type )

      "_use_extended_names", referenced from:

          _main in tic.o

    ld: symbol(s) not found for architecture arm64

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    make[1]: *** [tic] Error 1

    make: *** [all] Error 2`

Add a Comment

It turns out that it was an error in my Makefile and ld can't find some functions. I thought it was an error related to platforms as the error messege refers to arm64.

Sorry for the ambigious message as it's not a personal project so I can only intercept a few message related to the possible error.

Thank you all the same.

  • Hi,

    I have the exact same error in my first makefile. Could you help me by giving me insights about how you solved this ?

    Thank you

  • I am facing the same error i.e "ld: symbol(s) not found for architecture arm64" while using make. None of the above worked for me. How you solved this?

Add a Comment

I'm facing the same error!

Well, it seems like a related error, but it’s hard to be sure because of the formatting of your post. I recommend that you start a new thread and put the info in there. Use the same tags so that I see it go by. And feel free to reference this thread if you think the context would be valuable.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"