Author Topic: Issue creating DLL  (Read 114 times)

Offline hopslam

  • Single posting newcomer
  • *
  • Posts: 1
Issue creating DLL
« on: November 23, 2020, 09:27:10 pm »
I am trying to create a DLL in codeblocks, and use it in VB.net, but I have been having issues getting the DLL to work. I have created a very simple DLL to test with, and wondering if anyone would know of any settings or anything else that may be causing the issue.

The cpp file:
Code: [Select]
#include "main.h"

// a sample exported function
int DLL_EXPORT SomeFunction()
{
    return 5;
}

The header file:
Code: [Select]
#ifndef __MAIN_H__
#define __MAIN_H__

#include <windows.h>
/*  To use this exported function of dll, include this header
 *  in your project.
 */

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C"
{
#endif

int DLL_EXPORT SomeFunction();

#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__

I call the function into VB.net like this:
Code: [Select]
Class DLL_Functions
    Public Declare Function SomeFunction Lib "C:\Users\Owner\Desktop\Header Test\test\bin\Debug\test.dll" () As Integer
End Class

When I go to run the function I get an error: "Unable to load DLL. The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

I have checked just to ensure the file path is correct as well.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12897
    • Travis build status
Re: Issue creating DLL
« Reply #1 on: November 23, 2020, 11:44:09 pm »
Post the full rebuild log.
Can you use depends.exe to inspect your dll?
Do you see the function?
My guess is that C++ name mangling is causing you the trouble.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]