-
Need help with LNK error
Hi, when I build my project I got the following errors:
main3.obj : error LNK2031: unable to generate p/invoke for "extern "C" unsigned char * __clrcall SHA1(unsigned char const *,unsigned int,unsigned char *)" (?SHA1@@$$J0YMPAEPBEIPAE@Z); calling convention missing in metadata
main3.obj : error LNK2028: unresolved token (0A000012) "extern "C" unsigned char * __clrcall SHA1(unsigned char const *,unsigned int,unsigned char *)" (?SHA1@@$$J0YMPAEPBEIPAE@Z) referenced in function "int __clrcall openssl(unsigned long,unsigned long)" (?openssl@@$$FYMHKK@Z)
main3.obj : error LNK2019: unresolved external symbol "extern "C" unsigned char * __clrcall SHA1(unsigned char const *,unsigned int,unsigned char *)" (?SHA1@@$$J0YMPAEPBEIPAE@Z) referenced in function "int __clrcall openssl(unsigned long,unsigned long)" (?openssl@@$$FYMHKK@Z)
E:\VHDL_work\communication\Communication_Control_P anel\Debug\Communication_Control_Panel.exe : fatal error LNK1120: 2 unresolved externals
I have already set Linker input option correct, so I can't see where those errors are coming from, can someone help me or give a point ?
MS Visual studio C++ 2005
-
what can i do with just the errors. show atleast the
source-code so i can point to the problem. :S
-
Thank you for reply
Thank you for reply:)
My code is pretty long so I'm not sure of uploading it, I guess I could upload a part of it, where I think cause the error.
Code:
#include "stdafx.h"
#include "openssl/sha.h"
#include <stdio.h>
#include <stdlib.h> /* required for randomize() and random() */
#include <time.h> /* required for time()*/
#include <math.h>
#include <fcntl.h>
#include <string.h>
#include "unistd.h"
#include "function.h"
#pragma once
#define Q 60
#define D 8
unsigned long B;
unsigned long ** key;
unsigned long rounds;
unsigned long rest;
unsigned long a,i,j,k,l,r;
int fd;
int RUSAGE_SELF;
int openssl(unsigned long rounds, unsigned long B )
{
unsigned char key[][32]= {""};//use to store all the 256-bit keys ,key[B][32] 8*32
unsigned char message[48]; //the first 64 bit of message stands for N,
//and 2nd 64 bits stands for R and the rest stands for key.
//definition de msg
unsigned char result[21];
unsigned char result_temp[22];
srand((unsigned) time(NULL));
for(r=0;r<rounds;r++)
{
fd = _open( "/dev/urandom", O_RDONLY );
_read( fd, (void *) key, B*32 );//2^16*16*2
_read(fd, (void *)message, 16);//64*2
_close(fd);
rand_1=rand() /64 %256;
rand_2=rand() /64 %256;
ID = rand_1+rand_2*256;
ID = ID%B;//in case ID >B
memcpy(message+16, key[ID],32);
SHA1(message,48,result);//instead of Ff fct
B=64;
for (i=0; i <B; i++)
{
memcpy(message+16, key[i],32);
SHA1(message,48,result_temp);
for(j=0; j<20; j++)
{
if(result_temp[j]!=result[j])
{
break;
}
}
if (j==20)
{
break;
}
}
}//end of rounds
return 0;
}
-
> I have already set Linker input option correct
Well apparently you haven't.
Or at least not to the satisfaction of the linker.
Did you specify both the name of the library AND the location where to find it?