I'm trying to make a dll for C++, but I'm having a lot of headaches...
I'm using the code in purebasic below:
Code: Select all
Declare ConvertString(String.s)
DeclareCDLL.i HelloW(msg.i)
Procedure ConvertString(String.s)
Size=StringByteLength(String)
If Size>0
Protected *Ptr=AllocateMemory(Size+2)
If *Ptr
PokeS(*Ptr, String, Size, #PB_Ascii)
ProcedureReturn *Ptr
EndIf
EndIf
EndProcedure
ProcedureCDLL.i HelloW(msg.i)
ProcedureReturn ConvertString(PeekS(msg))
EndProcedure
Code: Select all
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <windows.h>
using namespace std;
extern "C" __declspec(dllimport) char* __cdecl HelloW(const char* msg);
int main()
{
std::string nome = "This is a string example";
const char* nomeCStr = nome.c_str();
char* result = HelloW(nomeCStr);
std::cout << "dll pb test!\n";
std::cout << result;
}
Could not find HelloW procedure entry point in dynamic link library
screenshot console : https://prnt.sc/0Lp2cgH-wor0
screenshot dll exported in release folder : https://prnt.sc/EQvDFbahmMMa
Can someone help me understand and resolve?