coin-or / qpOASES

Open-source C++ implementation of the recently proposed online active set strategy
GNU Lesser General Public License v2.1
365 stars 127 forks source link

"Undefined reference"-error when compiling example project #67

Open svigerske opened 4 years ago

svigerske commented 4 years ago

Issue created by migration from Trac.

Original creator: felixp

Original creation time: 2017-06-04 16:18:54

Assignee: ferreau

Version: 3.2.1

When running


 g++ -static example1.cpp ../src/BLASReplacement.cpp ../src/LAPACKReplacement.cpp  -I ../include/ -o statically_linked -L ../bin/ -l qpOASES

in the example folder as stated in [https://projects.coin-or.org/qpOASES/ticket/31] I get the following error:

../example1.cpp|66|undefined reference to `qpOASES::QProblem::QProblem(int, int, qpOASES::HessianType, qpOASES::BooleanType)'|

the executable examples that were automatically created when executing make run perfectly, though.

Any suggestions?

Kind regards, Felix

svigerske commented 4 years ago

Comment by zhaodong created at 2018-03-29 01:32:45

Hello,Felix:

maybe you can run it as following:

g++ example1.cpp -o example1 -I ../include -DUSE_LONG_INTEGERS -L../bin/ -Wl,-R../bin/ -lqpOASES

shyney7 commented 3 years ago

@svigerske thank you for your help I was also having problems compiling a simple example.cpp file. The flag -DUSE_LONG_INTEGERS fixed it for me.

Something that I want to mention is that I was still getting the following compiler error:

/tmp/ccSxV7jx.o: In function `main':
testqpa.cpp:(.text+0x177): undefined reference to `qpOASES::QProblem::QProblem(int, int, qpOASES::HessianType)'
collect2: error: ld returned 1 exit status

The only way of fixing it was to use the static library from version 3.2.0 instead of using the latest version 3.2.1. This was also mentioned here #86