草庐IT

c++ - 与库的 c 绑定(bind)链接

coder 2024-02-22 原文

我正在尝试链接到下一个库:( see docs )

它是一个 C 绑定(bind),用于用 C++ 编写的库。但是如果制作静态库然后尝试链接到它。

我收到这些消息:

uchardet//libuchardet.a(uchardet.cpp.o): In function `uchardet_new':
uchardet.cpp:(.text+0x19): undefined reference to `operator new(unsigned long)'
uchardet.cpp:(.text+0x3c): undefined reference to `std::string::_Rep::_S_empty_rep_storage'
uchardet.cpp:(.text+0x4b): undefined reference to `std::string::assign(char const*, unsigned long)'
uchardet.cpp:(.text+0x6c): undefined reference to `operator delete(void*)'
uchardet.cpp:(.text+0x7f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::Reset()':
uchardet.cpp:(.text._ZN23HandleUniversalDetector5ResetEv[_ZN23HandleUniversalDetector5ResetEv]+0x16): undefined reference to `std::string::assign(char const*, unsigned long)'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::Report(char const*)':
uchardet.cpp:(.text._ZN23HandleUniversalDetector6ReportEPKc[_ZN23HandleUniversalDetector6ReportEPKc]+0x35): undefined reference to `std::string::assign(char const*, unsigned long)'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::~HandleUniversalDetector()':
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD2Ev[_ZN23HandleUniversalDetectorD5Ev]+0x1a): undefined reference to `std::string::_Rep::_S_empty_rep_storage'
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD2Ev[_ZN23HandleUniversalDetectorD5Ev]+0x4d): undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::~HandleUniversalDetector()':
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD0Ev[_ZN23HandleUniversalDetectorD0Ev]+0x1a): undefined reference to `std::string::_Rep::_S_empty_rep_storage'
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD0Ev[_ZN23HandleUniversalDetectorD0Ev]+0x2c): undefined reference to `operator delete(void*)'
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD0Ev[_ZN23HandleUniversalDetectorD0Ev]+0x55): undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
uchardet//libuchardet.a(uchardet.cpp.o):(.rodata._ZTI23HandleUniversalDetector[_ZTI23HandleUniversalDetector]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(uchardet.cpp.o):(.eh_frame+0xab): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o): In function `nsUniversalDetector::HandleData(char const*, unsigned int)':
nsUniversalDetector.cpp:(.text+0x368): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x396): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x3c6): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x4eb): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x527): undefined reference to `operator delete(void*)'
nsUniversalDetector.cpp:(.text+0x53a): undefined reference to `operator delete(void*)'
nsUniversalDetector.cpp:(.text+0x554): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o): In function `nsUniversalDetector::~nsUniversalDetector()':
nsUniversalDetector.cpp:(.text+0x5bc): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o): In function `nsCharSetProber::~nsCharSetProber()':
nsUniversalDetector.cpp:(.text._ZN15nsCharSetProberD0Ev[_ZN15nsCharSetProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTI19nsUniversalDetector[_ZTI19nsUniversalDetector]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV19nsUniversalDetector[_ZTV19nsUniversalDetector]+0x30): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x20): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x28): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x30): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x38): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x40): more undefined references to `__cxa_pure_virtual' follow
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTI15nsCharSetProber[_ZTI15nsCharSetProber]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.eh_frame+0xbb): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::~nsEscCharSetProber()':
nsEscCharsetProber.cpp:(.text+0x1a0): undefined reference to `operator delete(void*)'
nsEscCharsetProber.cpp:(.text+0x1a9): undefined reference to `operator delete(void*)'
nsEscCharsetProber.cpp:(.text+0x1b2): undefined reference to `operator delete(void*)'
nsEscCharsetProber.cpp:(.text+0x1bb): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::~nsEscCharSetProber()':
nsEscCharsetProber.cpp:(.text+0x1e0): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o):nsEscCharsetProber.cpp:(.text+0x1e9): more undefined references to `operator delete(void*)' follow
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::nsEscCharSetProber(unsigned int)':
nsEscCharsetProber.cpp:(.text+0x276): undefined reference to `operator new(unsigned long)'
nsEscCharsetProber.cpp:(.text+0x296): undefined reference to `operator new(unsigned long)'
nsEscCharsetProber.cpp:(.text+0x2b6): undefined reference to `operator new(unsigned long)'
nsEscCharsetProber.cpp:(.text+0x2d2): undefined reference to `operator new(unsigned long)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::~nsEscCharSetProber()':
nsEscCharsetProber.cpp:(.text+0x20b): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o):(.rodata._ZTI18nsEscCharSetProber[_ZTI18nsEscCharSetProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o):(.eh_frame+0x137): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o): In function `nsMBCSGroupProber::nsMBCSGroupProber(unsigned int)':
nsMBCSGroupProber.cpp:(.text+0x964): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0x97f): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0x9d0): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0x9f9): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0xa22): undefined reference to `operator new(unsigned long)'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):nsMBCSGroupProber.cpp:(.text+0xa43): more undefined references to `operator new(unsigned long)' follow
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o): In function `nsMBCSGroupProber::nsMBCSGroupProber(unsigned int)':
nsMBCSGroupProber.cpp:(.text+0xd6b): undefined reference to `operator delete(void*)'
nsMBCSGroupProber.cpp:(.text+0xda5): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o): In function `nsMBCSGroupProber::~nsMBCSGroupProber()':
nsMBCSGroupProber.cpp:(.text+0x8f0): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTI17nsMBCSGroupProber[_ZTI17nsMBCSGroupProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTV23JapaneseContextAnalysis[_ZTV23JapaneseContextAnalysis]+0x10): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTV23JapaneseContextAnalysis[_ZTV23JapaneseContextAnalysis]+0x18): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTI23JapaneseContextAnalysis[_ZTI23JapaneseContextAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.eh_frame+0x67): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o): In function `nsSBCSGroupProber::nsSBCSGroupProber()':
nsSBCSGroupProber.cpp:(.text+0xdf4): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xe28): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xe5c): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xe90): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xec4): undefined reference to `operator new(unsigned long)'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o):nsSBCSGroupProber.cpp:(.text+0xef8): more undefined references to `operator new(unsigned long)' follow
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o): In function `nsSBCSGroupProber::nsSBCSGroupProber()':
nsSBCSGroupProber.cpp:(.text+0x13fb): undefined reference to `operator delete(void*)'
nsSBCSGroupProber.cpp:(.text+0x1422): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o): In function `nsSBCSGroupProber::~nsSBCSGroupProber()':
nsSBCSGroupProber.cpp:(.text+0xdc9): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o):(.rodata._ZTI17nsSBCSGroupProber[_ZTI17nsSBCSGroupProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o):(.eh_frame+0x67): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsSBCharSetProber.cpp.o): In function `nsSingleByteCharSetProber::~nsSingleByteCharSetProber()':
nsSBCharSetProber.cpp:(.text._ZN25nsSingleByteCharSetProberD0Ev[_ZN25nsSingleByteCharSetProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSBCharSetProber.cpp.o):(.rodata._ZTI25nsSingleByteCharSetProber[_ZTI25nsSingleByteCharSetProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsSJISProber.cpp.o): In function `nsSJISProber::~nsSJISProber()':
nsSJISProber.cpp:(.text._ZN12nsSJISProberD2Ev[_ZN12nsSJISProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSJISProber.cpp.o): In function `nsSJISProber::~nsSJISProber()':
nsSJISProber.cpp:(.text._ZN12nsSJISProberD0Ev[_ZN12nsSJISProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsSJISProber.cpp:(.text._ZN12nsSJISProberD0Ev[_ZN12nsSJISProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSJISProber.cpp.o):(.rodata._ZTI12nsSJISProber[_ZTI12nsSJISProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsUTF8Prober.cpp.o): In function `nsUTF8Prober::~nsUTF8Prober()':
nsUTF8Prober.cpp:(.text._ZN12nsUTF8ProberD2Ev[_ZN12nsUTF8ProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUTF8Prober.cpp.o): In function `nsUTF8Prober::~nsUTF8Prober()':
nsUTF8Prober.cpp:(.text._ZN12nsUTF8ProberD0Ev[_ZN12nsUTF8ProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsUTF8Prober.cpp:(.text._ZN12nsUTF8ProberD0Ev[_ZN12nsUTF8ProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUTF8Prober.cpp.o):(.rodata._ZTI12nsUTF8Prober[_ZTI12nsUTF8Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsLatin1Prober.cpp.o): In function `nsLatin1Prober::~nsLatin1Prober()':
nsLatin1Prober.cpp:(.text._ZN14nsLatin1ProberD0Ev[_ZN14nsLatin1ProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsLatin1Prober.cpp.o):(.rodata._ZTI14nsLatin1Prober[_ZTI14nsLatin1Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI24CharDistributionAnalysis[_ZTI24CharDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI25EUCTWDistributionAnalysis[_ZTI25EUCTWDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI25EUCKRDistributionAnalysis[_ZTI25EUCKRDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI26GB2312DistributionAnalysis[_ZTI26GB2312DistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI24Big5DistributionAnalysis[_ZTI24Big5DistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI24SJISDistributionAnalysis[_ZTI24SJISDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI25EUCJPDistributionAnalysis[_ZTI25EUCJPDistributionAnalysis]+0x0): more undefined references to `vtable for __cxxabiv1::__si_class_type_info' follow
uchardet//libuchardet.a(nsHebrewProber.cpp.o): In function `nsHebrewProber::~nsHebrewProber()':
nsHebrewProber.cpp:(.text._ZN14nsHebrewProberD0Ev[_ZN14nsHebrewProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsHebrewProber.cpp.o):(.rodata._ZTI14nsHebrewProber[_ZTI14nsHebrewProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsBig5Prober.cpp.o): In function `nsBig5Prober::~nsBig5Prober()':
nsBig5Prober.cpp:(.text._ZN12nsBig5ProberD2Ev[_ZN12nsBig5ProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsBig5Prober.cpp.o): In function `nsBig5Prober::~nsBig5Prober()':
nsBig5Prober.cpp:(.text._ZN12nsBig5ProberD0Ev[_ZN12nsBig5ProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsBig5Prober.cpp:(.text._ZN12nsBig5ProberD0Ev[_ZN12nsBig5ProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsBig5Prober.cpp.o):(.rodata._ZTI12nsBig5Prober[_ZTI12nsBig5Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEUCJPProber.cpp.o): In function `nsEUCJPProber::~nsEUCJPProber()':
nsEUCJPProber.cpp:(.text._ZN13nsEUCJPProberD2Ev[_ZN13nsEUCJPProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCJPProber.cpp.o): In function `nsEUCJPProber::~nsEUCJPProber()':
nsEUCJPProber.cpp:(.text._ZN13nsEUCJPProberD0Ev[_ZN13nsEUCJPProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsEUCJPProber.cpp:(.text._ZN13nsEUCJPProberD0Ev[_ZN13nsEUCJPProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCJPProber.cpp.o):(.rodata._ZTI13nsEUCJPProber[_ZTI13nsEUCJPProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEUCKRProber.cpp.o): In function `nsEUCKRProber::~nsEUCKRProber()':
nsEUCKRProber.cpp:(.text._ZN13nsEUCKRProberD2Ev[_ZN13nsEUCKRProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCKRProber.cpp.o): In function `nsEUCKRProber::~nsEUCKRProber()':
nsEUCKRProber.cpp:(.text._ZN13nsEUCKRProberD0Ev[_ZN13nsEUCKRProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsEUCKRProber.cpp:(.text._ZN13nsEUCKRProberD0Ev[_ZN13nsEUCKRProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCKRProber.cpp.o):(.rodata._ZTI13nsEUCKRProber[_ZTI13nsEUCKRProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEUCTWProber.cpp.o): In function `nsEUCTWProber::~nsEUCTWProber()':
nsEUCTWProber.cpp:(.text._ZN13nsEUCTWProberD2Ev[_ZN13nsEUCTWProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCTWProber.cpp.o): In function `nsEUCTWProber::~nsEUCTWProber()':
nsEUCTWProber.cpp:(.text._ZN13nsEUCTWProberD0Ev[_ZN13nsEUCTWProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsEUCTWProber.cpp:(.text._ZN13nsEUCTWProberD0Ev[_ZN13nsEUCTWProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCTWProber.cpp.o):(.rodata._ZTI13nsEUCTWProber[_ZTI13nsEUCTWProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsGB2312Prober.cpp.o): In function `nsGB18030Prober::~nsGB18030Prober()':
nsGB2312Prober.cpp:(.text._ZN15nsGB18030ProberD2Ev[_ZN15nsGB18030ProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsGB2312Prober.cpp.o): In function `nsGB18030Prober::~nsGB18030Prober()':
nsGB2312Prober.cpp:(.text._ZN15nsGB18030ProberD0Ev[_ZN15nsGB18030ProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsGB2312Prober.cpp:(.text._ZN15nsGB18030ProberD0Ev[_ZN15nsGB18030ProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsGB2312Prober.cpp.o):(.rodata._ZTI15nsGB18030Prober[_ZTI15nsGB18030Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
collect2: error: ld returned 1 exit status

如果 make shared one 并尝试在我的程序中使用它,它会编译,但是当我运行它时,我有:

error while loading shared libraries: libuchardet.so.0: cannot open shared object file: No such file or directory

我是这样编译的:

gcc test.c  -Ithird -Lthird/parserutils/lib_amd64/ -lparserutils -I uchardet/ -L uchardet/ -luchardet

好的!这行得通!

LD_LIBRARY_PATH=uchardet/ ./a.out

但是我可以在这里使用静态链接吗?

最佳答案

对于共享库案例:默认情况下,RTLD 仅应用公共(public)库搜索路径。要添加另一个,请在链接二进制文件时添加一个选项:-Wl,-rpath=$libdir,例如


gcc test.c  -Ithird -Lthird/parserutils/lib_amd64/ -lparserutils -I uchardet/ -L uchardet/ -luchardet -Wl,-rpath=`pwd`/uchardet

此选项将要求 RTLD 也在指定目录中搜​​索库。可以为此处调用的每个附加目录指定多次。

静态库情况发生了什么,您可以确定对共享库使用 ldd。它很可能需要 libg++、libstdc++ 或模拟,具体取决于您的系统。如果是这样,您还应该为您的链接添加其静态模拟。即使编译了纯 C 代码,g++ 也会自动执行此操作,但 gcc 不会。

关于c++ - 与库的 c 绑定(bind)链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20731614/

有关c++ - 与库的 c 绑定(bind)链接的更多相关文章

  1. ruby-on-rails - 如何优雅地重启 thin + nginx? - 2

    我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server

  2. ruby - ruby 中的 TOPLEVEL_BINDING 是什么? - 2

    它不等于主线程的binding,这个toplevel作用域是什么?此作用域与主线程中的binding有何不同?>ruby-e'putsTOPLEVEL_BINDING===binding'false 最佳答案 事实是,TOPLEVEL_BINDING始终引用Binding的预定义全局实例,而Kernel#binding创建的新实例>Binding每次封装当前执行上下文。在顶层,它们都包含相同的绑定(bind),但它们不是同一个对象,您无法使用==或===测试它们的绑定(bind)相等性。putsTOPLEVEL_BINDINGput

  3. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

  4. ruby-on-rails - Prawn - 表格单元格内的链接 - 2

    我正在尝试用Prawn生成PDF。在我的PDF模板中,我有带单元格的表格。在其中一个单元格中,我有一个电子邮件地址:cell_email=pdf.make_cell(:content=>booking.user_email,:border_width=>0)我想让电子邮件链接到“mailto”链接。我知道我可以这样链接:pdf.formatted_text([{:text=>booking.user_email,:link=>"mailto:#{booking.user_email}"}])但是将这两行组合起来(将格式化文本作为内容)不起作用:cell_email=pdf.make_c

  5. ruby - 使用 `+=` 和 `send` 方法 - 2

    如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:

  6. ruby-on-rails - 创建 ruby​​ 数据库时惰性符号绑定(bind)失败 - 2

    我正在尝试在Rails上安装ruby​​,到目前为止一切都已安装,但是当我尝试使用rakedb:create创建数据库时,我收到一个奇怪的错误:dyld:lazysymbolbindingfailed:Symbolnotfound:_mysql_get_client_infoReferencedfrom:/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundleExpectedin:flatnamespacedyld:Symbolnotfound:_mysql_get_client_infoReferencedf

  7. ruby - 如何计算 Liquid 中的变量 +1 - 2

    我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我

  8. arrays - Ruby 数组 += vs 推送 - 2

    我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“

  9. ruby - 使用 Watir 检查错误链接 - 2

    我有一个未排序的链接列表,我将其保存在旁边,我想单击每个链接并确保它转到真实页面而不是404、500等。问题是我不知道该怎么做。是否有一些我可以检查的对象会给我http状态代码或任何东西?mylinks=Browser.ul(:id,'my_ul_id').linksmylinks.eachdo|link|link.click#needtocheckfora200statusorsomethinghere!how?Browser.backend 最佳答案 我的回答与铁皮人的想法类似。require'net/http'require'

  10. ruby - 如何为 pbcopy 生成富文本链接 - 2

    我一直在玩一个脚本,它在Chrome中获取选定的文本并在Google中查找它,提供四个最佳选择,然后粘贴相关链接。它以不同的格式粘贴,具体取决于当前在Chrome中打开的页面-DokuWiki打开的DokuWiki格式,普通网站的HTML,我想要我的WordPress所见即所得编辑器的富文本。我尝试使用pbpaste-Preferrtf来查看没有其他样式的富文本链接在粘贴板上的样子,但它仍然输出纯文本。在文本编辑中保存文件并进行试验后,我想出了以下内容text=%q|{\rtf1{\field{\*\fldinst{HYPERLINK"URL"}}{\fldrsltTEXT}}}|te

随机推荐