Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ascotilla

macrumors newbie
Original poster
Jun 30, 2011
1
0
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!!
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
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
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
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.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
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

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.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.