C++ 未找到BFD库
我试图在Ubuntu上使用libbfd,我已经安装了bin-utils:C++ 未找到BFD库,c++,c,linux,ubuntu,C++,C,Linux,Ubuntu,我试图在Ubuntu上使用libbfd,我已经安装了bin-utils: Reading state information... Done binutils-dev is already the newest version (2.26.1-1ubuntu1~16.04.8). 0 upgraded, 0 newly installed, 0 to remove and 147 not upgraded. root@server:~/Documents/Exercicios/BinaryLoa
Reading state information... Done
binutils-dev is already the newest version (2.26.1-1ubuntu1~16.04.8).
0 upgraded, 0 newly installed, 0 to remove and 147 not upgraded.
root@server:~/Documents/Exercicios/BinaryLoader#
但是当我试图用
g++ -D_GLIBCXX_USE_CXX11_ABI=0 loader.cc
我要走了
loader.cc:(.text+0x4c):未定义对bfd_get_错误的引用
loader.cc:(.text+0x53):对bfd_errmsg的未定义引用
我的loader.cc文件如下所示:
#include <bfd.h>
#include <stdio.h>
#include "loader.h"
#include <stdlib.h>
static int load_symbols_bfd(bfd *bfd_h, Binary *bin)
{
int ret;
long n, nsyms, i;
asymbol **bfd_symtab;
Symbol *sym;
bfd_symtab = NULL;
n = bfd_get_symtab_upper_bound(bfd_h);
if (n < 0) {
fprintf(stderr, "failed to read symtab (%s)\n",
bfd_errmsg(bfd_get_error()));
...
}
...
}
#包括
#包括
#包括“loader.h”
#包括
静态整型加载符号(bfd*bfd\u h,二进制*bin)
{
int ret;
长n,nsyms,i;
asymbol**bfd_symtab;
符号*sym;
bfd_symtab=NULL;
n=bfd_get_symtab_上界(bfd_h);
if(n<0){
fprintf(stderr,“未能读取符号表(%s)\n”,
bfd_errmsg(bfd_get_error());
...
}
...
}
g++-D_GLIBCXX_USE_cx11_ABI=0 loader.cc
您没有告诉g++“链接到libbfd”,
所以在“链接”阶段,它找不到libbfd提供的函数
我想您需要
g++-D\u GLIBCXX\u使用\u cx11\u ABI=0-lbfd loader.cc
您需要在库中链接。试试看:g++-D\u GLIBCXX\u USE\u cx11\u ABI=0 loader.cc-lbdf
非常感谢,效果很好g++-D\u GLIBCXX\u USE\u cx11\u ABI=0 loader.cc loader\u demo.cc-lbfd