在Linux下设置CPLEX和Eclipse


for my own documentary and for those who need this.

Something Unrelated:

I used to use AMPL as my modeling language and solve the problem with CPLEX. However, later I realized that AMPL is just a modeling language, but not a generic programming language, which makes it incapable to handle my problem since I have to customize some parts of the algorithm. Then I started to use CONCERT from ILOG. At the same time, a “fancy friend” introduced me to use Python. I do not know for what reason I switched to LINUX, maybe because of the powerful command line. I got cplex set up, I got ampl set up and I got gcc set up, and then I need an IDE. I chose the popular one, eclipse. However, annoying things happened, I cannot compile my programs inside the IDE, while I can compile it with a self written make file. I need IDE because I want to make the debug easier. During that time, I need to reboot my computer many times to switch between windows and Linux, (I was thinking to use a virtual machine, but I did not do that). Fortunately, I got eclipse to work with cplex. It maybe not the best solution, but good enough to me, a newbie of Linux, programming, eclipse and cplex. :-) There was another story of installing Linux in my thinkpad T60, and make everything run smoothly.

Something Related:

OK, first thing is to install eclipse and CDT. There are lots of tutorials on this, so I will not cover this. Suppose you have CPLEX installed in the default directory: /usr/ilog/ . The setting is really nothing but putting the correct path into the correct place. As an old Chinese saying goes, a picture is better than thousands of words, I will put the screen shots below.

C++ compiler setting

Image 1 eclipse cplex

Directories

miscellaneous setting

Linker setting

@@update June 5, 2010:

I wrote this post two years ago, and I was using cplex 10.0. I don’t have a chance to try the new versions yet.

@@ update Nov 23,2010:

Thanks Yuan provided the setting for CPLEX 12

http://www4.ncsu.edu/~yzhang13/eclipse-cplex-linux2.html

  • YS

    抢个沙发

  • http://www.nosper.cn nosper

    hi, I just move to linux and want to install ampl. get some problem now:
    I downloaded the AMPL for Linux from the main web,
    then
    sudo gzip -d ampl.gz
    sudo mv ampl /usr/bin/
    sudo chmod +x /usr/bin/ampl
    But if I run ampl, the system tell me that no such file or directory
    Using command “which ampl”, the directory is true.

    finally i find two ways to solve this,first is enter the full file name include the path; second is go to the direct typing ./ampl.

    Could you kindly tell me why it doesn’t work by just typing ampl. thanks very much.

  • http://www.zh-cn.org L.J.

    @nosper
    Hi, nosper

    The problem is you did not add the path of the ampl path to PATH variable. Try to run

    export PATH=$PATH:/path/to/AMPL/directory

    Another way is make a link of the ampl file into the /usr/bin rather than coping the ampl file to that directory.

  • http://www.nosper.cn nosper

    thanks very much, it works now:)

  • yuan

    I really like your introduction, it saved me a lot time!

  • yuan

    I really like your introduction, it saved me a lot time!

  • ljxue

    Thank you ~~

  • http://www.zh-cn.org LJ

    Thank you ~~

  • http://www4.ncsu.edu/~yzhang13 Yuan

    If you are using the CPLEX 12.0, please check out my post here

    http://www4.ncsu.edu/~yzhang13/eclipse-cplex-linux2.html

  • L.J.

    @Yuan,
    Thanks. I think I saw you in INFORMS. I was president of INFORMS student Chapter at ASU.

  • http://www4.ncsu.edu/~yzhang13 Yuan

    @L.J.,
    Yeah, I must have seen you in the INFORMS student chapter breakfast reception. Congratulations again for winning the first student chapter prize!

  • Alfredo Morais

    What do you mean by “fancy friend” ??

    Cool info though bro!

  • http://www.zh-cn.org LJ

    Thanks Man. I don’t know if this still works or not. lol

    My “fancy friend” was a friend who wanted everything to be “fancy”, haha