【问题标题】:how edit make file when have icqdesktop error (make: *** [all] Error 2) Ubuntu 18.04 64bit出现 icqdesktop 错误时如何编辑 make 文件(make: *** [all] Error 2)Ubuntu 18.04 64bit
【发布时间】:2018-11-20 01:03:07
【问题描述】:

我尝试在 ubuntu 18.04 64 位上编译 icqdesktop 并且我尝试过:

mkdir build && cd build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLINUX_ARCH=64 && make

但我有这个错误:

[ 19%] Built target core
[ 19%] Built target corelib
[ 20%] Linking CXX executable ../../bin/Release64/icq

...
/usr/bin/x86_64-linux-gnu-ld: ../../external/linux/x64/libevent-2.1.8/lib/libevent.a(epoll.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../../external/linux/x64/libevent-2.1.8/lib/libevent.a(signal.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../../external/linux/x64/libevent-2.1.8/lib/libevent_pthreads.a(evthread_pthread.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
gui/CMakeFiles/icq.dir/build.make:16257: recipe for target '../bin/Release64/icq' failed
make[2]: *** [../bin/Release64/icq] Error 1
CMakeFiles/Makefile2:196: recipe for target 'gui/CMakeFiles/icq.dir/all' failed
make[1]: *** [gui/CMakeFiles/icq.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

我的问题是:(不是重复的!!)

现在如何更改 make 文件以使用 -fPIC 标志重新编译。

【问题讨论】:

  • 我认为您误解了,未使用 -fPIC 编译的库不是您正在编译的库,而是您尝试链接的来自 libevent 的库。最简单的解决方法与您所说的完全相反。只需编译/链接没有-fPIC-fPIE 的icq exe,然后您就可以链接到静态libevent 库。
  • @PeterT 如何更改 make 文件中的标志?
  • @MahdiParsa:您可以将附加选项 -DCMAKE_POSITION_INDEPENDENT_CODE=OFF 传递给 cmake。顺便说一句,您的问题的标题是meaningless:消息make: *** [all] Error 2 对于使用make 构建期间的几乎所有错误都很常见。
  • @Tsyvarev 感谢davice我尝试了这个但同样的问题:(

标签: c++ cmake desktop-application icq


【解决方案1】:

你可以编译调试模式:(它的工作正常)

mkdir build && cd build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DLINUX_ARCH=64 && make

【讨论】:

    猜你喜欢
    • 2021-02-08
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 2016-01-31
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    相关资源
    最近更新 更多