Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 加密++;导致Qt Creator中的引用未定义,但代码::块中的引用未定义_Linux_Qt_Undefined Reference_Crypto++ - Fatal编程技术网

Linux 加密++;导致Qt Creator中的引用未定义,但代码::块中的引用未定义

Linux 加密++;导致Qt Creator中的引用未定义,但代码::块中的引用未定义,linux,qt,undefined-reference,crypto++,Linux,Qt,Undefined Reference,Crypto++,几乎来自Crypto++的每个函数都会在Qt Creator中生成未定义的引用,但code::blocks运行得非常好 LIBS+= -lcryptopp 在.pro文件中似乎可以工作,因为我可以包含所需的文件并声明变量,除非构造函数重载 比如说 CryptoPP::Integer integer; std::string str=CryptoPP::IntToString(integer, 10); 投掷 .../main.cpp:54: undefined reference

几乎来自Crypto++的每个函数都会在Qt Creator中生成未定义的引用,但code::blocks运行得非常好

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

比如说

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

.../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 
../main.cpp:54:std::string CryptoPP::IntToString(CryptoPP::Integer,unsigned int)的未定义引用
collect2:错误:ld返回了1个退出状态
make:**[PDBM]错误1
07:10:21:进程“/usr/bin/make”已退出,代码为2。
//抱歉,stackoverflow希望这些链接是代码
/usr/lib/包含libcrypto++.a、libcrypto++.so、libcryptopp.so以及到libcrypto++.a的链接,名为libcryptopp.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
在/usr/include/cryptopp/secblock.h:7:0中包含的文件中,
from/usr/include/cryptopp/integer.h:7,
from../cryptest/main.cpp:7:
/usr/include/cryptopp/misc.h:在“std::string cryptopp::IntToString(T,unsigned int)[with T=cryptopp::Integer;std::string=std::basic_string]”的实例化中:
../cryptest/main.cpp:54:54:此处为必填项
/usr/include/cryptopp/misc.h:424:58:错误:从类型“cryptopp::Integer”转换为类型“char”无效
结果=字符((数字<10?'0':('a'-10))+数字)+结果;
^
Makefile:1113:目标“main.o”的配方失败
这意味着cryptopp一直在使用这些新的.h文件。所以,这不仅仅是我以前认为的链接器的问题

我在Ubuntu 16.04上,使用Qt5.8和存储库中的Crypto++

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

必须使用
-L
选项指定包含开发人员库副本的文件夹。例如,如果库位于/usr/lib中,则编写以下代码:

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

您可以提供错误消息,还可以解释代码块与Qt之间的关系。哪些是未定义的引用?添加逐字链接器输出。显示Qt项目文件和错误消息示例。另请参见、、等。Code::Blocks使用相同的编译器(可以是不同的版本,但我在bith上尝试了相同的结果)和相同的cryptopp。主要区别在于qt使用make,而C::B不使用。从控制台运行make会得到相同的结果。
std::string str=CryptoPP::IntToString(整数,10)相对较新。它是在Crypto++6.0中添加的。听起来像是Qt项目中链接到的
libcryptopp.a
是旧发行版提供的;而不是你正在建造的新建筑。这是有意义的,因为编译路径包括
-I/usr/local/include
(新标题),但链接路径不包括
-L/usr/local/lib
(新库)。因此,将
-L/usr/local/lib
添加到Qt链接器标志中。或者,代替
-l:libcryptopp.a
,使用完整的
/usr/local/lib/libcryptopp.a
。另一个选项是
对象+=/usr/lib/libcryptopp.a
。这将使用到库的静态链接,并可能避免下一组与路径问题相关的问题。使用静态链接和避免路径问题的另一种方法是
LIBS+=-L/usr/lib/-L:libcryptopp.a
。还可以看到,我已经尝试将此修补程序添加到LIBS,并将libcryptopp.a添加到对象,但没有任何更改。回家后我会尝试第二种选择。@user9398723
/usr/lib/
只是一个例子。您需要找出libcryptopp在计算机中的正确位置。另外,请记住在编辑.pro文件后重新运行qmake,以便更新Makefile。
LIBS += -L/usr/lib/ -lcryptopp