[Cbc] Static linking from own code in Linux
Stefan Vigerske
stefan at math.hu-berlin.de
Mon Feb 22 05:43:40 EST 2016
Hi,
delete the .so files from $OSICBC_HOME/lib before you link your
executable, or link with -static.
Stefan
On 02/22/2016 03:36 AM, Gleb Belov wrote:
> It links now! But:
>
> bg at bg-vbox:/media/sf_SHARED/prj/libmzn/build$ mzn-cbc
> mzn-cbc: error while loading shared libraries: libCgl.so.0: cannot open
> shared object file: No such file or directory
>
> I compiled cbc as follows:
> ./configure -C --disable-shared --enable-static && make -j 2 && make
> install
>
> Gleb
>
> On 22/02/2016 12:01 PM, Ted Ralphs wrote:
>> I'm pretty sure this is a link order problem. If you modify the link
>> order to
>>
>> -lCbcSolver -lCbc -lCgl -lOsiClp -lClpSolver -lClp -lOsi -lCoinUtils
>>
>> I'm guessing the problem will go away. I had forgotten that I guess
>> this was only a problem with static libraries.
>>
>> Ted
>>
>> On Sun, Feb 21, 2016 at 7:07 PM, Gleb Belov <gleb.belov at monash.edu
>> <mailto:gleb.belov at monash.edu>> wrote:
>>
>> Hi Ted,
>>
>> the linker does not really find any functions in the libraries,
>> although it finds all the .a files. The relevant part of cmake's
>> output is attached. Here are the contents of CBC's lib directory:
>>
>> bg at bg-vbox:/media/sf_SHARED/prj/libmzn/build$ ls $OSICBC_HOME/lib
>> libCbc.a libCbcSolver.a libCgl.a libClp.a libClpSolver.a
>> libCoinUtils.a libOsi.a libOsiCbc.la libOsiClp.la
>> libOsiCommonTests.la pkgconfig
>> libCbc.la libCbcSolver.la libCgl.la libClp.la libClpSolver.la
>> libCoinUtils.la libOsiCbc.a libOsiClp.a libOsiCommonTests.a
>> libOsi.la
>>
>> Looking for one of the functions missed, writeMpsNative, gives:
>>
>> bg at bg-vbox:/media/sf_SHARED/prj/libmzn/build$ grep writeMpsNative
>> $OSICBC_HOME/lib/*
>> Binary file /home/bg/Documents/prj/coin-Cbc-2.9/lib/libCbc.a matches
>> Binary file /home/bg/Documents/prj/coin-Cbc-2.9/lib/libCbcSolver.a
>> matches
>> Binary file /home/bg/Documents/prj/coin-Cbc-2.9/lib/libOsi.a matches
>> Binary file /home/bg/Documents/prj/coin-Cbc-2.9/lib/libOsiCbc.a
>> matches
>> Binary file /home/bg/Documents/prj/coin-Cbc-2.9/lib/libOsiClp.a
>> matches
>> Binary file
>> /home/bg/Documents/prj/coin-Cbc-2.9/lib/libOsiCommonTests.a matches
>> grep: /home/bg/Documents/prj/coin-Cbc-2.9/lib/pkgconfig: Is a
>> directory
>>
>>
>> Gleb
>>
>> On 22/02/2016 10:36 AM, Ted Ralphs wrote:
>>> As far as I know, there shouldn't be anything special you need to
>>> do in order to link to static libraries in Linux. What's the
>>> error? On Windows, we only support generation of static libraries
>>> at this point, so nothing should be any different there.
>>>
>>> Ted
>>>
>>> On Sun, Feb 21, 2016 at 6:02 PM, Gleb Belov
>>> <gleb.belov at monash.edu <mailto:gleb.belov at monash.edu>> wrote:
>>>
>>> Now it works with 2268 without any further changes, thank you.
>>>
>>> Next question: when configuring with --enable-static
>>> --disable-shared, the /lib forlder has only .a (and probably
>>> .la) files and the examples' Makefile is not much different.
>>> However my executable does not link. Is there any specific
>>> link flag in this case? What is under Win?
>>>
>>
>>
>>
>>
>> --
>> Dr. Ted Ralphs
>> Professor, Lehigh University
>> (610) 628-1280
>> ted 'at' lehigh 'dot' edu
>> coral.ie.lehigh.edu/~ted <http://coral.ie.lehigh.edu/%7Eted>
>
>
>
>
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc
>
--
http://www.gams.com/~stefan
More information about the Cbc
mailing list