[Coin-discuss] Symbol not found loading libCoinMP from Python ctypes

Joshua Arnott josh at snorfalorpagus.net
Sun Oct 12 18:13:19 EDT 2014


Miles,

Thanks. Using the '--enable-dependency-linking' argument seems to work.

However, I am now having trouble with a segfault with the following code
which exists with the call to CoinReadFile. I have the same segfault trying
to use PuLP. The same code runs fine on Linux.

#!/usr/bin/env python3

import ctypes
lib = ctypes.CDLL('libCoinMP.dylib', ctypes.RTLD_GLOBAL)
lib.CoinInitSolver('')
lib.CoinGetVersionStr.restype = ctypes.c_char_p
print(lib.CoinGetVersionStr())
lib.CoinCreateProblem.restype = ctypes.c_int
hprob = lib.CoinCreateProblem('test')
cstr = ctypes.c_char_p(bytes('pack1.mps', 'utf-8'))
print(lib.CoinReadFile(hprob, 3, cstr))
lib.CoinFreeSolver()

Josh

On 11 October 2014 19:02, Miles Lubin <miles.lubin at gmail.com> wrote:

> Hi Joshua,
>
> Try adding the '--enable-dependency-linking' argument to configure.
>
> Miles
>
> On Fri, Oct 10, 2014 at 5:57 PM, Joshua Arnott <josh at snorfalorpagus.net>
> wrote:
>
>> Hello,
>>
>> I’m trying to use the CoinMP library from Python 3 via ctypes. When I try
>> to load the shared library I get the following error:
>>
>> Python 3.4.1 (default, May 19 2014, 13:10:29)
>> [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import ctypes
>> >>> lib = ctypes.CDLL('libCoinMP.dylib')
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File
>> "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ctypes/__init__.py",
>> line 351, in __init__
>>     self._handle = _dlopen(self._name, mode)
>> OSError: dlopen(libCoinMP.dylib, 6): Symbol not found: _CbcOrClpRead_mode
>>   Referenced from: /usr/local/lib/libCoinMP.dylib
>>   Expected in: flat namespace
>>  in /usr/local/lib/libCoinMP.dylib
>>
>> However, when I “make test” everything runs correctly.
>>
>> Output from “nm” reports the symbol is undefined:
>>
>> U _CbcOrClpRead_mode
>>
>> I am getting similar errors for the other libraries, e.g.:
>>
>> Python 3.4.1 (default, May 19 2014, 13:10:29)
>> [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import ctypes
>> >>> ctypes.CDLL('libClp.dylib')
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File
>> "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ctypes/__init__.py",
>> line 351, in __init__
>>     self._handle = _dlopen(self._name, mode)
>> OSError: dlopen(libClp.dylib, 6): Symbol not found:
>> __ZN18CoinMessageHandler13checkSeverityEv
>>   Referenced from: /usr/local/lib/libClp.dylib
>>   Expected in: flat namespace
>>  in /usr/local/lib/libClp.dylib
>>
>> Running Mac OS X 10.9.5, with current CoinMP from SVN.
>>
>> Kind regards,
>>
>> Josh
>>
>> _______________________________________________
>> Coin-discuss mailing list
>> Coin-discuss at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/coin-discuss
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20141012/81f1bc25/attachment.html>


More information about the Coin-discuss mailing list