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

Miles Lubin miles.lubin at gmail.com
Mon Oct 13 11:47:09 EDT 2014


Hi Joshua,

How are you timing the command-line interface? Are you including the time
that PuLP uses to generate the model?

Anyway, Instead of CoinMP, I would recommend using the new Cbc C interface
(which I worked on). For an example, see
https://projects.coin-or.org/Cbc/browser/trunk/Cbc/test/CInterfaceTest.c#L31.
The interface is fully documented inline with doxygen and is included in
the 2.8.12 release.

Miles

On Mon, Oct 13, 2014 at 7:12 AM, Joshua Arnott <josh at snorfalorpagus.net>
wrote:

> 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
>>
>
>
> _______________________________________________
> 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/20141013/5afa4e56/attachment.html>


More information about the Coin-discuss mailing list