0

I'm trying to link soplex (the infinite precision LP solver of SCIP) in my C/C++ code. I managed to install soplex in my linux machine and from the command line it works.

My problem is that I do not manage to link it in my code:

I'm currently using a normal makefile in which I've put:

#sopleX HERE
SOPLEX_DIR =  /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib
SOPLEX_INCLUDE= /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/src

LP_LIBS = -L/usr/lib/x86_64-linux-gnu/ -lgmp  -L$(CPLEXLIBDIR) -lilocplex -lcplex  -lm -lpthread -ldl  -frounding-math -L$(GRBLIBDIR) -lgurobi90 -L$(SOPLEX_DIR)  -lsoplex 

DBG= -O3 -DIL_STD

INCDIR = -I. -I$(LP_INCLUDE) -I/usr/local/include -I$(GRB_LP_INCLUDE) -I$(SOPLEX_INCLUDE)

CXXFLAGS =  $(DBG) $(INCDIR) 

.c.o:
    gcc -c $(CXXFLAGS) $< -o $@

#LDLIBS = $(CONCORDE_LIBS) $(MY_LIBS) $(LP_LIBS) 
#LDLIBS = $(CONCORDE_LIBS) $(LP_LIBS) 
LDLIBS = $(LP_LIBS)

all:BPPS

BPPS: $(OBJS)
        $(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDLIBS)

$(OBJS): Makefile

clean:
    rm -f $(OBJS) rm BPPS

but when I try to compile it gives me a series of errors:

