Dynamic Link Libraries (Help?)

Status
Not open for further replies.

Plasmarobo

Solid State Member
Messages
11
I am creating a program that displays a messagebox based on a integer the user enters, and I want to be able to update it without giving out the entire release...

So I have come to the conclusion that I am going to use a DLL. Problem: I know NOTHING about dll's and related uses.

I need some simple direction on how to make a dll... from complete scratch... I have a project that is designed to compile into a dll, but that is about it (I use C++, my IDE is VC++ 2005 EE)

I am have the message box functions from something else, so they are ready, but have not been "dll-ized"

Thanks...
 
Okay, I figured out most of the dll... but now I have it built and ready to go...mostly. There is one problem. When I try to use it, I get a Entry point not found error at runtime. The error specifies the last function in my dll... Here, I'll post the dll:
(HEADER FILE):
/*
Austens Rank Library Header
*/

#include <windows.h>


#ifndef RANKLIB_DLL_
#define RANKLIB_DLL_

extern "C" __declspec(dllexport) void RlSplash();
extern "C" __declspec(dllexport) void RlCalc(int iPerc, int iCode);

#endif

(CPP FILE (cut out the specific content))
/*
Rank Library Expantions
*/

#include <windows.h>
#include "RankLib.h"



int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
return true;
}

extern "C" __declspec(dllexport) void RlSplash()
{
MessageBox(NULL, L"Austen made this Program!", L"Austen's Translator", MB_ICONASTERISK);
}

extern "C" __declspec(dllexport) void RlCalc(int iPerc, int iCode)
{

wchar_t *text;
wchar_t *title;

MessageBox(NULL, text, title, MB_ICONEXCLAMATION);

}
(END OF CODE)

If this forum supports code tags, let me know and I'll fix it.
 
DLL's are not executable entities. They are dynamic link libraries. You need to create a project that builds to an executable (exe). You can reference the DLL from the exe. However, you really have no need to use a DLL for your project.
 
I know that I do not NEED a dll, and could probably do it better with some normal files, but I wan't to learn how to use DLL's, which is why I am doing this mostly. I want to be able to use them in other projects...

Yeah... I just want to know why It can't find the entry point...
 
Yeah... I just want to know why It can't find the entry point...
Like I just told you, DLL's are not executable. There is no entry point. You will have to create a project that builds to an exe and reference the DLL from that exe.
 
Quote (Programming Windows 5th ed):
The Library Entry and Exit Point:

The dllmain function is called when the library first begins and when it terminates...

End quote

I have no idea what this means... is my book lying to me? Is it as you say, and there is no really entry point!? If so... should I just take DLL main out of my test proj? I actually DO have a seperate project that compiles to EXE that I use to test my Dll... I'm not quite that stupid :)

Anyway... I know that I really shouldn't be using a dll for this, but I just want to know how and get one working...

Thanks :)

Wait, this might help clarify:
When I run my test program I get this error Exactically:

"the procedure entry point RlCalc could not be located in the dynamic link library RANK LIB.dll"

The last function in the dll is called RlCalc.... could it be a problem with that?
 
Wait, this might help clarify:
When I run my test program I get this error Exactically:

"the procedure entry point RlCalc could not be located in the dynamic link library RANK LIB.dll"
Indeed, this helps alot. For future reference, always post error messages.

Your book is correct, as I was referring to the entry point of the program -- not the dll. I was assuming that you were trying to execute a dll in the same manner as an exe.

Make sure you don't have any older versions of your dll laying around. If you do, you may have mistakenly referenced one of them. Also, make sure that you have specified the name of the method correctly. As you may have guessed, your compiler is saying that it can't find a method named 'RlCalc'. Can you use any other methods in your dll? If not, you might be incorrectly referencing the dll.
 
I scanned the directory and deleted all the other compiles of the dll... I had it compile to several dirs... but that wasn't the problem. I tried commenting out the import of the RlCalc, but no dice there. I don't quite know if I am importing it right, but here is my calling code (minus th' windows stuff):XXXXXXXXXXXXXXXXX

(/*
Austens Rank Library Header
*/

#include <windows.h>


#ifndef RANKLIB_DLL_
#define RANKLIB_DLL_

extern "C" __declspec(dllexport) void RlSplash();
extern "C" __declspec(dllexport) void RlCalc(int iPerc, int iCode);

#endif

CPPFILE:

/*
Rank Library Expantions
*/

#include <windows.h>
extern "C"
{
#include "RankLib.h"
}


int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
return true;
}

extern "C" __declspec(dllexport) void RlSplash()
{
MessageBox(NULL, L"Austen made this Program!", L"Austen's % Translator", MB_ICONASTERISK);
}

extern "C" __declspec(dllexport) void RlCalc(int iPerc, int iCode)
{

wchar_t *text;
wchar_t *title;

CONTEND X-ED

MessageBox(NULL, text, title, MB_ICONEXCLAMATION);

}

Yeah... so I though I fixed it once, but it turns out I was using a different project. The functions work if they are in a normal H file... so... whee.

Hey, should I be including the H file with my project too? I am linking to the .lib file, so I figured I didn't need to... should I?
 
The only windows programming I do is with C#. I've never used C++ for windows specific applications. Using Visual Studio and C#, you specify the dll in the project properties references. After that, you can use a 'using' directive to specify the class. From that point, you should be able to freely use the code in the dll -- well, that's how it works in C#. I would venture to say that this is the way it works for C++ .NET. However, since you're not using .NET, it could be different.
 
Status
Not open for further replies.
Back
Top Bottom