[Symphony] Symphony on C++ with Eclipse

Ted Ralphs ted at lehigh.edu
Tue Dec 4 10:35:43 EST 2012


Linux has separate search paths for executables and shared libraries. The
problem is that the directory where the COIN libraries live is not in your
library search path. You need to either set the environment variable
"LD_LIBRARY_PATH" to include the path to the directory where the COIN
libraries are installed or install them into one of the system library
paths, such as /usr/lib. Another option is to link with something like

-Wl,--rpath -Wl,/home/me/Coin-Pkg/lib


which embeds the path to the library in the executable. There is actually
quite a bit of documentation describing how to link to COIN libraries here:

https://projects.coin-or.org/BuildTools/wiki/user-examples#LinkingyourCodewithCOIN-ORLibraries

This should give you everything you need.

Cheers,

Ted

On Tue, Dec 4, 2012 at 6:57 AM, Hugh Medal <hugh.medal at msstate.edu> wrote:

> Thanks Ted.
>
> That helped. I added all of the libraries listed by the pkg-config tool to
> Eclipse. Now, my build is successful.
>
> However, when I try to run my class, I get this error:
>
> /home/hmedal/Documents/2_msu/research_manager/code/ide/eclipse/HughCPP/Debug/HughCPP:
> error while loading shared libraries: libOsiSym.so.2: cannot open shared
> object file: No such file or directory
>
> Do you have any ideas?
>
> Here is my class again:
>
> MySource.cpp
>
> #include "OsiSymSolverInterface.hpp"
>
> int main(int argc, char **argv)
> {
> OsiSymSolverInterface osi;
> }
>
> Here is the list of libraries I am using:
>
> Building target: HughCPP
> Invoking: GCC C++ Linker
> g++ -L/opt/ibm/ILOG/CPLEX_Studio124/cplex/lib/x86_sles10_4.1/static_pic
> -L/opt/ibm/ILOG/CPLEX_Studio124/concert/lib/x86_sles10_4.1/static_pic
> -L/opt/SYMPHONY-5.4.4/lib -o "HughCPP"  ./src/lagrangean/LRAlgorithm.o
> ./src/lagrangean/LRAlgorithm_test.o
> ./src/lagrangean/LagrangeanFormulation.o
> ./src/lagrangean/LagrangeanFormulation_test.o  ./src/knapsack/KnapsackDP.o
> ./src/knapsack/KnapsackDP_test.o  ./src/Lottery.o ./src/MegaLottery.o
> ./src/MySource.o   -lilocplex -lcplex -lconcert -lm -lpthread -lOsiSym
> -lSym -lCgl -lOsiClp -lClp -lOsi -lCoinUtils -lbz2 -lz -llapack -lblas
>
> Also, I tried using the Makefile in <prefix>/SYMPHONY/Examples to build
> my file (MySource.cpp). However, it gives this error:
>
> MySource.cpp:10:37: fatal error: OsiSymSolverInterface.hpp: No such file
> or directory
>
> I don't see any references to <prefix>/include in the Makefile.
>
> Thanks,
> Hugh
>
>
>
> On Sun, Dec 2, 2012 at 5:52 PM, Ted Ralphs <ted at lehigh.edu> wrote:
>
>> Hi Hugh,
>>
>> The problem is that you need to link more than just the SYMPHONY library.
>> There is a separate library for the OSI interface, as well as libraries for
>> a number of other dependent COIN projects. However, since you are in Linux,
>> the fix is easy. The most straightforward way to build your own application
>> is to just modify one of the files in the <prefix>/SYMPHONY/Examples
>> directory. There is a Makefile there that will build an executable from any
>> source file you provide. For example, simply typing "make milp" will build
>> the main function in milp.c and link it to SYMPHONY. If you put
>> MySource.cpp in the Examples directory and type "make MySource", it should
>> build properly. Note, however, that if you are going to use the OSI
>> interface, you will need to set "USE_OSI_INTERFACE" to TRUE.
>>
>> To give a little more detail in case you want to build you own makefile,
>> you can use the automatically generated Makefile in
>> <prefix>/SYMPHONY/Examples as a template. You will notice that the command
>> line for linking gets the list of libraries using the "pkg-config" command.
>> You can get the list of libraries explicitly using this command if you
>> like. For example, here is the command to get the list of libraries that
>> must be added when linking:
>>
>> PKG_CONFIG_PATH=<prefix>/lib/pkgconfig pkg-config --libs symphony
>>
>> You can also get a list of additional flags for building:
>>
>> PKG_CONFIG_PATH=<prefix>/lib/pkgconfig pkg-config --cflags symphony
>>
>> If you want to use the OSI interface, you need to replace "symphony" with
>> "osi-sym" in the above command.
>>
>> Another alternative is that the output of the pkg-config command is also
>> automatically installed in <prefix>/share/coin/doc/SYMPHONY/sym_addlibs.txt.
>>
>> This should get you going. Let me know if you have additional questions.
>>
>> Cheers,
>>
>> Ted
>>
>>
>> On Sat, Dec 1, 2012 at 11:03 AM, Hugh Medal <hugh.medal at msstate.edu>wrote:
>>
>>> Thank you Ted.
>>>
>>> *Here is my info:*
>>> OS: Linux (Ubuntu 12.04)
>>> Compiler: g++ (version 4.6.3)
>>> SYMPHONY version: 5.4.4
>>> Eclipse version: 4.2.0; using CDT plugin
>>>
>>> *Steps I have taken:*
>>> 1. Installed SYMPHONY 5.4.4 into my /opt directory (using ./configure,
>>> make, make install; I ran make test and it was successful)
>>> 2. Added the symphony include directories to Eclipse
>>> - Project > Properties > C/C++ Compiler > Settings > GCC C++ Compiler
>>> > Includes
>>> - added /opt/SYMPHONY-5.4.4/include
>>> and /opt/SYMPHONY-5.4.4/SYMPHONY/include to the "include paths" list
>>> 3. Added the symphony lib directory to Eclipse
>>> - Project > Properties > C/C++ Compiler > Settings > GCC C++ Linker
>>> > Libraries
>>> - added /opt/SYMPHONY-5.4.4/lib to the "Library search path" list
>>> 3. Added the symphony Libraries Eclipse
>>> - Project > Properties > C/C++ Compiler > Settings > GCC C++ Linker
>>> > Libraries
>>> - added "Sym" to the "Libraries" list (I am not sure if I need to add an
>>> more libraries)
>>> 4. Created a C++ project
>>> 5. Created the following .cpp file
>>>
>>> #include "coin/OsiSymSolverInterface.hpp"
>>>
>>> int main(int argc, char **argv)
>>> {
>>> OsiSymSolverInterface osi;
>>> }
>>>
>>> *Problems:*
>>> When I build my project, I am getting this message (see errors in bold):
>>>
>>> make all
>>> Building file: ../src/MySource.cpp
>>> Invoking: GCC C++ Compiler
>>> g++ -I/opt/ibm/ILOG/CPLEX_Studio124/cplex/include
>>> -I/opt/ibm/ILOG/CPLEX_Studio124/concert/include
>>> -I/opt/SYMPHONY-5.4.4/include -I/opt/SYMPHONY-5.4.4/SYMPHONY/include -O0
>>> -g3 -Wall -c -fmessage-length=0 -m32 -O -fPIC -fno-strict-aliasing
>>> -fexceptions -DNDEBUG -DIL_STD -MMD -MP -MF"src/MySource.d"
>>> -MT"src/MySource.d" -o "src/MySource.o" -c "../src/MySource.cpp"
>>> Finished building: ../src/MySource.cpp
>>>
>>> Building target: HughCPP
>>> Invoking: GCC C++ Linker
>>> g++ -L/opt/ibm/ILOG/CPLEX_Studio124/cplex/lib/x86_sles10_4.1/static_pic
>>> -L/opt/ibm/ILOG/CPLEX_Studio124/concert/lib/x86_sles10_4.1/static_pic
>>> -L/opt/SYMPHONY-5.4.4/lib -o "HughCPP"  ./src/Lottery.o ./src/MegaLottery.o
>>> ./src/MySource.o   -lilocplex -lcplex -lconcert -lm -lpthread -lSym
>>> ./src/MySource.o: In function `main':
>>> */home/hmedal/Documents/2_msu/research_manager/code/ide/eclipse/HughCPP/Debug/../src/MySource.cpp:125:
>>> undefined reference to `OsiSymSolverInterface::OsiSymSolverInterface()'*
>>> */home/hmedal/Documents/2_msu/research_manager/code/ide/eclipse/HughCPP/Debug/../src/MySource.cpp:125:
>>> undefined reference to `OsiSymSolverInterface::~OsiSymSolverInterface()'
>>> *
>>> *collect2: ld returned 1 exit status*
>>> *make: *** [HughCPP] Error 1*
>>>
>>>
>>> On Fri, Nov 30, 2012 at 9:38 AM, Ted Ralphs <ted at lehigh.edu> wrote:
>>>
>>>> I use Eclipse and can probably help, but you'll have to give some more
>>>> information, such as
>>>>
>>>> 1. OS
>>>> 2. Compiler
>>>> 3. SYMPHONY version
>>>> 4. What problems you've encountered
>>>>
>>>> Cheers,
>>>>
>>>> Ted
>>>>
>>>> On Thu, Nov 29, 2012 at 8:40 PM, Hugh Medal <hugh.medal at msstate.edu>wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> Has anyone had success getting SYMPHONY to work with Eclipse CDT? I
>>>>> tried some instructions for SMI (
>>>>> https://projects.coin-or.org/BuildTools/wiki/pm-howdoi) but couldn't
>>>>> get them to work.
>>>>>
>>>>> Thanks,
>>>>> Hugh
>>>>>
>>>>> --
>>>>> Hugh Medal
>>>>> Assistant Professor
>>>>> Industrial and Systems Engineering
>>>>> Mississippi State University
>>>>> Office: 260K McCain
>>>>> Office: 662-325-3923
>>>>> Cell Phone: 701-866-1179
>>>>> Email: hmedal at i <hmedal at uark.edu>se.msstate.edu
>>>>> Website: hm568.ise.msstate.edu
>>>>> Twitter: hughmedal <https://twitter.com/#!/hughmedal>
>>>>> Facebook: Hugh Medal <http://www.facebook.com/hugh.medal>
>>>>> LinkedIn: Hugh Medal<http://www.linkedin.com/profile/view?id=65478854&authType=name&authToken=lX4B&pvs=pp>
>>>>> Google+: Hugh Medal<https://plus.google.com/111704068836614551361/posts>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Symphony mailing list
>>>>> Symphony at list.coin-or.org
>>>>> http://list.coin-or.org/mailman/listinfo/symphony
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dr. Ted Ralphs
>>>> Associate Professor, Lehigh University
>>>> (610) 628-1280
>>>> ted 'at' lehigh 'dot' edu
>>>> coral.ie.lehigh.edu/~ted
>>>>
>>>>
>>>
>>>
>>> --
>>> Hugh Medal
>>> Assistant Professor
>>> Industrial and Systems Engineering
>>> Mississippi State University
>>> Office: 260K McCain
>>> Office: 662-325-3923
>>> Cell Phone: 701-866-1179
>>> Email: hmedal at i <hmedal at uark.edu>se.msstate.edu
>>> Website: hm568.ise.msstate.edu
>>> Twitter: hughmedal <https://twitter.com/#!/hughmedal>
>>> Facebook: Hugh Medal <http://www.facebook.com/hugh.medal>
>>> LinkedIn: Hugh Medal<http://www.linkedin.com/profile/view?id=65478854&authType=name&authToken=lX4B&pvs=pp>
>>> Google+: Hugh Medal<https://plus.google.com/111704068836614551361/posts>
>>>
>>>
>>
>>
>> --
>> Dr. Ted Ralphs
>> Associate Professor, Lehigh University
>> (610) 628-1280
>> ted 'at' lehigh 'dot' edu
>> coral.ie.lehigh.edu/~ted
>>
>>
>
>
> --
> Hugh Medal
> Assistant Professor
> Industrial and Systems Engineering
> Mississippi State University
> Office: 260K McCain
> Office: 662-325-3923
> Cell Phone: 701-866-1179
> Email: hmedal at i <hmedal at uark.edu>se.msstate.edu
> Website: hm568.ise.msstate.edu
> Twitter: hughmedal <https://twitter.com/#!/hughmedal>
> Facebook: Hugh Medal <http://www.facebook.com/hugh.medal>
> LinkedIn: Hugh Medal<http://www.linkedin.com/profile/view?id=65478854&authType=name&authToken=lX4B&pvs=pp>
> Google+: Hugh Medal <https://plus.google.com/111704068836614551361/posts>
>
>


-- 
Dr. Ted Ralphs
Associate Professor, Lehigh University
(610) 628-1280
ted 'at' lehigh 'dot' edu
coral.ie.lehigh.edu/~ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/symphony/attachments/20121204/986aae19/attachment.html>


More information about the Symphony mailing list