|
|
#1 |
|
NASM et mac os ( french man sorry )
Good evening
I apologize beforehand, I am French. It has been several days since I look for solutions concerning NASM and mAC bone, but I find only the English forums.. I am thus on mac bone and I would like to compile a program assembler For exemple : Code:
%include "iut.inc" segment .text global start start: mov eax, msg_Accueil call write_string mov eax,msg_Nombre call write_string call read_int mov ebx,eax mov eax,msg_Base call write_string call read_int mov ecx,eax call SousProg ;APPEL DU SOUS PROGRAMME mov edx,eax mov eax, msgResultat call write_string mov eax, ebx call write_int mov eax, msgResultat1 call write_string mov eax, ecx call write_int mov eax, msgResultat2 call write_string mov eax, edx call write_int ret SousProg: ;EMPILEMENT DES REGISTRES UTILISES push ebx push ecx ;TRAITEMENT mov ebx,1312 mov ecx,5476 mov eax,45 ;FIN DU TRAITEMENT ;J'AI MODIFIE LA VALEUR DE ebx ET DE ecx POUR LES BESOINS DU TRAITEMENT ;RESTAURATION DES REGISTRES UTILISES pop ecx pop ebx ret segment .data msg_Accueil: db "Convertion d'un nombre en base b en decimal",10,0 msg_Nombre: db "Saissez le nombre a convertir",10,0 msg_Base: db "Saissez la base du nombre",10,0 msgResultat: db 10,"le resultat de la convertion du nombre ",0 msgResultat1 db " en base ",0 msgResultat2 db " en decimal est ",0 In class, to I was told that to compile under Linux, it was necessary to make: Code:
nasm –f elf exemple.asm gcc –o exemple exemple.o –L. –lIUT -lncurses -lpanel So , when i do Code:
nasm -v Code:
NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Aug 4 2012 Code:
MacBook-Pro-de-Rebouh:Assembleur rebouhaymen$ nasm -f elf Ex_SousP_Pile.asm
MacBook-Pro-de-Rebouh:Assembleur rebouhaymen$ gcc -o Ex_SousP_Pile Ex_SousP_Pile.o -L. -lIUT -lncurses -lpanel
ld: warning: ld: warning: ignoring file ./libIUT.a, file was built for archive which is not the architecture being linked (x86_64): ./libIUT.aignoring file Ex_SousP_Pile.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 1 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): Ex_SousP_Pile.o
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
MacBook-Pro-de-Rebouh:Assembleur rebouhaymen$
|
|
|
|
0
|
|
|
#2 |
|
Well, for starters, I have no idea what the contents of iut.inc or libIUT.a are, but it looks at least libIUT.a doesn't contain what you think it does. The magic number (0x7F 45 4C 46) reported is for an ELF executable, not an archive library (which should be 0xCAFEBABE for a universal file, or something like 0x21 3C 61 72 63 68 3E 0A for a single architecture file). To confirm, try running "file libIUT.a" and see what it reports. It should say "current ar archive random library".
|
|
|
|
0
|
|
|
#3 |
|
Mac OS X does not use the ELF format for its binaries. You need to use the macho format instead.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development Last.fm Profile | Extreme Metal Reviews MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3 |
|
|
|
0
|
|
|
#4 |
|
That's Mach-O, not macho.
But a .a file shouldn't contain a binary executable anyway, regardless of the format. Since it's reporting that it's an ELF executable, you have a problem. It sounds like this libIUT.a file may have been compiled (incorrectly) on a Linux system?
|
|
|
|
0
|
|
|
#5 |
|
The correct output format flag for OS X in NASM is indeed macho. Apart from that, is the archive perhaps built on Linux? In that case you have to re-compile it for OS X.
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 08:38 AM.






But a .a file shouldn't contain a binary executable anyway, regardless of the format. Since it's reporting that it's an ELF executable, you have a problem. It sounds like this libIUT.a file may have been compiled (incorrectly) on a Linux system?
Linear Mode
