Skip to content

Commit

Permalink
Fix ipopt compilation on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Jun 22, 2015
1 parent 77a112e commit 164e53e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Makefile.common
Expand Up @@ -112,13 +112,14 @@ $(OMBUILDDIR)/include/omc/c/gc_pthread_redirects.h: 3rdParty/gc/include/gc_pthre
(cd 3rdParty/gc && autoreconf -vif && automake --add-missing && ./configure "--host=$(host)" $(LIBGC_EXTRA_CONFIGURATION) --disable-gcj-support --disable-java-finalization --enable-large-config CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS) -DLARGE_CONFIG -DTHREAD_LOCAL_ALLOC")

3rdParty/Ipopt/Makefile: $(LAPACK_TARGET)
(cd 3rdParty/Ipopt && ./configure --with-pic "CC=$(CC)" CFLAGS="$(CFLAGS)" CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" F77="$(FC)" LDFLAGS="-L$(OMBUILDDIR)/$(LIB_OMC) $(LDFLAGS)" --with-lapack-lib="$(LD_LAPACK)" --with-blas-lib="$(LD_LAPACK)" "--host=$(host)" --without-metis --without-HSLold --without-HSL)
@# Note: CXX is passed LDFLAGS, which is wrong. However, Ipopt does not respect LDFLAGS and fails to link OSX C++ code if we do not do this.
(cd 3rdParty/Ipopt && ./configure --with-pic "CC=$(CC)" CFLAGS="$(CFLAGS)" CXX="$(CXX) $(LDFLAGS)" CXXFLAGS="$(CXXFLAGS)" F77="$(FC)" LDFLAGS="-L$(OMBUILDDIR)/$(LIB_OMC) $(LDFLAGS)" --with-lapack-lib="$(LD_LAPACK)" --with-blas-lib="$(LD_LAPACK)" "--host=$(host)" --without-metis --without-HSLold --without-HSL)

$(OMBUILDDIR)/$(LIB_OMC)/libipopt.la: 3rdParty/Ipopt/Makefile
$(MAKE) -C 3rdParty/Ipopt
$(MAKE) -C 3rdParty/Ipopt install
test ! `uname` = Darwin || install_name_tool -id @rpath/libipopt.1.9.6.dylib 3rdParty/Ipopt/lib/libipopt.1.9.6.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/libcoinmumps.1.4.11.dylib 3rdParty/Ipopt/lib/libcoinmumps.1.4.11.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/libipopt.0.0.0.dylib 3rdParty/Ipopt/lib/libipopt.0.0.0.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/libcoinmumps.1.5.2.dylib 3rdParty/Ipopt/lib/libcoinmumps.1.5.2.dylib
cp -a 3rdParty/Ipopt/lib*/*.* $(OMBUILDDIR)/$(LIB_OMC)

ipopt: $(OMBUILDDIR)/$(LIB_OMC)/libipopt.la
Expand Down
5 changes: 4 additions & 1 deletion configure.ac
Expand Up @@ -195,8 +195,11 @@ else # Is Darwin

AC_LANG_PUSH([C++])
OLD_CXXFLAGS=$CXXFLAGS
OLD_LDFLAGS=$LDFLAGS
for flag in -stdlib=libstdc++; do
AC_TRY_LINK([], [return 0;], [CXXFLAGS="$OLD_CXXFLAGS $flag"],[CXXFLAGS="$OLD_CXXFLAGS"])
CXXFLAGS="$OLD_CXXFLAGS $flag"
LDFLAGS="$OLD_LDFLAGS $flag"
AC_TRY_LINK([], [return 0;], [],[CXXFLAGS="$OLD_CXXFLAGS"; LDFLAGS="$OLD_LDFLAGS"])
done
AC_LANG_POP([C++])

Expand Down

0 comments on commit 164e53e

Please sign in to comment.