Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Executable built on ubuntu 16 with cplex 12.8 worked just fine on ubuntu 20 with cplex 12.10

  • 1.  Executable built on ubuntu 16 with cplex 12.8 worked just fine on ubuntu 20 with cplex 12.10

    Posted Fri November 06, 2020 12:02 PM
    Edited by System Admin Fri January 20, 2023 04:42 PM
    Hello,

    I had a machine running Ubuntu 16.04 LTS with CPLEX 12.8 installed on it. I built an application requiring CPLEX 12.8. Below is the makefile I used to build the executable:

    ----

    # Environment
    MKDIR=mkdir
    CP=cp
    GREP=grep
    NM=nm
    CCADMIN=CCadmin
    RANLIB=ranlib
    CC=gcc
    CCC=g++
    CXX=g++
    FC=gfortran
    AS=as

    # Macros
    CND_PLATFORM=GNU-Linux
    CND_DLIB_EXT=so
    CND_CONF=Release
    CND_DISTDIR=dist
    CND_BUILDDIR=build

    # Include project Makefile
    include Makefile

    # Object Directory
    OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}

    # Object Files
    OBJECTFILES= \
    ${OBJECTDIR}/_ext/511e4115/populatelnx2.o

    # C Compiler Flags
    CFLAGS=

    # CC Compiler Flags
    CCFLAGS=-fPIC -fno-strict-aliasing -fexceptions -fopenmp
    CXXFLAGS=-fPIC -fno-strict-aliasing -fexceptions -fopenmp

    # Fortran Compiler Flags
    FFLAGS=

    # Assembler Flags
    ASFLAGS=

    # Link Libraries and Options
    LDLIBSOPTIONS=-L /opt/ibm/ILOG/CPLEX_Studio128/cplex/lib/x86-64_linux/static_pic

    # Build Targets
    .build-conf: ${BUILD_SUBPROJECTS}
    "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/linux

    ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/linux: ${OBJECTFILES}
    ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
    ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/linux ${OBJECTFILES} ${LDLIBSOPTIONS} -lcplex -lm -lpthread -ldl

    ${OBJECTDIR}/_ext/511e4115/populatelnx2.o: ../src/populatelnx2.cpp
    ${MKDIR} -p ${OBJECTDIR}/_ext/511e4115
    ${RM} "$@.d"
    $(COMPILE.cc) -O2 -DIL_STD -DNDEBUG -I/opt/ibm/ILOG/CPLEX_Studio128/cplex/include -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/511e4115/populatelnx2.o ../src/populatelnx2.cpp

    # Subprojects
    .build-subprojects:

    # Clean Targets
    .clean-conf: ${CLEAN_SUBPROJECTS}
    ${RM} -r ${CND_BUILDDIR}/${CND_CONF}

    # Subprojects
    .clean-subprojects:

    # Enable dependency checking
    .dep.inc: .depcheck-impl

    include .dep.inc

    ----

    This created an executable /dist/Release/GNU-Linux/linux

    Then, I installed a fresh copy of Ubuntu 20.10, and installed CPLEX 12.10 after deleting/formatting all previous content of the machine. I then downloaded my project folders one of which is /dist/Release/GNU-Linux/ . On running ./linux I was surprised that the application ran just fine. I thought it would complain that it does not find the right version of CPLEX libraries.

    Do the CPLEX function calls get embedded into the built executable so that the executable is guaranteed to run on any linux distribution in the future even though CPLEX 12.8 is not installed? I thought the built executable would have to make dynamic calls to CPLEX functions.

    Thanks.

    ------------------------------
    CPLEX User
    ------------------------------
    #DecisionOptimization


  • 2.  RE: Executable built on ubuntu 16 with cplex 12.8 worked just fine on ubuntu 20 with cplex 12.10

    Posted Sun November 08, 2020 03:49 AM
    I figured it out based on

    https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/APIs/C/link_non_win_intro.html

    Indeed on Ubuntu, once an application is statically linked with CPLEX, it should work on other linux distributions (unless some system calls change in the OS), even if CPLEX is not installed on the new machine. That is a nice feature!

    (1) If I recall correctly, on Windows as well, static libraries were available earlier. At present, only dynamic dll libraries are provided. Is there any particular reason why static libraries are not available on Windows?

    (2) Are there any benchmark results with CPLEX developers about running time of CPLEX applications on linking against static libraries vs dynamic libraries on non-Windows machines? I would expect static linking to be faster than dynamic linking, while the tradeoff is that the size of the executable is much higher.

    ------------------------------
    CPLEX User
    ------------------------------