[Ipopt] Help on compile IPOPT c++ example (covert makefile to CMakeLists.txt), ubuntu 12.04, 64 bit , ipopt 11.0

Zhenli Lu zhenli.lu at ua.pt
Thu Jul 25 13:40:36 EDT 2013


Dear Stefan.
   Thank you very much for your email.
    Now it works with your solution. And I copy the makefile from Ipopt/turtorial/CodingExercise/Cpp/1-skeleton. And change the exe and *.o with my example shown in the documentation, and make, then ./exe it, it works.
   Now I want to know do you know how to change the makefile to a CMakeLists.txt, then I can make it easily to work with the other software in different framework.
   for example, the make file is shown as following, can some one help me to convert it to CMakeLists.txt.


---------------------------------------------------------------- 
# Copyright (C) 2009 International Business Machines and others.
# All Rights Reserved.
# This file is distributed under the Eclipse Public License.

# $Id: Makefile.in 1135 2007-12-27 19:23:06Z andreasw $

##########################################################################
#    You can modify this example makefile to fit for your own program.   #
#    Usually, you only need to change the five CHANGEME entries below.   #
##########################################################################

# CHANGEME: This should be the name of your executable
EXE = my_example

# CHANGEME: Here is the name of all object files corresponding to the source
#           code that you wrote in order to define the problem statement
OBJS = MyExample.o \
	hs071_nlp.o

# CHANGEME: Additional libraries
ADDLIBS =

# CHANGEME: Additional flags for compilation (e.g., include flags)
ADDINCFLAGS =

##########################################################################
#  Usually, you don't have to change anything below.  Note that if you   #
#  change certain compiler options, you might have to recompile Ipopt.   #
##########################################################################


# C++ Compiler command
CXX = g++

# C++ Compiler options
CXXFLAGS = -O3 -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long   -DIPOPT_BUILD

# additional C++ Compiler options for linking
CXXLINKFLAGS =  -Wl,--rpath -Wl,/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib

# Include directories (we use the CYGPATH_W variables to allow compilation with Windows compilers)
INCL = `PKG_CONFIG_PATH=/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib64/pkgconfig:/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib/pkgconfig:/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/share/pkgconfig:/opt/ros/fuerte/lib/pkgconfig: /usr/bin/pkg-config --cflags ipopt` $(ADDINCFLAGS)
#INCL = -I`$(CYGPATH_W) /home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/include/coin`  $(ADDINCFLAGS)

# Linker flags
LIBS = `PKG_CONFIG_PATH=/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib64/pkgconfig:/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib/pkgconfig:/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/share/pkgconfig:/opt/ros/fuerte/lib/pkgconfig: /usr/bin/pkg-config --libs ipopt`
##LIBS = -link -libpath:`$(CYGPATH_W) /home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib` libipopt.lib -lm  -ldl
#LIBS = -L/home/paulo/fuerte_work/IpoptBasedController/CoinIpopt/build/lib -lipopt -lm  -ldl

# The following is necessary under cygwin, if native compilers are used
CYGPATH_W = echo

all: $(EXE)

.SUFFIXES: .cpp .c .o .obj

$(EXE): $(OBJS)
	bla=;\
	for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
	$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $@ $$bla $(ADDLIBS) $(LIBS)

clean:
	rm -rf $(EXE) $(OBJS) ipopt.out

.cpp.o:
	$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ $<


.cpp.obj:
	$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `$(CYGPATH_W) '$<'`


--------------------------------------------------------------------    

Best regards,
 Zhenli
________________________________________
From: Stefan Vigerske [stefan at math.hu-berlin.de]
Sent: 25 July 2013 10:04
To: Zhenli Lu
Cc: ipopt at list.coin-or.org
Subject: Re: [Ipopt] Help on compile IPOPT c++ example, ubuntu 12.04, 64 bit , ipopt 11.0

Hi,

On 07/24/2013 10:51 PM, Zhenli Lu wrote:
> Dear All.
>      I am a new hand to install ipopt 11.0.
>      Based on the following website , I install ipopt without AMPL.
> https://projects.coin-or.org/Ipopt/browser/stable/3.11/Ipopt/doc/documentation.pdf?format=raw
>
> Question 1: how can I get AMPL by ./get. AMPL

The ftp access to netlib is currently not available.
You can download the ASL archive from
http://netlib.sandia.gov/cgi-bin/netlib/netlibfiles.tar?filename=netlib/ampl/solvers
and extract it in the ThirdParty/ASL directory by hand.

> Question 2: When I try to compile the example in CPP folder, I just rename makefile.in as makefile, and I installed gcc,g++,gfortran,. But when I run "make", it give the following information:
> /Cpp_example$ make
> make: *** No rule to make target `cpp_example. at OBJEXT@', needed by `cpp_example at EXEEXT@'. Stop.

You first have to configure, compile, and install Ipopt (configure;
make; make test; make install). In the examples directories of the Ipopt
build you will then have a usable Makefile.
Makefile.in is just a template that is used by configure to create a
Makefile that fits to your system.

Stefan

>
> Thanks for any help.
> Zhenli
>
>
>
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/ipopt
>




More information about the Ipopt mailing list