libtomcrypt icon indicating copy to clipboard operation
libtomcrypt copied to clipboard

ltc_math_descriptor redefinition error when attempting to compile using LTM as math provider.

Open Allevon412 opened this issue 1 year ago • 2 comments

Prerequisites

  • [x] Checked the developer manual
  • [x] Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=repo%3Alibtom%2Flibtomcrypt
  • [x] Checked that your issue isn't due to the fact that you're using asymmetric cryptography and you forgot linking in and/or setting an MPI provider (usually this causes either random crashes or runtime errors like LTC_ARGCHK 'ltc_mp.name != NULL' failure ...). c.f. Ch. "Math Descriptors" of the developer manual.
  • [x] Checked that your issue isn't related to TomsFastMath's limitation that PK operations can by default only be done with max. 2048bit keys

Description

[Description of the issue]

My issue is in attempting to compile the libtomcrypt library using visual studio 2022. I hit the following error when I attempt to using the tommath.lib library as the math provider. I have the following math provider defined in tomcrypt_custom.h

/* ---> math provider? <--- */ #ifndef LTC_NO_MATH

/* LibTomMath */ #define LTM_DESC

/* TomsFastMath / / #define TFM_DESC */

/* GNU Multiple Precision Arithmetic Library / / #define GMP_DESC */

#endif /* LTC_NO_MATH */

Severity Code Description Project File Line Suppression State Details Error C2371 'ltc_math_descriptor': redefinition; different basic types libtomcrypt D:\OffsecTools\libtomcrypt\src\headers\tomcrypt_math.h 501

Steps to Reproduce

Version

#define SCRYPT "1.18.2-develop"

You can get this information from the define SCRYPT in src/include/tomcrypt.h or your local git repository by running git describe --always --tags --dirty. Also, please include the compiler, the compiler version, the architecture and (if applicable) the MPI provider, the OS and what version of the OS you're experiencing the issue. Windows 10 x64 bit Visual Studio compiler 2022.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Allevon412 avatar Mar 19 '24 20:03 Allevon412

Can you please give more details on how to reproduce the error?

We're successfully building ltc+ltm with MSVC in our AppVeyor CI jobs, so I suspect a configuration issue, resp. an issue with how you build the libraries.

sjaeckel avatar Mar 20 '24 13:03 sjaeckel

Here are some more screenshots of my current configuration. What other information do you think you would need?

image image image

Allevon412 avatar Mar 20 '24 18:03 Allevon412

any word on this? all i tried to do was build using default settings in MSVS 2022 release x64 bit architecture.

Allevon412 avatar Mar 21 '24 19:03 Allevon412

Nvm I got it to build by adding #pragma once to the tomcrypt_custom.h file to negate the redefinition. I am assuming the header being included in multiple files caused a weird compiler error where it was being defined everywhere.

Allevon412 avatar Mar 21 '24 19:03 Allevon412