Decision Optimization

 View Only
  • 1.  C/C++ CXXlpopt() crashes my app!

    Posted Wed March 23, 2022 09:09 PM

    I am trying to compile CPLEX in a specific linux environment using static libraries. My specific application pulls data from Redis, so I am using the official hiredis library. My code simply loads a .sav model file and calls CPXXlpopt() with CPXPARAM_LPMethod set to CPX_ALG_DUAL (ie uses the dual simplex method). It compiles and runs, but my environement throws a SIGSEGV and crashes. It does not even throw an error from "status". Here is my ouptut showing the code runs up to a point. It successfully pings the redis server, loads the model, but then crashes:

    PING: PONG Warning: File contains basis. Basis is loaded. Time To Load Model (CPU sec) = 0.96

    Below is a portion of my make file (I am including it because it may be relevant):

    #compiler CXX := g++ #compiler flags -ggdb is for debugging CXX_FLAGS := -std=c++17 -DSSL_SUPPORT=1#REMOVE "--static" when compiling locally -DSSL_SUPPORT=1 #define the folders BIN := ./app/bin SRC := ./app/src INCLUDE := ./app/include LIBRARIES := ./app/lib HIR_INC := /usr/include/ HIR_LIB := /usr/lib/ CONCERT_LIB := /app/CPLEX/CPLEX_Studio201/concert/lib/x86-64_linux/static_pic CONCERT_INC := /app/CPLEX/CPLEX_Studio201/concert/include CPLEX_LIB := /app/CPLEX/CPLEX_Studio201/cplex/lib/x86-64_linux/static_pic CPLEX_INC := /app/CPLEX/CPLEX_Studio201/cplex/include ... $(BIN)/worker: $(SRC)/worker.cpp $(SRC)/utilities.cpp $(CXX) $(CXX_FLAGS) $^ -I$(INCLUDE) -I$(CPLEX_INC) -I$(CONCERT_INC) -I$(HIR_INC) -L$(HIR_LIB) -DIL_STD -L$(CPLEX_LIB) -L$(CONCERT_LIB) -L$(LIBRARIES) -lilocplex -lconcert -lcplex -l:libhiredis.a -l:libhiredis_ssl.a -l:libssl.a -l:libcrypto.a -lm -static-libstdc++ -lpthread -ldl -static-libgcc -o $




    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: C/C++ CXXlpopt() crashes my app!
    Best Answer

    Posted Thu March 24, 2022 12:05 AM

    Please try a few things:

    1. Set CPLEX parameter data read to 2 and re-compile and re-run your application. If there are some errors, please fix them.
    2. Use the CPLEX makefile files (for CPLEX samples) to compile your simple sample that only uses CPLEX API. Don't change any settings. Verify whether the application crashes.
    3. If step 1 runs without any error, try to remove all third-party references and libraries from your makefile and compile your simple sample that only uses CPLEX API. Verify whether the application crashes. If it crashes, check the differences between your makefile and the sample makefile.
    4. If step 3 doesn't crash, add back third-party references and libraries one by one. It is possible that certain library is not compatible with CPLEX.





    #DecisionOptimization
    #Support
    #SupportMigration


  • 3.  RE: C/C++ CXXlpopt() crashes my app!
    Best Answer

    Posted Thu March 24, 2022 05:20 PM

    ! Sometimes when one has been banging their head against a wall with linking issues, it is hard to take a step back and do the simplest thing.


    I removed the third party libraries first as you suggested and then tried compiling the basic program that loads the cplex model and calls CPXXlpopt(). That didn't work at first, so I ran `ldd` on the binary within my runtime environment to examine the paths to the shared libraries. When I moved the shared libraries to the correct paths in the runtime environment, the program worked!


    Next, I also removed all of the cplex code and tested with just the 3rd party application code. I was able to query my redis server no problem!


    I then attempted to add back the 3rd party libraries and include the CPLEX code as you suggested, now making sure to copy/move all of the required shared libraries into the run-time enviroment. However, I am now getting a System Error when trying to connect to redis.


    Here is the list of shared libraries I need:


    • linux-vdso.so.1 (0x00007ffd5896e000)
    • libhiredis_cluster.so.0.7 => /usr/lib/libhiredis_cluster.so.0.7 (0x00007fef098fb000)
    • libhiredis.so.1.0.3-dev => /usr/lib/libhiredis.so.1.0.3-dev (0x00007fef098e6000)
    • libhiredis_ssl.so.1.0.3-dev => /usr/lib/libhiredis_ssl.so.1.0.3-dev (0x00007fef098e1000)
    • libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007fef0984f000)
    • libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fef09566000)
    • libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fef09545000)
    • libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fef0953e000)
    • libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fef093ba000)
    • libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fef09237000)
    • libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fef0921d000)
    • libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fef0905c000)
    • /lib64/ld-linux-x86-64.so.2 (0x00007fef09922000


    if you think there is one which would be incompatible with CPLEX please let me know, but I believe the issue now lies with linking the 3rd party library.


    Thank you for all of your help!






    #DecisionOptimization
    #Support
    #SupportMigration


  • 4.  RE: C/C++ CXXlpopt() crashes my app!
    Best Answer

    Posted Tue March 29, 2022 03:22 PM

    I think you had opened a support case, so let the discussion continue there. I just have one quick tip: if you are using CPLEX Callable Library (CPX and CPXX functions) only, you don't need to link with -lilocplex -lconcert. Those are for users who need to use C++ API. You can use CPLEX Callable Library in C++ applications. You can check the differences in the Makefile for lpex2 and ilolpex2.






    #DecisionOptimization
    #Support
    #SupportMigration