Build error using pre-packaged GMP

Philip Höbler philip at hoebler.com
Thu May 27 09:16:16 UTC 2021


Thanks for the quick reply!

The gmp.h is indeed indirectly included as extern "C" {[...]} - in fact, 
RELIC requires being included that way. Did I understand you correctly, 
that this would be a problem for GMP? Or is being included as C 
/necesary/ for GMP?

I'm already in contact with the RELIC authors, if this is the issue I'm 
sure I will find a solution for fixing that together with them.

Am 26.05.21 um 10:31 schrieb Marc Glisse:
> On Mon, 24 May 2021, Philip Höbler wrote:
>
>> Dear GMP people,
>>
>> first of all, thank you for building this awesome project! I have an 
>> issue using it however, and I am mostly clueless why. Some 
>> information on that:
>>
>> - I'm using GMP as part of the RELIC library (that is, configuring 
>> RELIC to use gmp), in a C++ project
>>
>> - System: Fedora 34, x86_64, pre-packaged versions of gmp and 
>> gmp-devel (both 6.2.0: gmp-6.2.0-6.fc34.src.rpm) used
>>
>> - The library is correctly linked as far as I can tell, and no 
>> special build parameters are used by the RELIC Makefiles
>>
>>
>> The error I'm encountering seems to be conflicting declarations 
>> within the gmp-x86_64.h header (which is what stuns me, as it is from 
>> my view pretty much guaranteed to be coherent internally...). The gcc 
>> error output is:
>>
>> In file included from /usr/include/gmp.h:59,
>>                  from [project]/relic/include/relic_types.h:40,
>>                  from [project]/relic/include/relic_arch.h:39,
>>                  from [project]/relic/include/relic.h:81,
>>                  from [project headers...]
>> /usr/include/gmp-x86_64.h:2286:33: error: conflicting declaration of 
>> C function 'std::ostream& operator<<(std::ostream&, mpq_srcptr)'
>>  2286 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, 
>> mpq_srcptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2285:33: note: previous declaration 
>> 'std::ostream& operator<<(std::ostream&, mpz_srcptr)'
>>  2285 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, 
>> mpz_srcptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2287:33: error: conflicting declaration of 
>> C function 'std::ostream& operator<<(std::ostream&, mpf_srcptr)'
>>  2287 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, 
>> mpf_srcptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2285:33: note: previous declaration 
>> 'std::ostream& operator<<(std::ostream&, mpz_srcptr)'
>>  2285 | __GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, 
>> mpz_srcptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2289:33: error: conflicting declaration of 
>> C function 'std::istream& operator>>(std::istream&, mpq_ptr)'
>>  2289 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, 
>> mpq_ptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2288:33: note: previous declaration 
>> 'std::istream& operator>>(std::istream&, mpz_ptr)'
>>  2288 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, 
>> mpz_ptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2290:33: error: conflicting declaration of 
>> C function 'std::istream& operator>>(std::istream&, mpf_ptr)'
>>  2290 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, 
>> mpf_ptr);
>>       |                                 ^~~~~~~~
>> /usr/include/gmp-x86_64.h:2288:33: note: previous declaration 
>> 'std::istream& operator>>(std::istream&, mpz_ptr)'
>>  2288 | __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, 
>> mpz_ptr);
>>
>> I tried building a minimal example replicating this issue, but 
>> couldn't achieve that. My hope is that someone of you has encountered 
>> this before or can tell by pure experience where the issue may be...
>>
>> If anyone of you had an idea what the issue may be, I'd be very 
>> grateful to hear that! In case I can assist you with any more 
>> information, please let me know.
>
> My first guess would be some misguided
>
> extern "C" {
> #include <gmp.h>
> }
>
> (possibly indirectly)
>
> You would have a better chance asking the relic people, or the authors 
> of whatever code using relic you are compiling.
>


More information about the gmp-bugs mailing list