Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined reference to crypto_scrypt #224

Closed
bfamzz opened this issue Dec 26, 2019 · 2 comments
Closed

Undefined reference to crypto_scrypt #224

bfamzz opened this issue Dec 26, 2019 · 2 comments

Comments

@bfamzz
Copy link

bfamzz commented Dec 26, 2019

I am working on a c++ project and included libscrypt-kdf but when linking it throws an error.

I included the header file as follows in my project:

#ifdef __cplusplus extern "C" { #endif #include <string.h> #include "scrypt-kdf.h" #ifdef __cplusplus } #endif

Here is also my hashPassword function:

`int hashPassword(const char* password, const char* salt, uint8_t hashedPasswordOutput[]) {
int exitCode = scrypt_kdf((const uint8_t*)password, strlen(password),
(const uint8_t*)salt, strlen(salt), N, r, p, hashedPasswordOutput, OUTPUT_BUFLEN);

return exitCode;

}`

And finally, here is the error being thrown:

/usr/bin/ld: CMakeFiles/hello_crow.dir/main.cpp.o: in function hashPassword(char const*, char const*, unsigned char*)':
main.cpp:(.text+0x1a0e): undefined reference to crypto_scrypt' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/hello_crow.dir/build.make:88: hello_crow] Error 1 make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/hello_crow.dir/all] Error 2 make: *** [Makefile:84: all] Error 2

Here is a screenshot of the error:

image

Kindly help please. Thanks.

@cperciva
Copy link
Member

Sounds like you're not linking to the dynamic library. I don't use CMake so I don't know what the syntax you need for this is.

@bfamzz
Copy link
Author

bfamzz commented Dec 28, 2019

I was able to resolve it. I included this in my CMakeLists.txt file.

target_link_libraries(scrypt-kdf)

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants