andreww / fox

A Fortran XML library
https://andreww.github.io/fox/
Other
58 stars 50 forks source link

How to compile the FoX with -fPIC flag? #65

Closed LiangXihui closed 3 years ago

LiangXihui commented 3 years ago

Dear all,

I encountered a problem when compiling Quantum Esspresso (version 6.5). Quantum Esspresso (QE) is a quantum chemistry calculation package which includes the FoX source code. Blow is the error message: ... /usr/bin/ld: /ddk/qe//FoX/lib/libFoX_fsys.a(fox_m_fsys_string.o): relocation R_X86_64_32 against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /ddk/qe//FoX/lib/libFoX_fsys.a(fox_m_fsys_string_list.o): relocation R_X86_64_32 against.rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: /ddk/qe//FoX/lib/libFoX_fsys.a(fox_m_fsys_varstr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status make[2]: [Makefile:256: pw.x] Error 1 make[2]: Leaving directory '/ddk/qe/PW/src' make[1]: [Makefile:9: pw] Error 1 make[1]: Leaving directory '/ddk/qe/PW' make: *** [Makefile:74: pw] Error 1

I googled a lot and tried to re-configure and make the QE with various options such as the following commands, but still got the same errors. make distclean ./configure CFLAGS=-fPIC CPPFLAGS=-fPIC FFLAGS=-fPIC make all It seems that the FoX package has to be compiled with -fPIC flag. My OS is CentOS 8 (64 bit, Intel CPU). Could someone tell me how to resolve this problem? Thanks a lot in advance.

andreww commented 3 years ago

Dear LiangXihui,

It should be possible to compile FoX with '-fPIC' so I suspect the issue here is that the QE configure and make mechanism is not using those flags when compiling or configuring FoX. However, I don't know (and from a quick look cannot immediately see) how QE incorporates FoX into its build system so this is probably a question for the QE community.

If you find an issue compiling FoX (by itself) with -fPIC, could you reopen this report with compiler and version information.

Thanks,

Andrew

LiangXihui commented 3 years ago

Dear Andrew,

Thank you for your reply. Your reply is very helpful to me. I was reminded that I should try using 'sudo' to configure and make the QE. It seems OK! Thank you again.

Best regards,

Xihui


From: Andrew Walker notifications@github.com Sent: Thursday, August 13, 2020 5:01 PM To: andreww/fox fox@noreply.github.com Cc: LiangXihui liangxh@hotmail.com; Author author@noreply.github.com Subject: Re: [andreww/fox] How to compile the FoX with -fPIC flag? (#65)

Dear LiangXihui,

It should be possible to compile FoX with '-fPIC' so I suspect the issue here is that the QE configure and make mechanism is not using those flags when compiling or configuring FoX. However, I don't know (and from a quick look cannot immediately see) how QE incorporates FoX into its build system so this is probably a question for the QE community.

If you find an issue compiling FoX (by itself) with -fPIC, could you reopen this report with compiler and version information.

Thanks,

Andrew

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/andreww/fox/issues/65#issuecomment-673356456, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHGUCL6O3GSFGP76H52XPWLSAOTVJANCNFSM4P5RJ52Q.