Discussion:
[f2py] Hello; f2py on Mac OS X with gfortran
Andreas Voellmy
2005-07-21 21:06:12 UTC
Permalink
Hello, I just joined the mailing list. This looks like a great tool. I
work for the National Weather Service, and this tool could become very
important for us. I'm trying to get started with it, but am having
some trouble.

I'm trying to compile the hello world sample on Mac OS X panther with
the gfortran (GCC 4.1.0 20050611) fortran compiler. I ran the
following command:

f2py --f77exec=/usr/local/bin/gfortran -c -m hello hello.f

The sources seem to compile. Then the following command is executed:

/usr/local/bin/gfortran -Wl,-framework -Wl,Python -lcc_dynamic -bundle
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/hellomodule.o
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/fortranobject.o
/tmp/tmpZaDVS4/hello.o
-L/usr/local/lib/gcc/powerpc-apple-darwin9.1.0/4.1.0 -lg2c -o
./hello.so

And then I get the following message (twice):

/usr/bin/ld: can't locate file for: -lcc_dynamic
collect2: ld returned 1 exit status

My apologies if this is a silly question, but I would really
appreciate any help on this issue.

Regards, Andreas
Andreas Voellmy
2005-07-21 21:34:01 UTC
Permalink
I compiled (manually) without the -lcc_dynamic option. So I compiled this:

/usr/local/bin/gfortran -Wl,-framework -Wl,Python -bundle
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/hellomodule.o
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/fortranobject.o
/tmp/tmpZaDVS4/hello.o
-L/usr/local/lib/gcc/powerpc-apple-darwin9.1.0/4.1.0 -lg2c -o
./hello.so

The command was successful and it built my hello.so file.

However, when I start up python and type "import hello", I get this error:

Fatal Python error: Interpreter not initialzed (version mismatch?)
Abort trap

I am using Python 2.3.5.

Does anybody know how I can fix this?

Thanks, Andreas
John Gleeson
2005-07-22 06:08:30 UTC
Permalink
Post by Andreas Voellmy
I compiled (manually) without the -lcc_dynamic option. So I
/usr/local/bin/gfortran -Wl,-framework -Wl,Python -bundle
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/hellomodule.o
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/fortranobject.o
/tmp/tmpZaDVS4/hello.o
-L/usr/local/lib/gcc/powerpc-apple-darwin9.1.0/4.1.0 -lg2c -o
./hello.so
The command was successful and it built my hello.so file.
Fatal Python error: Interpreter not initialzed (version mismatch?)
Abort trap
I am using Python 2.3.5.
Does anybody know how I can fix this?
Thanks, Andreas
The problem is that python was compiled with gcc 3.3:

$ /usr/bin/python
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Switch from gcc 4.0 to 3.3 using the command 'gcc_select 3.3'.
You can get a compatible g77 binary (v. 3.4) at HPC for OS X <http://
hpc.sourceforge.net/>

-John
Andreas Voellmy
2005-07-22 18:02:51 UTC
Permalink
Thanks for the tip.

I installed the g77 version into /usr/local/bin. Running
/usr/local/bin/gyy --version gives:

GNU Fortran (GCC) 3.4.4

Then I ran gcc_select 3.3. Now when I run gcc_select it shows:

Current default compiler:
gcc version 3.3 20030304 (Apple Computer, Inc. build 1809)

Then I ran f2py like this:
f2py -f77exec=/usr/local/bin/g77 -c -m hello hello.f

It has an error on linking saying:
g77: installation problem, cannot exec 'c++filt': No such file or directory.

It creates the hello.so file anyway. I started python and imported
hello, then got this error:

Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap

What am I doing wrong? It looks like the versions are still a problem.
Is my machine still not using the correct compiler?

Thanks! Andreas
Post by John Gleeson
Post by Andreas Voellmy
I compiled (manually) without the -lcc_dynamic option. So I
/usr/local/bin/gfortran -Wl,-framework -Wl,Python -bundle
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/hellomodule.o
/tmp/tmpZaDVS4/tmp/tmpZaDVS4/src/fortranobject.o
/tmp/tmpZaDVS4/hello.o
-L/usr/local/lib/gcc/powerpc-apple-darwin9.1.0/4.1.0 -lg2c -o
./hello.so
The command was successful and it built my hello.so file.
Fatal Python error: Interpreter not initialzed (version mismatch?)
Abort trap
I am using Python 2.3.5.
Does anybody know how I can fix this?
Thanks, Andreas
$ /usr/bin/python
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Switch from gcc 4.0 to 3.3 using the command 'gcc_select 3.3'.
You can get a compatible g77 binary (v. 3.4) at HPC for OS X <http://
hpc.sourceforge.net/>
-John
John Gleeson
2005-07-22 19:59:28 UTC
Permalink
On Jul 22, 2005, at 12:02 PM, Andreas Voellmy wrote:

<snip>
Post by Andreas Voellmy
f2py -f77exec=/usr/local/bin/g77 -c -m hello hello.f
g77: installation problem, cannot exec 'c++filt': No such file or directory.
<snip>
Thanks! Andreas
<snip>

Andreas,

Here's some advice that Chris Espinozo from Apple offered on the
Xcode-users
list recently.

HTH.

-John

On May 2, 2005, at 12:37 PM, Hugh Hoover wrote:
I no longer have a c++filt on my system after the upgrade.
<snip>


As far as we can tell, c++filt is in /usr/bin/c++filt as usual. It
should have been installed with the "BSD Packages" on Tiger install.
From Terminal, do

lsbom /Library/Receipts/BSD.pkg/Contents/Archive.bom | grep c\+\+filt

You should see

./usr/bin/c++filt 100755 0/0 351836 3781245634
./usr/share/man/man1/c++filt.1 100644 0/0 8512 1617226393

If you don't, try reinstalling the BSD packages from your Tiger
install disk.

Chris
Andreas Voellmy
2005-07-22 22:17:53 UTC
Permalink
Thanks. I ran lsbom and I get exactly the same output as Chris
Espinozo listed. So the problem might be something else.

Andreas
Post by John Gleeson
<snip>
Post by Andreas Voellmy
f2py -f77exec=/usr/local/bin/g77 -c -m hello hello.f
g77: installation problem, cannot exec 'c++filt': No such file or directory.
<snip>
Thanks! Andreas
<snip>
Andreas,
Here's some advice that Chris Espinozo from Apple offered on the
Xcode-users
list recently.
HTH.
-John
I no longer have a c++filt on my system after the upgrade.
<snip>
As far as we can tell, c++filt is in /usr/bin/c++filt as usual. It
should have been installed with the "BSD Packages" on Tiger install.
From Terminal, do
lsbom /Library/Receipts/BSD.pkg/Contents/Archive.bom | grep c\+\+filt
You should see
./usr/bin/c++filt 100755 0/0 351836 3781245634
./usr/share/man/man1/c++filt.1 100644 0/0 8512 1617226393
If you don't, try reinstalling the BSD packages from your Tiger
install disk.
Chris
Loading...