Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>#pragma once #pragma comment (lib, "CryptoLib.lib") #include "stdafx.h" </code></pre> <p>This is wrong. The compiler will go looking for the stdafx.h #include directive and <strong>ignores</strong> anything it finds before that. So it will completely ignore your #pragma comment directive. The linker will therefore <em>not</em> link CryptoLib.lib and you'll indeed get this linker error. Using #pragma once in a .cpp file does not make sense. </p> <p>Another problem is that you appear to compile this code with /clr in effect, we can tell from the <em>using</em> statement. The compiler cannot tell that your function is a __cdecl function, it will assume the default and that's __clrcall when managed code compilation is enabled. You have to be explicit about it, like this: </p> <pre><code>#include "stdafx.h" // First line in file! #pragma managed(push, off) #include "CryptoLib.h" #pragma comment (lib, "CryptoLib.lib") #pragma managed(pop) </code></pre> <p>There's yet another possible problem with the function declaration, it isn't clear whether that function was compiled with a C compiler or a C++ compiler. A C++ compiler will <em>decorate</em> the function name. If it was actually compiled with a C compiler then you have to tell the compiler about that:</p> <pre><code>#ifndef _CRYPTOLIB_H_ #define _CRYPTOLIB_H_ #ifdef __cplusplus extern "C" { #endif void __cdecl CryptoLib_Encrypt(unsigned char *Data, unsigned char *RandomNr); #ifdef __cplusplus } #endif #endif /* _CRYPTOLIB_H_ */ </code></pre> <p>Note the usage of <code>extern "C"</code>, it disables name decoration. If you cannot or should not edit this header file then you can cram the extern "C" {} in your .cpp file, surrounding the #include.</p> <p>If you still have trouble then post the <strong>exact</strong> linker error message as well what you see when you run <code>Dumpbin.exe /exports</code> on the DLL from the Visual Studio Command Prompt.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload