问题
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