我试图在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/BinaryLoader# 但是当我试图用
g++ -D_GLIBCXX_USE_CXX11_ABI=0 loader.cc我得到了
loader.cc:(.text+0x4c):对bfd_get_error 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()));
...
}
...
}发布于 2020-07-20 01:56:25
g++ -D_GLIBCXX_USE_CXX11_ABI=0 loader.cc
您没有告诉g++‘libbfd',所以在'link’阶段,它找不到libbfd提供的功能。
我想你需要g++ -D_GLIBCXX_USE_CXX11_ABI=0 -lbfd loader.cc。
https://stackoverflow.com/questions/62987448
复制相似问题