undefined symbols

Discussion in 'Mac Programming' started by ascotilla, Jun 30, 2011.

  1. macrumors newbie

    Joined:
    Jun 30, 2011
    #1
    Hi all!

    I'm running a complex model written in two sections (one in fortran and the other in c++), compiled together by using a makefile. I was able to compile it in a linux system on a PC, using the intel compilers. We are a few people working with the same model, and it's quite usual to have compilation problems due to system differences.

    Now I'm trying to compile it in a Mac Pro, using the GNU compilers, and I was able to go beyond some of the problems, but I'm stucked with the last one.

    I copy it here:

    dyn1003-29:Macvs1-fromHPvs2 mmartinc$ make
    gfortran -o motif_lpj lpjmain_std.obj lpjio-std.obj Array.obj -I/Users/mmartinc/local/lib/lnetcdf_c++ -I/Users/mmartinc/local/lib/-lnetcdf
    ld: warning: in lpjio-std.obj, file was built for unsupported file format which is not the architecture being linked (i386)
    ld: warning: in Array.obj, file was built for unsupported file format which is not the architecture being linked (i386)
    Undefined symbols:
    "_getgrid_", referenced from:
    _MAIN__ in lpjmain_std.obj
    _MAIN__ in lpjmain_std.obj
    "_outgrid_", referenced from:
    _MAIN__ in lpjmain_std.obj
    "_outannual_", referenced from:
    _MAIN__ in lpjmain_std.obj
    "_termio_", referenced from:
    _MAIN__ in lpjmain_std.obj
    "_getclimate_", referenced from:
    _MAIN__ in lpjmain_std.obj
    _MAIN__ in lpjmain_std.obj
    "_initio_", referenced from:
    _MAIN__ in lpjmain_std.obj
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [motif_lpj] Error 1
    dyn1003-29:Macvs1-fromHPvs2 mmartinc$

    lpjmain_std.obj is one of the obj files created during the compilation, but I don't know where is the problem coming from...I'm sorry if it's too basic, but I'm still a newbie :)

    Any help will be more than welcome

    Thanks in advance!!
     
  2. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    Looks like you are trying to mix and match 64 bit and 32 bit (i386) code. I'd focus on fixing that first (pick one) and see if the problem gies away.

    It may not be finding the symbols because it can't link to them.

    B
     
  3. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #3
    If you're compiling under Mac OS X 10.6, gcc will build 64-bit code by default. Add the Mac OS X-specific -arch i386 option to gcc when you compiling the C++ components.
     
  4. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #4
    Wouldn't it make more sense to try and find a 64 bit version of fortran, IIRC the gfortran here: http://hpc.sourceforge.net/ was 64 bit capable. (Built on top of GCC).

    B
     
  5. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    Right. Fortran could benefit a lot from the 64bit instruction set, especially the extra registers. But in the meantime, to test if a 32-bit/64-bit mismatch is the problem, just had the arch option, which the OP may not have known about, what with it being Mac OS X-specific.
     
  6. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Works for me.

    The OP didn't specify where they got gfortran. But its gcc back end most likely also supports C++. It probably wouldn't hurt to make sure both sets of code are compiled with the same version of gcc and the same -arch.

    B
     

Share This Page