簡體   English   中英

鏈接錯誤:“重定位R_X86_64_32 ...在創建共享對象時不能使用; 用-fPIC重新編譯“

[英]Linking error: “relocation R_X86_64_32 … can not be used when making a shared object; recompile with -fPIC”

我正在嘗試編譯Tox(特別是toxcore)。 當我嘗試編譯它時,遇到以下錯誤:

>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 )和編輯Makefile (更改)來嘗試使用fPIC CC = gccCC = 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 ..

配置腳本中必定存在錯誤,不應該提供libvpx.a

但是不要擔心,因為Ubuntu為libvpx-devlibsodium-dev提供了包,並且使用它們似乎工作得很好,所以你應該這樣做,除非有一些強有力的理由不這樣做。

此外,除非你需要經典的toxcore ,似乎c-toxcore是繼承者,所以你可能應該使用它。

使用--enable-pic配置將添加必要的-fPIC選項,並且適用於我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM