无法链接Portaudio库

时间:2015-09-14 08:54:12

标签: c++ makefile autotools automake portaudio

我使用Portaudio库创建了一个简单的Makefile项目,该项目使用以下Makefile工作正常:

CXXFLAGS =  -O2 -g -Wall -fmessage-length=0
OBJS =      RecAudio.o
LIBS = ../Portaudio/portaudio/lib/.libs/libportaudio.a -lpthread -lrt -lasound
#LIBS = -lportaudio -lpthread -lrt -lasound
TARGET =    RecAudio
$(TARGET):  $(OBJS)
    $(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all:    $(TARGET)
clean:
    rm -f $(OBJS) $(TARGET)

我尝试将Portaudio库集成到使用Automake工具创建的另一个项目中。我以这种方式在Makefile.am文件中添加了库:

METASOURCES = AUTO
lib_LTLIBRARIES = libsounddevice.la
libsounddevice_la_SOURCES = AudioCapturePluginCommon.cpp SoundDevice.cpp SoundDeviceConfig.cpp
libsounddevice_la_LDFLAGS = -module
AM_CPPFLAGS = -D_REENTRANT
libsounddevice_la_LIBADD = portaudio/portaudio/lib/.libs/libportaudio.a -lACE -lxerces-c -llog4cxx -lorkbase -lpcap -lpthread -lrt -lasound
INCLUDES = -I@top_srcdir@ -I../../../orkbasecxx -I../common
AudioCapturePluginCommon.cpp:
    ln -s ../common/AudioCapturePluginCommon.cpp AudioCapturePluginCommon.cpp

但我收到了以下错误:

sr/bin/ld: portaudio/portaudio/lib/.libs/libportaudio.a(pa_front.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
portaudio/portaudio/lib/.libs/libportaudio.a: could not read symbols: Bad value

2 个答案:

答案 0 :(得分:0)

不要与" -shared"针对静态库。

使用共享的" -lportaudio"

另见Why is fPIC absolutely necessary on 64 and not on 32bit platforms?

答案 1 :(得分:-1)

我发现了问题,当我安装了Portaudio时,portaudio库已包含在/ usr / local / lib路径中,同时我的项目在/ usr / lib路径中搜索Portaudio库。因此,我将库从/ usr / local / lib复制到/ usr / lib,我解决了问题(与-lportadio链接)。感谢

此致 Daniele Elia