无法链接到BFD [英] Unable to link against BFD

查看:345
本文介绍了无法链接到BFD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将此文件包含在我的项目中: http ://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html

I am trying to include this file in my project: http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html

但是它需要链接BFD.我同时安装了binutilsbinutils-devel.我试过用-lbfd链接以及直接链接到/usr/lib64/libbfd.so/usr/lib64/libbfd.a(两者都存在).我还尝试搜索pkg-config以查看是否应该使用其他标志,但在pkg-config中没有引用BFD或binutils.

But it requires linking against BFD. I have both binutils and binutils-devel installed. I have tried linking with -lbfd as well as directly to /usr/lib64/libbfd.so and /usr/lib64/libbfd.a (which both do exist). I also tried searching pkg-config to see if there was a different flag I should be using, but there is no reference to BFD or binutils in pkg-config.

无论我尝试了什么,都会遇到以下错误:

No matter what I've tried I get the following errors:

undefined reference to 'bfd_init'
undefined reference to 'bfd_openr'
undefined reference to 'bfd_check_format'
undefined reference to 'bfd_checkformat_matches'
undefined reference to 'bfd_close'
undefined reference to 'bfd_map_over_sections'

首先,我要编译我的记录器和上面链接到的backtrace-symbols.c文件(因为记录器是我打算用来打印轨迹的位置).然后,我将这两个目标文件链接到一个组合的目标文件中:

First I am compiling my logger and the backtrace-symbols.c file I linked to above (as the logger is where I intend to use this for printing traces). Then I am linking those two object files together into a combined object file:

CC = clang
CFLAGS = -g -Wall -c
SOURCE = simplog.c
OBJ = simplog.o, simplog-temp.o, backtrace-symbols.o

all:
    $(CC) $(CFLAGS) $(SOURCE); mv simplog.o simplog-temp.o; \
    $(CC) -ansi $(CFLAGS) backtrace-symbols.c; \
    ld -r simplog-temp.o backtrace-symbols.o -o simplog.o

clean:
    rm -f $(OBJ) 

然后将这个目标文件链接到我的主项目中:

Then I am linking this object file into my main project:

CC= clang++
PROG= ./bin/chiplus8
OBJS= ./src/main.o ./src/Chip8.o ./src/EmuCPU.o ./src/SimpleLogger/simplog.o
LIBS= 
CXXFLAGS= -g -Wall -std=c++11 $(shell pkg-config --cflags ${LIBS})
LDFLAGS= $(shell pkg-config --static --libs ${LIBS})

all: logger $(PROG)

$(PROG): $(OBJS)
    mkdir -p ./bin/
    $(CC) -g -rdynamic -o $(PROG) $(LDFLAGS) -lbfd -liberty $(OBJS)
    rm -f $(OBJS)

logger:
    cd ./src/SimpleLogger; make clean all

clean:
    rm -f $(PROG) $(OBJS)

我真的不确定我该怎么做才能使其正确链接.有什么我想念的吗?

I'm really not sure what I need to do to get this to link properly anymore. Is there something I'm missing?

推荐答案

更改:

$(PROG): $(OBJS)
    mkdir -p ./bin/
    $(CC) -g -rdynamic -o $(PROG) $(LDFLAGS) -lbfd -liberty $(OBJS)
    rm -f $(OBJS)

对此:

$(PROG): $(OBJS)
    mkdir -p ./bin/
    $(CC) -g -rdynamic -o $(PROG) $(LDFLAGS) $(OBJS) -lbfd -liberty
    rm -f $(OBJS)

必须使用编译命令将目标文件放置在库之前.请参阅此问题.

Object files have to be placed before libraries with the compilation command. See this question.

这篇关于无法链接到BFD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