0

I have 3rd parties libraries that don't placed under "/usr/lib". I defined their path in eclipse library search path . The project compile and linkage well, but when i run project i got exception that library doesn't found. if i copy the 3rd party library to "/usr/lib" than it run ok.

I believe that this is path issue (i am new to cpp), how do i configure this in eclipse ?

Thank you

Avihai Marchiano
  • 3,837
  • 3
  • 38
  • 55

1 Answers1

1

First of all, since it's crashing during runtime, you are linking against dynamic libraries (libWhatever.so), so you have to add your library path to the LD_LIBRARY_PATH environment variable. Otherwise, you could force the linker to link statically to static libraries (libWhatever.a), using the -static flag.

Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
  • I am sure that this is the correct answer. the problem is that i use eclipse cdt and i dont know how to configure it in eclipse-cdt – Avihai Marchiano Jul 24 '12 at 16:27
  • But why don't you just link statically, to avoid tons of headaches? Check the second answer here: http://stackoverflow.com/questions/4952403/link-static-lib-in-eclipse-cdt – Mihai Todor Jul 24 '12 at 16:28
  • sorry , for my ignorance. i am new to cpp. can i link statistically even if i have only so? – Avihai Marchiano Jul 24 '12 at 16:30
  • Uh, OK, that is quite unpleasant. In this case, you definitely need to set the `LD_LIBRARY_PATH`. Eclipse is smart enough to do this for you, though. See here: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.cdt.doc.user/tasks/cdt_t_run_env.htm – Mihai Todor Jul 24 '12 at 16:35