C++: External library in eclipse CDT

Now I am using eclipse CDT for my C/C++ Application, but there is problem when I link my external library, it could not be loaded properly at run time, even through I put the library file near the source file, I gave the library path, and it's name correctly.

project directory:

  • include(.h files)
  • source(.cpp. files..)
  • lib(libbozorth3.a,LSFMatcher.a)
  • I want link that static libraries with my application I follow this steps:

  • project->properties->general->path and symbols->include directory path,and libraries(bozorth3.a,LSFMatcher.a),and add library path .
  • and also i add the same library in linker section also
  • When I build the program it displays a error cannot find -lbozorth3.a cannot find -lLSFMatcher.a

    So I need the correct steps to add the external library to c/c++ application.


    I normally configure

  • the library
  • the library search path (Needed for compiliation)
  • the runtime search path (-rpath Linker option)
  • (see images below and exchange the path in the Linker flags to that one you used in the library search path)

    图书馆搜索路径链接器选项用于运行时搜索路径


    you should use -Wl,-rpath=${workspace_loc}/Liball and not -Wl,-rpath,${workspace_loc}/Liball .

    Also under library -l option add library like eg. for libgcc.a add only gcc


    You should pay attention to what is in parentheses: Other options (-Xlinker [option]).

    The way to pass options is different. Instead of using:

    -Wl,-rpath,'${ProjDirPath}/../../system/lib'
    

    You must use:

    -rpath '${ProjDirPath}/../../system/lib'
    

    That is, remove the "-Wl," and replace the second "," by " " (space).

    在这里输入图像描述

    在这里输入图像描述

    链接地址: http://www.djcxy.com/p/61666.html

    上一篇: 使用Eclipse CDT和GDB进行调试:找不到源文件

    下一篇: C ++:eclipse CDT中的外部库