The problem you're running into is not due to Open MPI.  The Objective C and C 
compilers on OS X (and most platforms) are the same binary, so you should be 
able to use mpicc without any problems.  It will see the .m extension and 
switch to Objective C mode.  However, NSLog is in the Foundation framework, so 
you must add the compiler option

  -framework Foundation

to the compiler flags (both when compiling and linking).  If you ripped out all 
the MPI and used gcc directly to compile your example code, you'd run into the 
same linker error without the -framework option.

Hope this helps,

Brian

--
  Brian W. Barrett
  Scalable System Software Group
  Sandia National Laboratories
________________________________________
From: users-boun...@open-mpi.org [users-boun...@open-mpi.org] on behalf of Jeff 
Squyres [jsquy...@cisco.com]
Sent: Monday, September 19, 2011 6:46 AM
To: Open MPI Users
Subject: Re: [OMPI users] Open MPI and Objective C

+1

You'll probably have to run "mpicc --showme" to see all the flags that OMPI is 
passing to the underlying compiler, and use those (or equivalents) to the ObjC 
compiler.


On Sep 19, 2011, at 8:34 AM, Ralph Castain wrote:

> Nothing to do with us - you call a function "NSLog" that Objective C doesn't 
> recognize. That isn't an MPI function.
>
> On Sep 18, 2011, at 8:20 PM, Scott Wilcox wrote:
>
>> I have been asked to convert some C++ code using Open MPI to Objective C and 
>> I am having problems getting a simple Obj C program to compile.  I have 
>> searched through the FAQs and have not found anything specific.  Is it an 
>> incorrect assumption that the C interfaces work with Obj C, or am I missing 
>> something?
>>
>> Thanks in advance for your help!
>> Scott
>>
>>
>> open MPI version: 1.4.3
>> OSX 10.5.1
>>
>> file: main.m
>>
>> #import <Foundation/Foundation.h>
>> #import "mpi.h"
>>
>> int main (int argc, char** argv)
>>
>> {
>>    //***
>>    // Variable Declaration
>>    //***
>>    int theRank;
>>    int theSize;
>>
>>    //***
>>    // Initializing Message Passing Interface
>>    //***
>>    MPI_Init(&argc,&argv);
>>    MPI_Comm_size(MPI_COMM_WORLD,&theSize);
>>    MPI_Comm_rank(MPI_COMM_WORLD,&theRank);
>>    //*** end
>>
>>    NSLog(@"Executing open MPI Objective C");
>>
>> }
>>
>> Compile:
>>
>> [87]UNC ONLY: SAW>mpicc main.m -o test
>> Undefined symbols:
>>   "___CFConstantStringClassReference", referenced from:
>>       cfstring=Executing open MPI Objective C in ccj1AlL9.o
>>   "_NSLog", referenced from:
>>       _main in ccj1AlL9.o
>> ld: symbol(s) not found
>> collect2: ld returned 1 exit status
>> _______________________________________________
>> users mailing list
>> us...@open-mpi.org
>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
> _______________________________________________
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users


--
Jeff Squyres
jsquy...@cisco.com
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/


_______________________________________________
users mailing list
us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/users


Reply via email to