Re: [cryptopp-users] Undefined symbols for architecture arm64 for CryptoPP in Macbook Air with M1 chip

2022-09-09 Thread Jeffrey Walton
On Thu, Sep 8, 2022 at 11:58 PM Arivarasan K  wrote:
>
> Hello people,
>
> I am trying to install and use CryptoPP library in my Macbook Air M1. I did 
> all the make, install step. When I tried to execute a sample program, I get 
> an error as Undefined symbols for architecture arm64: I give the details 
> below.
>

It looks like you re not linking against the Crypto++ library. Link
against cryptlib.a . Also see
https://www.cryptopp.com/wiki/IOS_(Command_Line) .

Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8kr8CNb%2BYXLZ%2B49n2F5sGEP4ZwYmM8U-s9S3-KCZVy8YA%40mail.gmail.com.


[cryptopp-users] Undefined symbols for architecture arm64 for CryptoPP in Macbook Air with M1 chip

2022-09-08 Thread Arivarasan K
Hello people,

I am trying to install and use CryptoPP library in my Macbook Air M1. I did 
all the make, install step. When I tried to execute a sample program, I get 
an error as Undefined symbols for architecture arm64: I give the details 
below.

LCG.cpp

// sample.cpp : Defines the entry point for the console application.
//

#include "StdAfx.h"

// Runtime Library Includes
#include 
#include 
#include 

// Crypto++ Include
#include // PRNG

int main(int argc, char* argv[])
{ 
// Scratch Area
// Use as seed to the LCG
const unsigned int BLOCKSIZE = 16 * 8;
byte pcbScratch[ BLOCKSIZE ];

std::cout << "Seed:" << BLOCKSIZE << std::endl << std::endl;
// 1st LCG
CryptoPP::LC_RNG lcg1( BLOCKSIZE /*32 bit word */);
lcg1.GenerateBlock( pcbScratch, BLOCKSIZE );

// Output
std::cout << "The 1st LCG produced:" << std::endl;
for( unsigned int i = 0; i < BLOCKSIZE; i++ )
{
std::cout << "0x" << std::setbase(16) << std::setw(2) << std::setfill('0');
std::cout << static_cast( pcbScratch[ i ] ) << " ";
}
std::cout << std::endl;
// @nd LCG
CryptoPP::LC_RNG lcg2( BLOCKSIZE /*32 bit word */);
lcg2.GenerateBlock( pcbScratch, BLOCKSIZE );

// Output
std::cout << "The 2nd LCG produced:" << std::endl;
for( unsigned int i = 0; i < BLOCKSIZE; i++ )
{
std::cout << "0x" << std::setbase(16) << std::setw(2) << std::setfill('0');
std::cout << static_cast( pcbScratch[ i ] ) << " ";
}
std::cout << std::endl; 

return 0;
}

g++ LCG.cpp

LCG.cpp:20:5: error: unknown type name 'byte'; did you mean 
'CryptoPP::byte'?

byte pcbScratch[ BLOCKSIZE ];

^~~~

CryptoPP::byte

/usr/local/include/cryptopp/config_int.h:56:23: note: 'CryptoPP::byte' 
declared here

typedef unsigned char byte;

  ^

1 error generated.


when I add CryptoPP::byte, i get,


g++ LCG.cpp 

Undefined symbols for architecture arm64:

  "CryptoPP::LC_RNG::GenerateBlock(unsigned char*, unsigned long)", 
referenced from:

  _main in LCG-9973ee.o

  "CryptoPP::Algorithm::Algorithm(bool)", referenced from:

  CryptoPP::RandomNumberGenerator::RandomNumberGenerator() in 
LCG-9973ee.o

  "vtable for CryptoPP::RandomNumberGenerator", referenced from:

  CryptoPP::RandomNumberGenerator::RandomNumberGenerator() in 
LCG-9973ee.o

  NOTE: a missing vtable usually means the first non-inline virtual member 
function has no definition.

  "vtable for CryptoPP::LC_RNG", referenced from:

  CryptoPP::LC_RNG::LC_RNG(unsigned int) in LCG-9973ee.o

  NOTE: a missing vtable usually means the first non-inline virtual member 
function has no definition.

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

arivarasan@Arivarasan Sample % g++ LCG.cpp 

LCG.cpp:12:10: fatal error: 'cryptopp/*.h' file not found

#include // PRNG

 ^~

1 error generated.


g++ LCG.cpp -v

Apple clang version 13.1.6 (clang-1316.0.21.2.5)

Target: arm64-apple-darwin21.6.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

 "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple 
arm64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ 
-Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage 
-Werror=implicit-function-declaration -emit-obj -mrelax-all 
--mrelax-relocations -disable-free -disable-llvm-verifier 
-discard-value-names -main-file-name LCG.cpp -mrelocation-model pic 
-pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -fno-rounding-math 
-munwind-tables -target-sdk-version=12.3 
-fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 
-target-feature +v8.5a -target-feature +fp-armv8 -target-feature +neon 
-target-feature +crc -target-feature +crypto -target-feature +dotprod 
-target-feature +fp16fml -target-feature +ras -target-feature +lse 
-target-feature +rdm -target-feature +rcpc -target-feature +zcm 
-target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 
-target-feature +sha3 -target-feature +sha2 -target-feature +aes 
-target-abi darwinpcs -fallow-half-arguments-and-returns 
-debugger-tuning=lldb -target-linker-version 763 -v -resource-dir 
/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6 -isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include 
-stdlib=libc++ -internal-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 
-internal-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include 
-internal-isystem 
/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include 
-internal-externc-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include 
-internal-externc-isystem /Library/Developer/CommandLineTools/usr/include 
-Wno-reorder-init-list -Wno-implicit-int-float-conversion 
-Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt 
-Wno-misleading-indentation -Wno-quoted-include-in-framework-header 
-Wno-implicit-fallthrough -Wno-enum-enum-conversion