Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 30, 2011, 06:26 AM   #1
ascotilla
macrumors newbie
 
Join Date: Jun 2011
undefined symbols

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!!
ascotilla is offline   0 Reply With Quote
Old Jun 30, 2011, 06:34 AM   #2
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
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
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Jun 30, 2011, 06:49 AM   #3
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: 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 is offline   0 Reply With Quote
Old Jun 30, 2011, 06:09 PM   #4
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
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
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Jun 30, 2011, 06:23 PM   #5
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Quote:
Originally Posted by balamw View Post
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.
jiminaus is offline   0 Reply With Quote
Old Jun 30, 2011, 07:54 PM   #6
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
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
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
GCC complaining about undefined symbols when trying to compile for 10.5 in 10.6 foidulus Mac Programming 2 May 4, 2010 01:07 PM
gettext: undefined symbol vocaro Mac Programming 7 Apr 7, 2010 05:08 PM
undefined symbol problem with Xcode linker Hinchy Mac Programming 1 Nov 13, 2009 06:06 PM
undefined symbol jamesapp Mac Programming 1 May 29, 2008 12:36 PM
gcc compilation error -- ld: Undefined symbols pigbrain Mac Programming 6 Jul 19, 2005 07:23 AM


All times are GMT -5. The time now is 11:49 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC