Debugging error PQCgenKAT_kem.c
KursatCAKAL opened this issue · 5 comments
How do you debug your code PQCgenKAT_kem.c I am getting below error.
cc -o PQCgenKAT_kem -g2 /Users/kursatc/kyber/ref/PQCgenKAT_kem.c
Undefined symbols for architecture arm64:
"_pqcrystals_kyber768_ref_dec", referenced from:
_main in PQCgenKAT_kem-4da757.o
"_pqcrystals_kyber768_ref_enc", referenced from:
_main in PQCgenKAT_kem-4da757.o
"_pqcrystals_kyber768_ref_keypair", referenced from:
_main in PQCgenKAT_kem-4da757.o
"_randombytes", referenced from:
_main in PQCgenKAT_kem-4da757.o
"_randombytes_init", referenced from:
_main in PQCgenKAT_kem-4da757.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It is fine when you compile it. I am trying to debug code step by step in CLion. Did you try it ? Here are the steps which I follow:
1-) Download algorithm from the page : https://csrc.nist.gov/Projects/post-quantum-cryptography/selected-algorithms-2022
2-) Open Folder in CLion.
3-) Select Algorithm Implementation Type
4-) Go kyber512 or kyber1024
5-) Open PQCgenKAT_kem.c in CLion IDE.
6-) Open Terminal in CLion.
7-) Run "make" command in kyber512 directory
6-) Click Run ico next to the main function at line 26. Then select debug.
I am getting same error when I try to Build (ctrl +f9) or Debug my project.
How did you debug your project in your development cycle?
Sorry for missing some details.
If you want to debug your project. You need below steps:
1-) Create CMakeList.txt
2-) Include it into your project folder.
3-) Open your project folder with CLion.
4-) Select CMake project in "Open or Import Project" window
5-) Make sure related configurations are generated in "Open Project Wizard" window.
Related configurations means that Build Type, Toolchain, Generator, CMake Options etc.
6-) CLion will generate debug options.
Dear @cryptojedi , Could you please share me how do you debug your project in your development cycle? Do you want to add specific cases for above steps?
My CMakeList.txt:
cmake_minimum_required(VERSION 3.12)
project(PQCgenKAT_kem C)
set(CMAKE_C_STANDARD 11)
# Set the source files and headers
set(SOURCES
cbd.c
fips202.c
indcpa.c
kem.c
ntt.c
poly.c
polyvec.c
PQCgenKAT_kem.c
reduce.c
rng.c
verify.c
symmetric-shake.c
)
set(HEADERS
api.h
cbd.h
fips202.h
indcpa.h
ntt.h
params.h
poly.h
polyvec.h
reduce.h
rng.h
verify.h
symmetric.h
)
# Add the executable target
add_executable(PQCgenKAT_kem ${SOURCES} ${HEADERS})
# Set compiler flags
target_compile_options(PQCgenKAT_kem PRIVATE -O3 -march=native -fomit-frame-pointer)
# Link the necessary libraries
target_link_libraries(PQCgenKAT_kem crypto)
I'm using a combination of printf-debugging and gdb. I have never used CLion and I'm afraid I cannot offer help here.
Thank you.
Wish you enjoy work.