Crypto++ 7.0: Warning LNK4221 in project cryptlib with Visual Studio 2015

88 views
Skip to first unread message

Don-Umbro

unread,
Jul 10, 2018, 5:04:40 AM7/10/18
to Crypto++ Users
Hello together,

I'm a new user of the Crypto++ library and just downloaded it about a week ago.
I got the library integrated into our project and it's working fine. Thank's to everyone who contributed to this great work.
I'm working on a Win7 64 bit and with Visual Studio 2015.

However I'm a little irritated, because I get LNK4221 error in project cryptlib even for the original solution cryptest which is shipped with the code:
strciphr.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library [c:\cryptopp\cryptlib.vcxproj]
I get this warnings for object files strciphr.obj, simple.obj, polynomi.obj and algebra.obj.

Looking into these files, I figured that these files consist of definitions / implementations for member functions of template classes. What's the point here? From my understanding templates should in general either be in a header file or be have an explicit instansiation inside the cpp. https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl also discusses this topic, mentioning that my understanding contains some "simplification". So maybe I miss a relevant point here.

simple.cpp does not contain anything at all. oO

What's the point of theses files, do I need them at all?
Can/Should I disable these warnings?
What would be the best way to archive this?
And shouldn't this solution be applied to the public project and not only locally in my project?

I also found this discussion, which mentions LNK4221: https://groups.google.com/d/msg/cryptopp-users/Rn1EOAHnfOk/9rHtbelL2kwJ
However it did not help me regarding my uncertainess...

Regards,
Jan

PS: I also get the warning C4456 for declaration of variable "block" in aria.cpp in lines 151 and 156. Do I get the intention of the code wrong, or would it be enought to just rename these variables to something like "blockTemp"?

Jeffrey Walton

unread,
Jul 10, 2018, 5:24:26 AM7/10/18
to Don-Umbro, Crypto++ Users
On Tue, Jul 10, 2018 at 5:04 AM, Don-Umbro <don-...@sags-per-mail.de> wrote:
> ...
>
> However I'm a little irritated, because I get LNK4221 error in project
> cryptlib even for the original solution cryptest which is shipped with the
> code:

Patches are always welcomed.

We don't bust balls over the trivial stuff like formatting. If you can
move the library forward then we are happy to evaluate it.

>> strciphr.obj : warning LNK4221: This object file does not define any
>> previously undefined public symbols, so it will not be used by any link
>> operation that consumes this library [c:\cryptopp\cryptlib.vcxproj]
>
> I get this warnings for object files strciphr.obj, simple.obj, polynomi.obj
> and algebra.obj.

Try:

* https://github.com/weidai11/cryptopp/commit/3dcceb55f57c
* https://github.com/weidai11/cryptopp/commit/0cee6f01f010

Jeff

Don-Umbro

unread,
Jul 11, 2018, 3:24:46 AM7/11/18
to Crypto++ Users
Hi Jeff,

thanks for your answer.

Patches are always welcomed.

We don't bust balls over the trivial stuff like formatting. If you can
move the library forward then we are happy to evaluate it.

I'm happy to provide a patch / pull request, if I have a solution that benefits the project. However I'm not as experienced with Crypto++, cryptography and c++ in general as many of you probably are. So spamming bad / inappropriate patches onto the project might not be the best... That's why I wanted to get my understanding right and some comments first.

Looking into the issue a little more, I figured that the corresponding *.cpp files themselves are included elsewhere. Basically e.g. "algebra.cpp" in fact seems to be more like a header than a source. One way to get rid of the issue would be renaming "algebra.cpp" to something like "algebra_impl.h". Would you view this as a useful change? Why is it a cpp after all?
This solution would work as well. However IMHO it looks more like a workaround than solving the original issue, which is VisualStudio compiling algebra.cpp because it is a cpp...

Jan

Jeffrey Walton

unread,
Aug 13, 2018, 7:29:23 AM8/13/18
to Crypto++ Users


On Wednesday, July 11, 2018 at 3:24:46 AM UTC-4, Don-Umbro wrote:
...
Looking into the issue a little more, I figured that the corresponding *.cpp files themselves are included elsewhere. Basically e.g. "algebra.cpp" in fact seems to be more like a header than a source. One way to get rid of the issue would be renaming "algebra.cpp" to something like "algebra_impl.h". Would you view this as a useful change? Why is it a cpp after all?

Try:

  * https://github.com/weidai11/cryptopp/commit/3dcceb55f57c
  * https://github.com/weidai11/cryptopp/commit/0cee6f01f010

This solution would work as well. However IMHO it looks more like a workaround than solving the original issue, which is VisualStudio compiling algebra.cpp because it is a cpp...

We also have to clear the warnings when using libtool on Unix and Linux.

Jeff
Reply all
Reply to author
Forward
0 new messages