Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29234 Discussions

Error when build Fortran Project in Xcode

lxh37
Beginner
1,651 Views

 

Hi, I have Mac Yosemite 10.10.3, Xcode 6.3 and Fortran composer_xe_2015.3.187.

I could build my project in command line using this command:

"/opt/intel/bin/ifort -static-intel -dynamiclib -openmp *.o -o libsamplesize.dylib"

I tried to use Xcode to debug as there is some issue with memory management,

this is my first time to use Xcode for Fortran project, I have followed instruction

how to create Fortran project in Xcode and linked "libiomp5.dylib" to

the project, but got error message below,

what I need to do to fix it? Thanks!

Ld /Users/admin_lxh37/Library/Developer/Xcode/DerivedData/smart-gdvirwgekqfyelbapbcdvzwwaqnc/Build/Products/Debug/smart normal x86_64
    cd /Users/admin_lxh37/Desktop/smart/smart
    export MACOSX_DEPLOYMENT_TARGET=10.10
    /usr/bin/ifort-15.0 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/admin_lxh37/Library/Developer/Xcode/DerivedData/smart-gdvirwgekqfyelbapbcdvzwwaqnc/Build/Products/Debug -L/opt/intel/composer_xe_2015.3.187/compiler/lib -F/Users/admin_lxh37/Library/Developer/Xcode/DerivedData/smart-gdvirwgekqfyelbapbcdvzwwaqnc/Build/Products/Debug -filelist /Users/admin_lxh37/Library/Developer/Xcode/DerivedData/smart-gdvirwgekqfyelbapbcdvzwwaqnc/Build/Intermediates/smart.build/Debug/smart.build/Objects-normal/x86_64/smart.LinkFileList -mmacosx-version-min=10.10 -dev-usr-root=/Applications/Xcode.app/Contents/Developer/usr -liomp5 -o /Users/admin_lxh37/Library/Developer/Xcode/DerivedData/smart-gdvirwgekqfyelbapbcdvzwwaqnc/Build/Products/Debug/smart

Undefined symbols for architecture x86_64:
  "_MAIN__", referenced from:
      _main in for_main.o
ld: symbol(s) not found for architecture x86_64
Command /usr/bin/ifort-15.0 failed with exit code 1

 

0 Kudos
1 Solution
Ron_Green
Moderator
1,651 Views

Intel Fortran integration into Xcode is a partial feature.  That is to say, Intel does not claim to have full integration into Xcode.  One can use the editor, but that is about it.  Debug and project builds are not fully supported.  Case in point, F90 codes with complex USE dependencies are often not built in the correct order.

Generally I recommend not using Xcode for anything other than a source code editor.  Everything else, use the command line.

Make sure to 'source /opt/intel/bin/compilervars.sh intel64'

then use 'gdb-ia' for your debugger.  This is an Intel-enhanced command line gdb - enhancements include support for modern Fortran 95/2003/2008

I can look into the first issue reported, but again, if you have module dependencies it's quite likey that you'll find bugs in the Xcode integration.  Intel does not claim support of integration into Xcode, it's a partial feature.

Ron

View solution in original post

0 Kudos
8 Replies
lxh37
Beginner
1,651 Views

 

I wonder what options I have to debug memory issues in Mac?

0 Kudos
John_A_4
Beginner
1,651 Views

And as long as ifort with Xcode is the subject...

When I use ifort from the command line, any compile errors are listed showing file name and line number where the error occurred.

When I build a project in Xcode with ifort as the compiler, I see name of the file where the error was found but not the line number. Is there maybe an Xcode project setting that controls this? 

Mac OS 10.9.5,/Xcode 6.2/ifort composer_xe_2015.3.187

Any comments/advice greatly appreciated.  

 

0 Kudos
Ron_Green
Moderator
1,652 Views

Intel Fortran integration into Xcode is a partial feature.  That is to say, Intel does not claim to have full integration into Xcode.  One can use the editor, but that is about it.  Debug and project builds are not fully supported.  Case in point, F90 codes with complex USE dependencies are often not built in the correct order.

Generally I recommend not using Xcode for anything other than a source code editor.  Everything else, use the command line.

Make sure to 'source /opt/intel/bin/compilervars.sh intel64'

then use 'gdb-ia' for your debugger.  This is an Intel-enhanced command line gdb - enhancements include support for modern Fortran 95/2003/2008

I can look into the first issue reported, but again, if you have module dependencies it's quite likey that you'll find bugs in the Xcode integration.  Intel does not claim support of integration into Xcode, it's a partial feature.

Ron

0 Kudos
Ron_Green
Moderator
1,651 Views

debugger:  gdb-ia is supported by Intel.  It has great support for Fortran.  IF you have any issues with debugging under gdb-ia go here:  https://software.intel.com/en-us/forums/debug-solutions

0 Kudos
lxh37
Beginner
1,651 Views

 

I used Fortran codes to create  a .dylib and called it from a web applet from Ruby On Rails,
 the web applet is very simple, basically just ask user to enter parameters, then call Fortran
to calculate the answer and posted the result. The error I got from Ruby is:

malloc: *** error for object 0x7fba21c81808: incorrect checksum for freed object - object was
probably modified after being freed. App 19814 stderr: *** set a breakpoint in malloc_error_break to debug

From the error message, it seems the issue is with memory handling, so I tried to compile Fortran codes
with option "-free" and "-check bounds", but don't get any error message, by the way, I have compiled it
and ran in older versions of Mac, it works fine. Only start to have the issue
when we tried to upgrade the machine to Yosemite and use the newest version of compiler...

Just wonder if gdb-ia will help...

Thanks!

Liz

0 Kudos
lxh37
Beginner
1,651 Views

 

I have never used gdb-ia, could you point me to the reference how to use it? Thanks!

Liz

0 Kudos
Ron_Green
Moderator
1,651 Views

google 'gdb tutorial'.  Same commands, just use Fortran syntax like

print mytype%component1%component2

commands are all gdb, nothing new or different.  gdb-ia just adds understanding of Fortran.

ron

 

0 Kudos
lxh37
Beginner
1,651 Views

 

I have created the project in Xcode successfully now, I can turn on Intel Fortran Compiler XE - runtime
features "check array and string bounds", "check for null pointers and allocatable array references,
the program runs without any problem (let it run for 1000 times). May I assume that the memory issue is not in
Fortran code?

0 Kudos
Reply