compile fails: lib-audio-devices needs -fPIC SOLVED?

Building and customizing Audacity from the source code.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
mgchristensen
Posts: 3
Joined: Sun Sep 19, 2021 3:51 pm
Operating System: Linux Fedora/RHEL

compile fails: lib-audio-devices needs -fPIC SOLVED?

Post by mgchristensen » Sun Sep 19, 2021 6:36 pm

Attempting to compile Audacity from a git clone, I got the following error:

[ 29%] Built target lib-registries
Consolidate compiler generated dependencies of target lib-xml
[ 30%] Built target lib-xml
Consolidate compiler generated dependencies of target lib-audio-devices
[ 30%] Building CXX object libraries/lib-audio-devices/CMakeFiles/lib-audio-devices.dir/AudioIOBase.cpp.o
[ 30%] Building CXX object libraries/lib-audio-devices/CMakeFiles/lib-audio-devices.dir/DeviceChange.cpp.o
[ 30%] Building CXX object libraries/lib-audio-devices/CMakeFiles/lib-audio-devices.dir/DeviceManager.cpp.o
[ 30%] Building CXX object libraries/lib-audio-devices/CMakeFiles/lib-audio-devices.dir/Meter.cpp.o
[ 31%] Linking CXX shared library ../../shared/Release/lib-audio-devices.so
/usr/bin/ld: ../../lib-src/portmixer/libportmixer.a(px_mixer.c.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../lib-src/portmixer/libportmixer.a(px_unix_oss.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../lib-src/portmixer/libportmixer.a(px_linux_alsa.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make[2]: *** [libraries/lib-audio-devices/CMakeFiles/lib-audio-devices.dir/build.make:156: shared/Release/lib-audio-devices.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:1596: libraries/lib-audio-devices/CMakeFiles/lib-audio-devices.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

CMakeError.log is unrevealing, as it only has an error related to the version of nasm.

CMakeOutput.txt is likewise unrevealing.

However, adding this line at about line 408 allowed the compile to finish:

set(CMAKE_POSITION_INDEPENDENT_CODE ON) at about line 408.

This, per the post here: https://stackoverflow.com/questions/382 ... ler-option).

The library lib-audio-devices.so shows up here:

~/audacity/build/bin/Release/lib64/audacity/

sudo make install also completed.

Any comments to educate me greatly appreciated!

mgchristensen
Posts: 3
Joined: Sun Sep 19, 2021 3:51 pm
Operating System: Linux Fedora/RHEL

Re: compile fails: lib-audio-devices needs -fPIC SOLVED?

Post by mgchristensen » Sun Sep 19, 2021 7:07 pm

Sigh... I omitted that "However, adding this line at about line 408 allowed the compile to finish:" should reference the file ~/audacity/CMakeLists.txt>

steve
Site Admin
Posts: 82906
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: compile fails: lib-audio-devices needs -fPIC SOLVED?

Post by steve » Sun Sep 19, 2021 7:42 pm

The best place to ask about build problems is here: https://discord.gg/2ueFdhpg
(Remember to say which version of Fedora / RHEL you are using, and which exact version of Audacity source code.)
Learn more about Nyquist programming at audionyq.com

mgchristensen
Posts: 3
Joined: Sun Sep 19, 2021 3:51 pm
Operating System: Linux Fedora/RHEL

Re: compile fails: lib-audio-devices needs -fPIC SOLVED?

Post by mgchristensen » Mon Sep 20, 2021 2:09 pm

Audacity source code version 3.1.0. Fedora 34 x86_64.
Thank you!

jademan
Forum Crew
Posts: 1853
Joined: Fri Jul 17, 2009 10:11 pm
Operating System: Windows 10

Re: compile fails: lib-audio-devices needs -fPIC SOLVED?

Post by jademan » Mon Sep 20, 2021 2:17 pm

mgchristensen wrote:
Mon Sep 20, 2021 2:09 pm
Audacity source code version 3.1.0. Fedora 34 x86_64.
Thank you!
So you would want to supply this information when you describe your issue on the #linux channel - COMPILING AUDACITY after you join Audacity-Dev on discord as Steve suggested.

Post Reply