An error occurred when trying to link the source code in Shosuisha's "Low Level Programming" on the mac terminal. I tried writing and setting the environment while looking at the Github page of this book, but I couldn't solve it anyway, so I would like to lend my wisdom.
Github for Low Level Programming: https://github.com/Apress/low-level-programming
Error message% nasm -fmacho64 hello.asm&&ld hello.o&&./a.out
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol (s) not found for architecture x86_64
Applicable source code
global start
section .text
start: mov rax, 0x02000004
mov rdi, 1
mov rsi, message
mov rdx, 13
syscall
mov rax, 0x02000001
xor rdi, rdi
syscall
section .data
message: db "Hello, World", 10
I changed what was originally _start to start, or changed it to main or _main.
Supplemental information (FW/tool version etc.)mid-2012 13inch macbook air
intel core i5
macOS Catalina version 10.15.1
NASM version 2.14.02 compiled on Sep 28 2019
2019/11/03 00:50
I saw it as_main.
There are two places in start, have you both _main?
If both are _main
ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
Another error message was. Link and run
% nasm -fmacho64 hello.asm&&ld hello.o&&./a.out
It remains. Thanks for your advice.
asm-san2019/11/03 01:20
On github
>Linking: ld -macosx_version_min 10.7.0 -lSystem -o hello_world
Did you try this option?
If i try to link with that option
ld: warning: -arch not specified
ld: warning: ignoring file /usr/lib/libSystem.dylib, missing required architecture unknown in file /usr/lib/libSystem.dylib (2 slices)
Undefined symbols for architecture unknown:
"start", referenced from:
implicit entry/start for main executable
ld: symbol (s) not found for architecture unknown
The message has changed. By the way, the two parts that were the contents ofstart
were changed to_main
in response to otn's indication. Thanks for your advice.
-
Answer # 1
-
Answer # 2
Are you aware of the cause (s) of Undefined symbols for architecture x86_64 :?
Related articles
- macos (osx) - jupyter lab chromedriver error
- macos (osx) - i can't get up all the time with the error "visual studio code quit for an unexpected reason"
- macos (osx) - docker error
- macos (osx) - error in homebrew update
- macos (osx) - when i try to put gnuplot in homebrew, i get an error
- macos (osx) - error in rsync command in shell script
- macos (osx) - talib install error
- macos (osx) - sort_valus method error macos
- macos (osx) - i want to fix bash_profile error (syntax error) in terminal
- macos (osx) - i get an error when i open the terminal
- macos (osx) - about fatal error displayed by git operation in terminal
- macos (osx) - when i drag and drop wxpython, the error "type error: ~ a'bool' is expected not'none type'" appears
- macos (osx) - ruby on rails installation error (`you don't have write permissions`)
- macos (osx) - the set path is not saved
- macos (osx) - i'm trying to connect to localhost:8888 with mamp but i get 404 not found
- macos (osx) - after changing the home directory name of mac, various software stopped working
- macos (osx) - i want to improve that "no mapping found" appears 3 times when defxnvim starts
- macos (osx) - in aws amplify cli, even if i enter amplify configure in the terminal, it does not proceed with command not found
- macos (osx) - check boxes such as "intelephensediagnosticsundefinedclass" are not displayed in vs code settings->ex
- assembly language - how to secure the stack area in the assembler
- local environment construction about installation of mac mysql
- macos (osx) - creating a shell file
- ruby - homebrew install does not succeed
- php - please tell me the continuous input of half-width alphanumeric characters by pressing and holding the mac keyboard
- macos (osx) - i can't push to a remote repository on github
- python - $pip install -r requirementstxt cannot be executed with an error
- python - i want to use the program in the folder obtained from github in the terminal
- macos (osx) - i can't push on github
- macos (osx) - what to do if your current account on github doesn't have permissions
- java - i want to import a project from github with eclipse
I think the github article about command line option specification was old at the time of writing (two years ago), and the target macOS version was also old. I tried it with macOS Mojave, but it was assembled by replacing the "start" with "_main" in the two places that were pointed out in the comments, and removing the "-macosx_version_min" option of the
ld
command I was able to link with. Questioner's macOS is Catalina, but for reference.