[百度空间] ld: add library file reference by path & file name

本文介绍了如何使用链接器选项来指定库文件。默认情况下,链接器会搜索带有lib前缀的库文件。但也可以通过指定路径和文件名的方式加载没有lib前缀的库文件。

By default, -l option will search libraries with lib* prefix in speficied search paths.

i.e.

1
ld -o a.out -lA cppmain.o

will search libA.so/libA.a in all library search paths.

 

but it is possbile to set library by using a path & any filename(without lib prefix): use -l:"PATH_TO_LIBFILE"

1
ld -o a.out -l:~/dynlib.foo

转载于:https://www.cnblogs.com/crazii/p/4512792.html

/usr/bin/ld: warning: libIlmImf-2_3.so.24, needed by ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7, not found (try using -rpath or -rpath-link) /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::InputFile::InputFile(char const*, int)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::OutputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::FrameBuffer::insert(char const*, Imf_2_3::Slice const&)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Header::channels()' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::chromaticities(Imf_2_3::Header const&)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::OutputFile::OutputFile(char const*, Imf_2_3::Header const&, int)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::FrameBuffer::begin()' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Header::Header(int, int, float, Imath_2_3::Vec2<float> const&, float, Imf_2_3::LineOrder, Imf_2_3::Compression)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Channel::Channel(Imf_2_3::PixelType, int, int, bool)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Header::channels() const' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::InputFile::setFrameBuffer(Imf_2_3::FrameBuffer const&)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::FrameBuffer::end()' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::InputFile::header() const' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Header::~Header()' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::InputFile::readPixels(int, int)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::globalThreadCount()' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Header::dataWindow() const' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::ChannelList::findChannel(char const*) const' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::OutputFile::~OutputFile()' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Slice::Slice(Imf_2_3::PixelType, char*, unsigned long, unsigned long, int, int, double, bool, bool)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::Chromaticities::Chromaticities(Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&, Imath_2_3::Vec2<float> const&)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::OutputFile::writePixels(int)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::ChannelList::insert(char const*, Imf_2_3::Channel const&)' /usr/bin/ld: ../third_party/opencv3/lib64/libopencv_imgcodecs.so.3.4.7: undefined reference to `Imf_2_3::hasChromaticities(Imf_2_3::Header const&)' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/ppocr.dir/build.make:320: ppocr] Error 1 make[1]: *** [CMakeFiles/Makefile2:115: CMakeFiles/ppocr.dir/all] Error 2 make: *** [Makefile:103: all] Error 2
11-27
usr/bin/ld: CMakeFiles/rgbd_tum.dir/Examples/RGB-D/rgbd_tum.cc.o: in function `main': rgbd_tum.cc:(.text.startup+0x559): undefined reference to `cv::imread(std::string const&, int)' /usr/bin/ld: rgbd_tum.cc:(.text.startup+0x75f): undefined reference to `cv::imread(std::string const&, int)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::putText(cv::_InputOutputArray const&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::getTextSize(std::string const&, int, double, int, int*)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::namedWindow(std::string const&, int)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::FileNode::string() const' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::FileStorage::operator[](std::string const&) const' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `DBoW2::FORB::toString(cv::Mat const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `pangolin::CreateWindowAndBind(std::string, int, int, pangolin::Params const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::write(cv::FileStorage&, std::string const&, int)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::write(cv::FileStorage&, std::string const&, double)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive, char, std::char_traits<char> >::load(std::string&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `pangolin::Split(std::string const&, char)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `pcl::visualization::CloudViewer::showCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> const> const&, std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `boost::archive::basic_binary_oprimitive<boost::archive::binary_oarchive, char, std::char_traits<char> >::save(std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `pcl::visualization::CloudViewer::CloudViewer(std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `DBoW2::FORB::fromString(cv::Mat&, std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `pangolin::CreatePanel(std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `cv::operator<<(cv::FileStorage&, std::string const&)' /usr/bin/ld: ../lib/libORB_SLAM3.so: undefined reference to `boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::load(std::string&)' collect2: error: ld returned 1 exit status make[3]: *** [CMakeFiles/rgbd_tum.dir/build.make:212:../Examples/RGB-D/rgbd_tum] 错误 1 make[2]: *** [CMakeFiles/Makefile2:1106:CMakeFiles/rgbd_tum.dir/all] 错误 2 make[1]: *** [CMakeFiles/Makefile2:1113:CMakeFiles/rgbd_tum.dir/rule] 错误 2 make: *** [Makefile:560:rgbd_tum] 错误 2
11-18
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x80): undefined reference to `deflate' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::~WebSocketPerMessageDeflateCompressor()': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x3a0): undefined reference to `deflateEnd' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::init(unsigned char, bool)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x3f0): undefined reference to `deflateInit2_' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::compress(ix::IXWebSocketSendData const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x5e0): undefined reference to `deflate' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::~WebSocketPerMessageDeflateDecompressor()': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xa94): undefined reference to `inflateEnd' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::init(unsigned char, bool)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xad0): undefined reference to `inflateInit2_' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::decompress(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xc1c): undefined reference to `inflate' [build] /usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `bool ix::WebSocketPerMessageDeflateCompressor::compressData<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<unsigned char, std::allocator<unsigned char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> >&) [clone .part.0]': [build] IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xd4c): undefined reference to `deflate'以上错误如何解决
10-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值