0

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
umläute
  • 28,885
  • 9
  • 68
  • 122
daniele86
  • 147
  • 3
  • 14
  • Why not do as advised in the error message and `recompile with -fPIC` flag? – πάντα ῥεῖ Sep 14 '15 at 08:56
  • The program is already compiled with -fPIC and -DPIC. There is always the same problem *** Warning: Linking the shared library libsounddevice.la against the *** static library /home/daniele/Desktop/Sviluppo/Portaudio/portaudio/lib/.libs/libportaudio.a is not portable! – daniele86 Sep 14 '15 at 09:10

2 Answers2

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?

arved
  • 4,401
  • 4
  • 30
  • 53
  • I have already used "-lportaudio" and the program compiles correctly but when I log "Pa_GetDeviceCount();" I have 0 audio devices, instead they should be 7 as shows other program compiled with libportaudio.a library. Any ideas about this issue? Thanks – daniele86 Sep 14 '15 at 12:00
0

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

daniele86
  • 147
  • 3
  • 14