View previous topic :: View next topic |
Author |
Message |
guyuming Apprentice
Joined: 19 Nov 2020 Posts: 248
|
Posted: Wed Dec 18, 2024 7:58 am Post subject: how to add -fPIC into cmake ebuild |
|
|
i am trying to create an ebuild for https://github.com/arangodb/linenoise-ng and reference that library in my code.
when compile my code, i get what follows:
Code: |
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/liblinenoise.a(linenoise.cpp.o): relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC |
I think i need to add -fPIC into my ebuild for linenoise-ng which inherit cmake.eclass
I tried what follows, but it does not seem to work.
Code: |
src_configure() {
local mycmakeargs=(
-DCMAKE_CXX_FLAGS_RELEASE="-fPIC"
)
cmake_src_configure
}
|
or
Code: |
-DCMAKE_CXX_FLAGS_RELEASE+="-fPIC" |
|
|
Back to top |
|
|
nicop Tux's lil' helper
Joined: 10 Apr 2014 Posts: 103
|
Posted: Wed Dec 18, 2024 10:15 am Post subject: |
|
|
you can use before cmake_src_configure :
append-cflags -fPIC
it needs inherit flag-o-matic
or something like
-DCMAKE_C_FLAGS_RELEASE="${CFLAGS} -fPIC" ? |
|
Back to top |
|
|
bstaletic Guru
Joined: 05 Apr 2014 Posts: 408
|
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1777 Location: South America
|
Posted: Wed Dec 18, 2024 12:45 pm Post subject: Re: how to add -fPIC into cmake ebuild |
|
|
guyuming wrote: | Code: | /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/liblinenoise.a(linenoise.cpp.o): relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC |
|
Is your code going in a shared library? Linenoise Next Generation only provides a static library:
CMakeLists.txt
Code: | # build liblinenoise
add_library(
linenoise
STATIC
src/ConvertUTF.cpp
src/linenoise.cpp
src/wcwidth.cpp
) |
I'd rather patch CMakeLists.txt in your ebuild to have CMake create a shared library instead. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
guyuming Apprentice
Joined: 19 Nov 2020 Posts: 248
|
Posted: Thu Dec 19, 2024 6:35 am Post subject: |
|
|
thanks nicop, the flag-o-matic way works for me:
Before i post this question, I use the following query to look for samples on my machine but fruitless
Code: | locate .ebuild|xargs grep -il "inherit cmake" |xargs grep CMAKE_CXX_FLAGS |rfm.sh -l |
after your suggestion, i tried the fPIC as keyword and find some samples:
Code: | locate .ebuild|xargs grep -il "inherit cmake" |xargs grep fPIC|rfm.sh -l |
And the rfm project https://github.com/guyuming76/rfm is where i am trying to test linenoise.
rfm provide a gtk+ based list ui for files in search result, and i can click/enter open file with editors such as emacs to see detail. You can also run shell command on selected files
I am newbie for the tool chain. Both flag-o-matic and cmake are new for me(the name cmake is more familiar).
I am not supposed to modify the cmakefile.txt of linenoise since i am not working on it currently, just looking for a simple alternaitve for the gnu readline i am using in project currently
UPDATE: grep inherit and cmake seperately returns more:
Code: |
locate .ebuild|xargs grep -il inherit|xargs grep -il cmake |xargs grep CMAKE_CXX_FLAGS |rfm.sh -l |
UPDATE: what follows seems to be the correct syntax. I am planning to enhance a feature to store frequently used commands in somewhere such as config.h. I need to know more about readline and history libraries for this i think. Or kind of integration with the tldr project?
Code: | locate .ebuild|xargs grep inherit|grep cmake|cut -d: -f1 |xargs grep CMAKE_CXX_FLAGS|rfm.sh -l |
|
|
Back to top |
|
|
|