g++  -O3 -DIL_STD -I. -I/home/fabio/ILOG/CPLEX_Studio_AcademicResearch129/cplex/include/ilcplex -I/usr/local/include -I/home/fabio/GUROBI/gurobi903/linux64/include -I/home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/src  -o BPPS src/Main.o src/DP.o src/DP_LEX.o src/BPPS_BP_MASTER.o src/BPPS_BP_PRICER.o src/BPPS_BP_TREE.o src/BPPS_BP_TRIPLETS.o src/BPPS_BP_DIVING.o src/BPPS_BP_LP_HEUR.o src/BPPS_BP_SP_HEUR.o src/BPPS_BP_MAPPING.o src/REDUCTIONS.o src/preprocessing.o src/global_functions.o source/errors.o source/dp_master.o source/heap.o source/mckpsc-ls.o source/sort.o source/tools.o src/BPPS_FORM_B.o src/BPPS_FORM_A.o -L/usr/lib/x86_64-linux-gnu/ -lgmp  -L/home/fabio/ILOG/CPLEX_Studio_AcademicResearch129/cplex/lib/x86-64_linux/static_pic -lilocplex -lcplex  -lm -lpthread -ldl  -frounding-math -L/home/fabio/GUROBI/gurobi903/linux64/lib -lgurobi90 -L/home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib  -lsoplex 
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::~Rational()':
rational.cpp:(.text+0x44): undefined reference to `__gmpq_clear'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::freeListMem()':
rational.cpp:(.text+0x138): undefined reference to `__gmpq_clear'
/usr/bin/ld: rational.cpp:(.text+0x157): undefined reference to `__gmpq_clear'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::disableListMem()':
rational.cpp:(.text+0x1f8): undefined reference to `__gmpq_clear'
/usr/bin/ld: rational.cpp:(.text+0x217): undefined reference to `__gmpq_clear'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator=(soplex::Rational const&)':
rational.cpp:(.text+0x2a0): undefined reference to `__gmpq_set'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator=(long double const&)':
rational.cpp:(.text+0x2ec): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x30c): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x32c): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x34b): undefined reference to `__gmpq_set_d'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator=(double const&)':
rational.cpp:(.text+0x398): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x3b2): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x3ca): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x3d9): undefined reference to `__gmpq_set_d'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator=(int const&)':
rational.cpp:(.text+0x413): undefined reference to `__gmpq_set_si'
/usr/bin/ld: rational.cpp:(.text+0x428): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x440): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x458): undefined reference to `__gmpq_set'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator=(__mpq_struct const (&) [1])':
rational.cpp:(.text+0x47d): undefined reference to `__gmpq_set'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator double() const':
rational.cpp:(.text+0x4aa): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x4bd): undefined reference to `__gmpq_equal'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator long double() const':
rational.cpp:(.text+0x51e): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x531): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x53d): undefined reference to `__gmpq_get_d'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator float() const':
rational.cpp:(.text+0x59e): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x5b9): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x5cd): undefined reference to `__gmpq_get_d'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator+=(soplex::Rational const&)':
rational.cpp:(.text+0x641): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x654): undefined reference to `__gmpq_add'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator-=(soplex::Rational const&)':
rational.cpp:(.text+0x681): undefined reference to `__gmpq_sub'
/usr/bin/ld: rational.cpp:(.text+0x694): undefined reference to `__gmpq_set'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator*=(soplex::Rational const&)':
rational.cpp:(.text+0x6e2): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x6f1): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x707): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x716): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x72a): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x753): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x76f): undefined reference to `__gmpq_set'
/usr/bin/ld: rational.cpp:(.text+0x782): undefined reference to `__gmpq_mul'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::operator/=(soplex::Rational const&)':
rational.cpp:(.text+0x7c0): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x7d6): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x7e5): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x7f4): undefined reference to `__gmpq_equal'
/usr/bin/ld: rational.cpp:(.text+0x806): undefined reference to `__gmpq_div'
/usr/bin/ld: rational.cpp:(.text+0x827): undefined reference to `__gmpq_inv'
/usr/bin/ld: rational.cpp:(.text+0x84f): undefined reference to `__gmpq_inv'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::invert()':
rational.cpp:(.text+0x870): undefined reference to `__gmpq_inv'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::powRound()':
rational.cpp:(.text+0x8a5): undefined reference to `__gmpz_init'
/usr/bin/ld: rational.cpp:(.text+0x8b5): undefined reference to `__gmpz_cdiv_q'
/usr/bin/ld: rational.cpp:(.text+0x8c5): undefined reference to `__gmpz_sub_ui'
/usr/bin/ld: rational.cpp:(.text+0x8d2): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: rational.cpp:(.text+0x8e2): undefined reference to `__gmpz_ui_pow_ui'
/usr/bin/ld: rational.cpp:(.text+0x8ee): undefined reference to `__gmpq_set_z'
/usr/bin/ld: rational.cpp:(.text+0x8f6): undefined reference to `__gmpz_clear'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::isAdjacentTo(double const&) const':
rational.cpp:(.text+0x94b): undefined reference to `__gmpq_get_d'
/usr/bin/ld: rational.cpp:(.text+0x959): undefined reference to `__gmpq_init'
/usr/bin/ld: rational.cpp:(.text+0x96b): undefined reference to `__gmpq_set_d'
/usr/bin/ld: rational.cpp:(.text+0x976): undefined reference to `__gmpq_cmp'
/usr/bin/ld: rational.cpp:(.text+0x980): undefined reference to `__gmpq_clear'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::Rational::sizeInBase(int) const':
rational.cpp:(.text+0xa92): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: rational.cpp:(.text+0xaa1): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::readStringRational(char const*, soplex::Rational&)':
rational.cpp:(.text+0xb2e): undefined reference to `__gmpq_set_str'
/usr/bin/ld: rational.cpp:(.text+0xb6d): undefined reference to `__gmpq_canonicalize'
/usr/bin/ld: rational.cpp:(.text+0xba2): undefined reference to `__gmpz_init'
/usr/bin/ld: rational.cpp:(.text+0xbaa): undefined reference to `__gmpq_init'
/usr/bin/ld: rational.cpp:(.text+0xc99): undefined reference to `__gmpq_set_str'
/usr/bin/ld: rational.cpp:(.text+0xcaa): undefined reference to `__gmpq_canonicalize'
/usr/bin/ld: rational.cpp:(.text+0xcd8): undefined reference to `__gmpq_canonicalize'
/usr/bin/ld: rational.cpp:(.text+0xce0): undefined reference to `__gmpz_clear'
/usr/bin/ld: rational.cpp:(.text+0xce8): undefined reference to `__gmpq_clear'
/usr/bin/ld: rational.cpp:(.text+0xdfb): undefined reference to `__gmpz_ui_pow_ui'
/usr/bin/ld: rational.cpp:(.text+0xe06): undefined reference to `__gmpq_set_z'
/usr/bin/ld: rational.cpp:(.text+0xe15): undefined reference to `__gmpq_mul'
/usr/bin/ld: rational.cpp:(.text+0xe82): undefined reference to `__gmpz_ui_pow_ui'
/usr/bin/ld: rational.cpp:(.text+0xe8d): undefined reference to `__gmpq_set_z'
/usr/bin/ld: rational.cpp:(.text+0xe9c): undefined reference to `__gmpq_div'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator<<(std::ostream&, soplex::Rational const&)':
rational.cpp:(.text+0xede): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: rational.cpp:(.text+0xeef): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: rational.cpp:(.text+0xf0c): undefined reference to `__gmpq_get_str'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator==(soplex::Rational const&, soplex::Rational const&)':
rational.cpp:(.text+0xf7f): undefined reference to `__gmpq_equal'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator!=(soplex::Rational const&, soplex::Rational const&)':
rational.cpp:(.text+0xf9f): undefined reference to `__gmpq_equal'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator<(soplex::Rational const&, soplex::Rational const&)':
rational.cpp:(.text+0xfbf): undefined reference to `__gmpq_cmp'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator<=(soplex::Rational const&, soplex::Rational const&)':
rational.cpp:(.text+0xfdf): undefined reference to `__gmpq_cmp'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator>(soplex::Rational const&, soplex::Rational const&)':
rational.cpp:(.text+0xfff): undefined reference to `__gmpq_cmp'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::operator>=(soplex::Rational const&, soplex::Rational const&)':
rational.cpp:(.text+0x101f): undefined reference to `__gmpq_cmp'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::totalSizeRational(soplex::Rational const*, int, int)':
rational.cpp:(.text+0x108e): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: rational.cpp:(.text+0x109d): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::dlcmSizeRational(soplex::Rational const*, int, int)':
rational.cpp:(.text+0x1103): undefined reference to `__gmpz_init_set_ui'
/usr/bin/ld: rational.cpp:(.text+0x1132): undefined reference to `__gmpz_lcm'
/usr/bin/ld: rational.cpp:(.text+0x1142): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: rational.cpp:(.text+0x114d): undefined reference to `__gmpz_clear'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::dmaxSizeRational(soplex::Rational const*, int, int)':
rational.cpp:(.text+0x11b2): undefined reference to `__gmpz_sizeinbase'
/usr/bin/ld: /home/fabio/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid/lib/libsoplex.a(rational.cpp.o): in function `soplex::rationalToString[abi:cxx11](soplex::Rational const&, int)':
rational.cpp:(.text+0x1245): undefined reference to `__gmpf_init2'
/usr/bin/ld: rational.cpp:(.text+0x1251): undefined reference to `__gmpf_set_q'
/usr/bin/ld: rational.cpp:(.text+0x1267): undefined reference to `__gmpf_out_str'
/usr/bin/ld: rational.cpp:(.text+0x1274): undefined reference to `__gmpf_clear'
/usr/bin/ld: 

