ERROR : bad magic number (not a Mach-O file)

Discussion in 'Mac Programming' started by OneDreamCloser, Jul 18, 2009.

  1. macrumors member

    Joined:
    Jun 16, 2008
    #1
    hi all,

    i m trying to run a tool written in C in X11,
    after re-declaring some things and tweaking the Makefile,
    i got the "make depend" working but when i do "make all"
    i get this error ...

    /usr/bin/ld: ALGORITHMS/algorithms.o bad magic number (not a Mach-O file)
    /usr/bin/ld: INPUTACTIONS/inputActions.o bad magic number (not a Mach-O file)
    /usr/bin/ld: OUTPUTACTIONS/outputActions.o bad magic number (not a Mach-O file)
    /usr/bin/ld: FABRICS/fabrics.o bad magic number (not a Mach-O file)
    /usr/bin/ld: TRAFFIC/traffic.o bad magic number (not a Mach-O file)
    collect2: ld returned 1 exit status
    make[2]: *** [sim] Error 1
    make[1]: *** [thisoptall] Error 2
    make: *** [all] Error 2

    normally, doing
    1. make depend ( correct )
    2. make all ( incorrect ??? )
    3. createsim -sim ( should work )
    ( attached you can find the source code and the makefile in case you needed to have a look )

    the problem is that i don t know what the message "bad magic number (not a Mach-O file)" means ...
    i would be thankful if someone could help me overcome this problem

    thanx in advance
     

    Attached Files:

  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    A make clean will get rid of all of the .o files that already exist. This looks like it was distributed with some of the things already compiled (presumably for another system like Linux, these look like ELF objects).

    After the make clean, try to start from step 1 and see if things go better.

    -Lee
     
  3. thread starter macrumors member

    Joined:
    Jun 16, 2008
    #3
    Thanks lee1210 for the help, but i already have tried that and unfortunately it didn t work, any other ideas ?
     
  4. macrumors 6502a

    John Jacob

    Joined:
    Feb 11, 2003
    Location:
    Columbia, MD
    #4
    From a terminal, do a file ALGORITHMS/algorithms.o (and so on for the other object files) and post the results here so we can see what kind of files these are.

    Edit: I downloaded the zip file and tried:

    make cleanall
    make depend
    make all

    And I got the following error:
    Code:
    make[2]: *** No rule to make target `ALGORITHMS/algorithms.o', needed by `sim'.  Stop.
    
    Edit2: From the makefile, I tried the following steps
    cd ALGORITHMS
    make optall


    But I got the following error:
    Code:
    make algorithms.o CFLAGS="-O3 -Wall -Wshadow -I.. -DLIST_HISTOGRAM -DLIST_STATS "
    gcc -O3 -Wall -Wshadow -I.. -DLIST_HISTOGRAM -DLIST_STATS    -c -o ap2driver.o ap2driver.c
    ap2driver.c:62:20: error: malloc.h: No such file or directory
    ap2driver.c: In function 'ap2driver':
    ap2driver.c:79: warning: implicit declaration of function 'malloc'
    ap2driver.c:79: warning: incompatible implicit declaration of built-in function 'malloc'
    ap2driver.c: In function 'assign2graph':
    ap2driver.c:127: warning: incompatible implicit declaration of built-in function 'malloc'
    make[1]: *** [ap2driver.o] Error 1
    make: *** [optall] Error 2
    
     
  5. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #5
    Seems your code tries to include "malloc.h" and that file doesn't exist. It is not a standard C header file, or a standard Posix header file. Changing it to

    Code:
    #include <stdlib.h>
    
    is likely to help.
     
  6. thread starter macrumors member

    Joined:
    Jun 16, 2008
    #6
    thank you all for your help,

    make clean didn t work properly
    so a make cleanall or i a rm -f did the work

    i redeclared the library malloc.h with sys/malloc.h and everything it s ok now

    thank you all
     

Share This Page