4

I try to compile icqdesktop On ubuntu 18.04 64 bit and I have try:

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

but I have this error:

[ 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

my questions is: (it's not duplicate!!)

Now how can I change make file to recompile with -fPIC flag.

A1Gard
  • 4,070
  • 4
  • 31
  • 55
  • 1
    I think you're misunderstanding, the libraries that aren't compiled with `-fPIC` are not the ones you are compiling but the ones from libevent that you're trying to link against. The easiest fix is the exact opposite of what you said you wanted. Just compile/link the icq exe without `-fPIC` or `-fPIE` then you can link against the static libevent libs. – PeterT Jun 10 '18 at 18:01
  • @PeterT How can I change the flag in make file? – A1Gard Jun 10 '18 at 18:04
  • @MahdiParsa: You may pass additional option `-DCMAKE_POSITION_INDEPENDENT_CODE=OFF` to `cmake`. BTW, the title of your question is *meaningless*: message `make: *** [all] Error 2` is common for almost any error during the build with `make`. – Tsyvarev Jun 10 '18 at 18:26
  • @Tsyvarev Thanks for davice I try this but same problem yet :( – A1Gard Jun 10 '18 at 20:11
  • Can you see what flags are being used by say runing `make VERBOSE=1`? Or from the `build` directory, running something like `find -type f -name "*.make" | xargs grep "\-fPIC" ` or find -type f -name "*.make" | xargs grep "\-fPIE" to find what flags are being used. I hope these examples can help you find a way to hack your build.I fear the CMakeList.txt files might not be set up to listen to `-DCMAKE_POSITION_INDEPENDENT_CODE=OFF` correctly. – snow_abstraction Jun 16 '18 at 19:04
  • 1
    It can be pretty important to run `make clean` from the `build` directory and then removing everything from the `build` directory before running `cmake` command again when experimenting with linker flags. – snow_abstraction Jun 16 '18 at 19:29
  • I reproduced your error and using the info from the my previous comment that -fPIC is ALREADY being used. Adding -fPIC wouldn't help you. I tested this by building a small binary again the icqdesktop/external libraries: `g++ tut1.cpp -I"../icqdesktop/external/boost/include" -L"../icqdesktop/external/linux/x64/" -lboost_filesystem` where tut1.cpp is the source code from [https://www.boost.org/doc/libs/1_67_0/libs/filesystem/example/tut1.cpp]. I get the error message "...can not be used when making a shared object; recompile with -fPIC" regardless if I build with or without the -fPIC flag. – snow_abstraction Jun 18 '18 at 18:32

1 Answers1

1

you can compile debug mode: (its work right)

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

Sadegh PM
  • 444
  • 2
  • 15