[.....]

I think that there must be a problem linking the libraries of gmp, can anybody please help me?

The library gmp is here:

fabio@canarino3:~/Dropbox/WORKING/SETUP_BPP_CODE/soplex-5.0.1/buid$ grep gmp soplex-targets.cmake 
  INTERFACE_LINK_LIBRARIES "/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libgmp.so;/usr/lib/x86_64-linux-gnu/libgmpxx.so;quadmath"
  INTERFACE_LINK_LIBRARIES "/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libgmp.so;/usr/lib/x86_64-linux-gnu/libgmpxx.so;quadmath"

I've built soplex from source, dowloaded from the scip webpage

Do you have an example of makefile in which soplex is linked?

MANY THANKS!!!!

Bodo
  • 9,287
  • 1
  • 13
  • 29
fabio
  • 1
  • 1
  • Check where `libgmp` is. Maybe the linker does not find it or finds a wrong version. How did you install soplex? Built from source? Please [edit] your question to answer or to add information or clarification. – Bodo Sep 15 '20 at 18:22
  • many thanks, I've updated my question, I've installed gmp using the apt-get install functions and I've built soplex from source. – fabio Sep 15 '20 at 18:34
  • Specifying libraries with absolute path in `INTERFACE_LINK_LIBRARIES` looks strange, but that's probably not related to your problem. I think the order of the libraries is wrong. Try changing the order in `LP_LIBS`: `-lgmp` after `-lsoplex` – Bodo Sep 15 '20 at 19:21
  • also with the suggested order I have the same error:LP_LIBS = -L$(CPLEXLIBDIR) -lilocplex -lcplex -lm -lpthread -ldl -L$(GRBLIBDIR) -lgurobi90 -L$(SOPLEX_DIR) -lsoplex -lgmp – fabio Sep 15 '20 at 19:34
  • Please add all information to the question. Show what you have tried in your Makefile and the resulting command and error message. I just noticed that you specified `libgmp.so` and `libgmpxx.so` in `soplex-targets.cmake`. Try `-lgmp -lgmpxx`. – Bodo Sep 16 '20 at 07:19

0 Answers0