Fail to Link Portaudio Library

旧城冷巷雨未停 提交于 2019-12-25 12:40:12

问题


I have made a simple Makefile project using Portaudio libraries and the project has been working fine with the following 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. I added library in Makefile.am file in this way:

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

回答1:


Don't link with "-shared" against a static library.

Use the shared one "-lportaudio"

See also Why is fPIC absolutely necessary on 64 and not on 32bit platforms?




回答2:


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. Thus I have copied libraries from /usr/local/lib to /usr/lib and I solved the problem (linking with -lportadio). Thanks

Regards Daniele Elia



来源:https://stackoverflow.com/questions/32560728/fail-to-link-portaudio-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!