Невозможно связать с неопределенной ссылкой на VTT для CryptoPP :: RSAFunction - PullRequest
0 голосов
/ 24 января 2019

Я использую Crypto ++ на aarch64, я сталкиваюсь с проблемой при компиляции моего бинарного файла, использующего cryptopp-7.0.0, единственная проблема со ссылками, с которой я сталкиваюсь, связана с RSAFunction, все остальные классы работают отлично, здесьэто сама программа, которая действительно является основной, которая изолирует проблему:

#include "cryptopp/rsa.h"
using CryptoPP::RSA;

#include <string.h>
using std::string;

#include <unistd.h>

int main(void)
{
    RSA::PublicKey publicKey;
    return 0;
}

При попытке скомпилировать с помощью этой команды:

~$ toolchain/bin/aarch64-libreelec-linux-gnueabi-g++ cryptopptestfile.cpp -o crypttest -L/toolchain/usr/lib -lcryptopp

Я получил эти ошибки:

<artificial>:(.text+0xe7c): undefined reference to `vtable for CryptoPP::RSAFunction'
<artificial>:(.text+0xe80): undefined reference to `vtable for CryptoPP::RSAFunction'
<artificial>:(.text+0xea8): undefined reference to `VTT for CryptoPP::RSAFunction'
<artificial>:(.text+0xeb4): undefined reference to `VTT for CryptoPP::RSAFunction'
/tmp/ccs498WJ.ltrans0.ltrans.o: In function `CryptoPP::InvertibleRSAFunction::~InvertibleRSAFunction()':
<artificial>:(.text+0x10c0): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x10c4): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x10c8): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x112c): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
/tmp/ccs498WJ.ltrans0.ltrans.o: In function `CryptoPP::InvertibleRSAFunction::InvertibleRSAFunction()':
<artificial>:(.text+0x12e4): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x12f8): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x1324): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x132c): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x13cc): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x13dc): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'

Это относится только к:

cryptopp::RSAFunction(s)

Спасибо за помощь.

Вот флаги компиляции:

arch64-libreelec-linux-gnueabi-g++ -march=armv8-a+crc+fp+simd -mabi=lp64 -Wno-psabi -mcpu=cortex-a53+crc+fp+simd -fomit-frame-pointer -Wall -pipe -Os -flto -ffat-lto-objects -fPIC -pipe -c rsa.cpp

g ++ версия:

6.2.0

1 Ответ

0 голосов
/ 24 января 2019

Обнаружена проблема, это из-за этого флага компиляции:

-flto

Как только я уберу этот флаг компиляции, все будет работать нормально, обратите внимание, что активация этого флага:

-flto:
This option runs the standard link-time optimizer. When invoked with 
source code, it generates GIMPLE (one of GCC’s internal representations) 
and writes it to special ELF sections in the object file. When the object 
files are linked together, all the function bodies are read from these ELF 
sections and instantiated as if they had been part of the same translation 
unit.

Этот флаг разрывает компоновщик при использовании функции (функций) RSA, протестированных с версии 6.0.0 до 8.0.0

...