undefined reference to functions declared in lindo.h

淺唱寂寞╮ 提交于 2019-12-12 03:56:47

问题


I have the same problem described in this post:

undefined reference to function declared in *.h file

I am writing a C/C++ project Using Eclipse.

How can I solve the same problem?

I have tried going to: Project -> properties -> c c++ build -> settings -> Tool Settings->Gcc c++ libraries -> libraries -> libraries (-l)

and adding the libraries in /lindoappi/bin/linux34.

but it does not work. I added the directory to:

Project -> properties -> c c++ build -> settings -> Tool Settings->Gcc c++ libraries -> libraries -> library search path

The console output is:

**** Build of configuration Debug for project LINDO_test ****

make all Building target: LINDO_test Invoking: GCC C++ Linker g++ -L/home/mario/lindoapi/bin/linux32 -o"LINDO_test" ./src/LINDO_test.o ./src/test_001.o -lliblindo /usr/bin/ld: cannot find -lliblindo collect2: ld returned 1 exit status make: *** [LINDO_test] Error 1

The folowing is a related post too: error while loading shared libraries

Any other suggestions? Thanks a lot.


回答1:


Go to:

Project -> properties -> c c++ build -> settings -> Tool Settings->Gcc c++ linker -> libraries -> libraries (-l)

add the libraries as: lindo64 mosek64 and whatever you need.

Then add: Project -> properties -> c c++ build -> settings -> Tool Settings->Gcc c++ linker

Make sure .../lindoapi/bin/linux64 is in Project -> properties -> c c++ build -> settings -> Tool Settings->Gcc c++ linker -> libraries -> Library search path (-L)

edit the command line pattern to: ${COMMAND} ${OUTPUT} ... -Wl,-rpath=/opt/lindoapi/bin/linux64 ${INPUTS}

for some reason Eclipse only allows -soname, --out-implib, and --output-def for Wl, so you have to do it manually in this way. Is not clean, but it works.

I hope this is useful to other users too.

happy coding.



来源:https://stackoverflow.com/questions/16052148/undefined-reference-to-functions-declared-in-lindo-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!