简体   繁体   English

无法链接Portaudio库

[英]Fail to Link Portaudio Library

I have made a simple Makefile project using Portaudio libraries and the project has been working fine with the following Makefile: 我已经使用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)

I'll try to integrate Portaudio libraries into another project created with Automake tools. 我将尝试将Portaudio库集成到使用Automake工具创建的另一个项目中。 I added library in Makefile.am file in this way: 我以这种方式在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

but I obtained the following error: 但是我得到了以下错误:

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

Don't link with "-shared" against a static library. 不要针对静态库与“共享”链接。

Use the shared one "-lportaudio" 使用共享的一个“ -lportaudio”

See also Why is fPIC absolutely necessary on 64 and not on 32bit platforms? 另请参见为什么在64位而非32位平台上绝对需要fPIC?

I have found the problem, when I have installed Portaudio, portaudio libraries has been included in /usr/local/lib path meanwhile my project search Portaudio libraries in /usr/lib path. 我发现了问题,当我安装Portaudio时,portaudio库已包含在/ usr / local / lib路径中,而我的项目在/ usr / lib路径中搜索了Portaudio库。 Thus I have copied libraries from /usr/local/lib to /usr/lib and I solved the problem (linking with -lportadio). 因此,我已将库从/ usr / local / lib复制到/ usr / lib,并且解决了该问题(与-lportadio链接)。 Thanks 谢谢

Regards Daniele Elia 问候Daniele Elia

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM