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

Joshua Arnott josh at snorfalorpagus.net
Mon Oct 13 07:12:16 EDT 2014


Stuart,

I wasn't aware that using CoinMP like this was discouraged.

I'm solving a large number of relatively simple MILPs - around 60k, each
usually taking less than a second to solve with CBC. I've found that using
the CBC command line interface is 6-7x slower than the CoinMP shared
library, at least on Windows. That's the difference between by model taking
20 minutes or > 2 hours to run. I had assumed this was due to the
relatively expensive cost of process creation on Windows, which using the
shared library avoids.

Josh

On 12 October 2014 23:26, Stuart Mitchell <stu at stuartmitchell.com> wrote:

> Hi Josh,
> why do you want to use CoinMP with pulp anyway?
>
> The recommended/ default solver is command line cbc.
>
> CoinMP uses and old version of cbc and has several unresolved bugs.
>
> Stu
>
> On Mon, Oct 13, 2014 at 11:13 AM, Joshua Arnott <josh at snorfalorpagus.net>
> wrote:
>
>> 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
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> Coin-discuss mailing list
>> Coin-discuss at list.coin-or.org
>> http://list.coin-or.org/mailman/listinfo/coin-discuss
>>
>>
>
>
> --
> Stuart Mitchell
> PhD Engineering Science
> Extraordinary Freelance Programmer and Optimisation Guru
> www.stuartmitchell.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20141013/c4694148/attachment-0001.html>


More information about the Coin-discuss mailing list