我正在尝试编译Tox(特别是toxcore)。当我尝试编译它,我会遇到以下错误:链接错误:“重新定位R_X86_64_32 ...在制作共享对象时无法使用;使用-fPIC重新编译”
>make
make all-recursive
make[1]: Entering directory '/root/Tox/toxcore'
Making all in build
make[2]: Entering directory '/root/Tox/toxcore/build'
CCLD libtoxav.la
/usr/bin/ld: /usr/local/lib/libvpx.a(vpx_codec.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libvpx.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:1385: recipe for target 'libtoxav.la' failed
make[2]: *** [libtoxav.la] Error 1
make[2]: Leaving directory '/root/Tox/toxcore/build'
Makefile:506: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/Tox/toxcore'
Makefile:410: recipe for target 'all' failed
make: *** [all] Error 2
在错误消息后,我试图通过出口C++标志(export CXXFLAGS="$CXXFLAGS -fPIC"
),通过添加参数configure
(./configure --enable-shared
)使用fPIC
和编辑Makefile
(将CC = gcc
更改为CC = gcc -fPIC
),但这些尝试没有奏效,我仍然遇到同样的错误。什么可能出错?
这是我现在所拥有的(在Ubuntu)的方法:
sudo apt-get install pkg-config
sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install autotools-dev
sudo apt-get install automake
sudo apt-get install checkinstall
sudo apt-get install check
sudo apt-get install git
sudo apt-get install yasm
cd ~
mkdir Tox
cd Tox
git clone https://github.com/jedisct1/libsodium.git
cd libsodium
git checkout tags/1.0.3
./autogen.sh
./configure && make check
sudo checkinstall --install --pkgname libsodium --pkgversion 1.0.0 --nodoc
sudo ldconfig
cd ..
git clone https://chromium.googlesource.com/webm/libvpx
cd libvpx
git checkout tags/v1.3.0
./configure
make
make install
cd ..
git clone https://github.com/irungentoo/toxcore.git
cd toxcore
autoreconf -i
./configure
make
sudo make install
cd ..
在更改配置后是否清除了以前的版本?你可以检查日志,看看你是否真的在编译标志中追加了'-fPIC'。 – Mine
@我的感谢您的评论。是的,我尝试了几次清洁。在'config.log'中,我看到引用'-fPIC'表明它确实在使用(例如'检查gcc PIC标志-fPIC -DPIC是否工作,'结果:是'等)。 – d3pd