entry point not found in dynamic link library in VC++

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 635
Joined: Fri Dec 04, 2015 9:26 pm

entry point not found in dynamic link library in VC++

Post by skinkairewalker »

Hey guys, how are you all?
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

and declaring it like this in C++

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;


}


and when running the c++ application I get this error:

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?
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: entry point not found in dynamic link library in VC++

Post by chi »

Hi, you probably forgot to include the import lib when compiling in VC++. Copy MgmCore.lib to the .dll and add a reference to Project/... Properties/Linker/Input/Additional Dependencies...
Et cetera is my worst enemy
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 635
Joined: Fri Dec 04, 2015 9:26 pm

Re: entry point not found in dynamic link library in VC++

Post by skinkairewalker »

I referenced it this way:
screenshot : https://prnt.sc/QB0-RSrKtOAU
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: entry point not found in dynamic link library in VC++

Post by chi »

Then I don't know, works here... Had to change to PokeS(*Ptr, String, Size, #PB_Unicode) tho ;)
Et cetera is my worst enemy
jassing
Addict
Addict
Posts: 1774
Joined: Wed Feb 17, 2010 12:00 am

Re: entry point not found in dynamic link library in VC++

Post by jassing »

32 vs 64 bit?
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 635
Joined: Fri Dec 04, 2015 9:26 pm

Re: entry point not found in dynamic link library in VC++

Post by skinkairewalker »

I managed to solve it after several attempts to configure the visual c++ correctly.
Post Reply