User forums > Using Code::Blocks
[OpenSSL] - ld returned 1 exit status
(1/1)
Cloud_Strife_Han:
Dear there,
I am testing a snippet to compute hash of file using openssl.
My snippet below:
--- Code: ---#include <openssl/sha.h>
#include <stdio.h>
int main()
{
const unsigned char str[] = "Original String";
unsigned char hash[SHA_DIGEST_LENGTH]; // == 20
SHA1(str, sizeof(str)-1, hash);
// puts(hash);
return 0;
}
--- End code ---
I added lib of openssl but when compiling I got this message in build log.
--- Quote ---
-------------- Clean: Debug in ComputeHash (compiler: GNU GCC Compiler)---------------
Cleaned "ComputeHash - Debug"
-------------- Build: Debug in ComputeHash (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -g -IC:\Users\%username%\Documents\CodeBlock\ComputeHash\ -c C:\Users\%username%\Documents\CodeBlock\ComputeHash\HashComputing.cpp -o obj\Debug\HashComputing.o
g++.exe -o bin\Debug\ComputeHash.exe obj\Debug\HashComputing.o -static lib\libcrypto.lib
lib\libcrypto.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
--- End quote ---
I use Code::Blocks 17.12 recv 11256. Openssl 1.1.1b
How can I fix this? Any idea?
Thanks!
Miguel Gimenez:
libcrypto must be compiled with g++, and probably it will be called libcrypto.a instead of libcrypto.lib.
In general you can't mix objects from two different compilers.
stahta01:
--- Quote from: Miguel Gimenez on March 20, 2019, 12:52:41 pm ---libcrypto must be compiled with g++, and probably it will be called libcrypto.a instead of libcrypto.lib.
In general you can't mix objects from two different compilers.
--- End quote ---
To be more specific (the compiler version matters sometimes); you can most of the times use C compiled library and you can almost never use C++ compiled libraries with different compilers.
Navigation
[0] Message Index
Go to full version