andyvand / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Mac OS X: Symbol not found: ___gmp_version #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install gmpy on Mac OS 10.5
2. Start Python interpreter
3. import gmpy

What is the expected output? What do you see instead?
I get the following traceback:

Python 2.5.2 |EPD 2.5.2001| (r252:60911, Jul 22 2008, 07:21:23) 
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError:
dlopen(/Library/Frameworks/Python.framework/Versions/2.5.2001/lib/python2.5/site
-packages/gmpy.so,
2): Symbol not found: ___gmp_version
  Referenced from:
/Library/Frameworks/Python.framework/Versions/2.5.2001/lib/python2.5/site-packag
es/gmpy.so
  Expected in: dynamic lookup

What version of the product are you using? On what operating system?
Mac OS 10.5.5, Enthought Python 2.5.2, GMP 4.2.3 ('make check' passed),
gmpy trunk (r38).

Please provide any additional information below.
Same problem with GMP 4.2.2 installed via MacPorts.
Compiling and installing gmpy gave no errors, only the import fails.

Original issue reported on code.google.com by Dirk.L...@gmail.com on 20 Sep 2008 at 5:04

GoogleCodeExporter commented 9 years ago
It seems I had wrong versions of several libraries installed. 
Now everything works.

I started from scratch, removed everything gmp related from my system, 
uninstalled
the MacPorts version of libtool and libtool-devel and strictly followed the
instructions in mac_build.txt.

Original comment by Dirk.L...@gmail.com on 27 Sep 2008 at 7:35

GoogleCodeExporter commented 9 years ago
Closed, due to local build issue.

Thanks for letting us know it's been fixed.

Original comment by casevh on 14 Oct 2008 at 5:13

GoogleCodeExporter commented 9 years ago
I had about the same issue today.
My system is Snow Leopard 10.6.7 ( with python 2.6.1 built-in )

I downloaded the latest gmp sources ( 5.0.2 )
'configure', 'make' and 'make check' all passed with no errors.
( installing gmp ( 5.0.1) from macports also has no errors )

Next I downloaded the latest gmpy sources ( 1.14 )
$ sudo python setup.py install
running install
running build
running build_ext
running install_lib
copying build/lib.macosx-10.6-universal-2.6/gmpy.so -> 
/Library/Python/2.6/site-packages
running install_egg_info
Writing /Library/Python/2.6/site-packages/gmpy-1.14-py2.6.egg-info

When I try to run the test, it fails:
$ python test/gmpy_test.py
Traceback (most recent call last):
  File "test/gmpy_test.py", line 9, in <module>
    import gmpy
ImportError: dlopen(/Library/Python/2.6/site-packages/gmpy.so, 2): Symbol not 
found: ___gmp_version
  Referenced from: /Library/Python/2.6/site-packages/gmpy.so
  Expected in: flat namespace
 in /Library/Python/2.6/site-packages/gmpy.so

Any suggestions how to solve this ?

Original comment by djcom...@gmail.com on 5 Jun 2011 at 6:21

GoogleCodeExporter commented 9 years ago
Unfortunately, I don't have a Mac for testing. Can you the new gmpy2 2.0.0a2 
that was just released? There are very few changes from the perspective of 
integer/rational support. There is a Wiki page that describes the build process 
for Linux. I'm curious if the -Ddir= option will work on OS X.

Original comment by casevh on 9 Jun 2011 at 3:06

GoogleCodeExporter commented 9 years ago
Just reopened the issue...

Original comment by casevh on 9 Jun 2011 at 3:07

GoogleCodeExporter commented 9 years ago
I restarted with a clean system (removed every possible gmp and gmpy/gmpy2 file 
I could find)
First I build gmp 5.0.2 from source, logs included.
Next I tried the "short instructions" how to install gmpy2 (2.0.0a2)
Output of 'sudo python setup.py install' is in gmpy2_install.log (doet it 
assume mpfr is installed too?)
That failed, so I tried with the -Ddir option.
Output of 'sudo python setup.py build_ext -Ddir=/usr/local/lib install' is in 
gmpy2_install_Ddir.log
This does succeed.
Now 'python test_large.py" fails, but with a different symbol not found. :(

Original comment by djcom...@gmail.com on 10 Jun 2011 at 1:32

Attachments:

GoogleCodeExporter commented 9 years ago
Based on some of the error messages, I think I might know what's wrong. I'll 
make a new setup.py file for you to test. It will take me a couple of days 
since I'm busy at work.

Original comment by casevh on 10 Jun 2011 at 6:33

GoogleCodeExporter commented 9 years ago
Just a few ideas while looking through the logs. It looks like setup.py is 
trying to build a universal binary with support for PPC, i386, and x64. I'm 
guessing that GMP was only built for 64bit support. The error message in the 
build log also implies a mismatch in type sizes.

A Google search for "python extension mac os x universal" provides some links 
that might be useful.

I hope this helps. 

Original comment by casevh on 13 Jun 2011 at 6:27

GoogleCodeExporter commented 9 years ago
Yes, the problem is a 32bit vs 64bit problem.
According to what I've tried, GMP (5.0.2) can only be built for a 64bit 
architecture. (-arch=i386 failed to compile)
So building GMPY2 (2.0.0a2) should also be 64bit.
Further investigation revealed that python was running in 32bit mode, thus 
creating a 32bit GMPY2 for a 64bit GMP.

However, you can set a system-variable to make python run in 64bit mode.
$# defaults write com.apple.versioner.python Prefer-32-Bit -bool no

$# sudo python setup.py build_ext -Ddir=/usr/local/lib install

$# python test/gmpy_test.py
> Traceback (most recent call last):
>  File "test/gmpy_test.py", line 23, in <module>
>    import gmpy_test_mpf
>  File "/[...]/gmpy2-2.0.0a2/test/gmpy_test_mpf.py", line 12, in <module>
>    a=_g.mpfr('123.456')
> AttributeError: 'module' object has no attribute 'mpfr'

It seems to solve all the previous errors :) A simple testprogram I made also 
works fine.
But is it required to install mpfr too ?

Original comment by djcom...@gmail.com on 13 Jun 2011 at 1:35

GoogleCodeExporter commented 9 years ago
To force GMP to build a 32-bit version, you need to pass ABI=32 to configure.

If mpfr is not available, only integer and rational numbers are supported. If 
you need support for floating point numbers, then you'll need mpfr since 
support for the very limited mpf type from GMP has been removed.

I'll edit the build instructions later today. Would you be willing to 
proof-read / test them?

Original comment by casevh on 13 Jun 2011 at 6:20

GoogleCodeExporter commented 9 years ago
My apologies for this late reply.
I once again started with a clean system (removed everything gmp or gmpy)
For convenience, I restored the default factory setting (Snow Leopard 10.6.7):
$# defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

This is the summary what I did next:
$[gmp-5.0.2]# ./configure && make && make check && sudo make install
GMP installs successful.
$[mpfr-3.0.1]# ./configure && make && make check && sudo make install
MPFR installs successful.
$[gmpy2-2.0.0a2]# sudo python setup.py build_ext -Ddir=/usr/local/lib install
GMPY2 installs successful
$[gmpy2-2.0.0a2]# python test/gmpy_test.py
<snipped tests...>
1411 passed and 0 failed.
Test passed.

Python now still runs in 64bit mode, even though I changed the Prefer-32-Bit 
setting...
It looks solved, but I am not certain what the cause of the original problem 
was :(

Yes, you can always contact me to proof-read or test Mac installation 
instructions.

Original comment by djcom...@gmail.com on 23 Jun 2011 at 10:49

GoogleCodeExporter commented 9 years ago
I'm curious whether GMP is actually built for 32 or 64 bits.

What does gmpy2.mp_limbsize() return?

What does sys.long_info return?

Original comment by casevh on 29 Jun 2011 at 3:35

GoogleCodeExporter commented 9 years ago
Snow Leopard comes preinstalled with python 2.6.1
sys.long_info is only available in python versions 2.7 and above

=== gmpy2.mp_limbsize() ===
64
=== sys.float_info ===
sys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, 
min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, 
mant_dig=53, epsilon=2.2204460492503131e-16, radix=2, rounds=1)
=== sys.maxint === [this is a 64bit maxint]
9223372036854775807
=== sys.version_info ===
(2, 6, 1, 'final', 0)
=== sys.getsizeof( sys.maxint ) ===
24

If I force python to run in 32bit mode the above commands fail.
So it is logical to assume that all was build and running in 64bit.

Original comment by djcom...@gmail.com on 30 Jun 2011 at 7:04

GoogleCodeExporter commented 9 years ago
Thanks for the update. I'll add your instructions to the installation page.

BTW, I believe the last line in your instructions can be just:

sudo python setup.py install

The /usr/local directory is automatically searched for the lib & include 
directories. The -D option is only needed if the gmp and mpfr are installed in 
a location that isn't searched.

Original comment by casevh on 17 Jul 2011 at 6:14