gpt4 book ai didi

linux - Crypto++ 在 Qt Creator 中导致 undefined reference ,但在 code::blocks 中没有

转载 作者:太空宇宙 更新时间:2023-11-04 10:11:18 26 4
gpt4 key购买 nike

Crypto++ 中的几乎每个函数都会在 Qt Creator 中产生 undefined reference ,但是 code::blocks 运行得很好。

LIBS+= -lcryptopp  

在 .pro 文件中似乎可以工作,因为我可以包含所需的文件并声明变量,除非构造函数重载。

例如

CryptoPP::Integer integer;  
std::string str=CryptoPP::IntToString(integer, 10);

throw

.../main.cpp:54: undefined reference to `std::string CryptoPP::IntToString<CryptoPP::Integer>(CryptoPP::Integer, unsigned int)'  
collect2: error: ld returned 1 exit status
make: *** [PDBM] Error 1
07:10:21: The process "/usr/bin/make" exited with code 2.

<a href="https://pastebin.com/c9nWekZR">cryptest.pro</a>
<a href="https://pastebin.com/0ku8Dncw">Makefile</a>
<a href="https://pastebin.com/ii1AM1Dx">full rebuild</a> //sorry, stackoverflow wants those links to be a code

/usr/lib/包含 libcrypto++.a、libcrypto++.so、libcryptopp.so 和指向名为 libcryptopp.a 的 libcrypto++.a 的链接

新发现:我之前曾尝试编译这个库,现在我的项目文件夹中包含 cryptopp 文件夹中的所有 .h 和 .cpp 文件。在不显示代码的情况下提供所有代码,已创建新项目并出现更多错误:

In file included from /usr/include/cryptopp/secblock.h:7:0,
from /usr/include/cryptopp/integer.h:7,
from ../cryptest/main.cpp:7:
/usr/include/cryptopp/misc.h: In instantiation of ‘std::string CryptoPP::IntToString(T, unsigned int) [with T = CryptoPP::Integer; std::string = std::basic_string<char>]’:
../cryptest/main.cpp:54:54: required from here
/usr/include/cryptopp/misc.h:424:58: error: invalid cast from type ‘CryptoPP::Integer’ to type ‘char’
result = char((digit < 10 ? '0' : ('a' - 10)) + digit) + result;
^
Makefile:1113: recipe for target 'main.o' failed

这意味着 cryptopp 一直在使用那些新的 .h 文件。所以这不仅仅是我之前认为的链接器的问题。

我在 Ubuntu 16.04 上,使用存储库中的 Qt 5.8 和 Crypto++。

最佳答案

-lcryptopp

这个选项只是告诉你的链接器你想链接到一个名为 libcryptopp.so 的共享库。但是,它不会告诉您的链接器在哪里可以找到共享库。

您必须使用 -L 选项指定包含开发人员库副本的文件夹。例如,如果库在/usr/lib 中,那么这样写:

LIBS += -L/usr/lib/ -lcryptopp

关于linux - Crypto++ 在 Qt Creator 中导致 undefined reference ,但在 code::blocks 中没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48937867/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com