Userlib Issues

BlitzPlus Forums/BlitzPlus Beginners Area/Userlib Issues

Sauer(Posted 2009) [#1]
So I'm trying to implement some C code, but I keep getting the error "userlib not found".

Here's the .decls:
.lib "clear.dll"
ClearConsole():"_ClearConsole@0"


And here is the .dll:
#include <stdio.h>
#include <stdlib.h>

#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall

BBDECL int BBCALL ClearConsole(void)
{
    system("cls");
    return 0;
}


I looked at the samples and tried to compare, but I can't find the problem. It comes up yellow in the IDE so I guess there's a problem with the .dll? I made the .dll by writing some C code and changing the extension to .dll.

I think that's all the info that's relevant, any help is appreciated, thanks!


epiblitikos(Posted 2009) [#2]
I made the .dll by writing some C code and changing the extension to .dll.


You got it right, the problem is with your DLL. You need to compile the source into a DLL--I use Visual C++ Express 2008 for my C/C++ codings (including DLLs), its free and available at http://www.microsoft.com/express/vc/ .

How you'll want to proceed once you have VC++:
1) make a new project (call it "clear" in accordance with your .decls file)
2) select "Win32 Console Application"
3) under "Application Settings" select the "DLL" radio button and check the "Empty project" checkbox--click "OK".
4) add a source file (a .cpp file) to your project (right-click the "Source Files" folder in the Solution Explorer menu)
5) copy in your code (which looks clean to me)
6) select "Build clear" (under the build menu)
7) find clear.dll where you built it (use a search if you have to) and copy it into the userlibs folder in the BlitzPlus directory (along with your .decls file).

Note: When you compile your program in BlitzPlus, you have to keep/distribute the DLLs you use with it. The DLLs are called in your program at the path given in the .lib directive of your .decls file. That is, if your .decls has the line
 .lib "stuff/things.dll" 

Then you want to have things.dll at {program folder}/stuff/ in order for your compiled program to work.


Sauer(Posted 2009) [#3]
Hey thanks a lot, I am using the Code::Blocks IDE and I believe it has something similar to what you described in Visual C++. If I cannot get it to work there I'll go download it.

EDIT: Wait, but if I'm doing it in Code::Blocks will the BBCALL and BBDECL declarations be the same?

Thanks again,


epiblitikos(Posted 2009) [#4]
Yep, those are standard C/C++ preprocessor calls.


Sauer(Posted 2009) [#5]
Gosh I still can't get it to work, I know it's a long shot, but does anyone use Code::Blocks? It's frustrating because I have the code and my program is ready to work except one of the crucial elements lies in this .dll...