dll help, syntax question


J

Jason

Hello, I've got an example from the mingw website of creating a dll. It is
3 files: a header, .c file and another file containing main. I want to use
the dll in VB and it works for tstfunc, but I am not able to use tststr as
it wont export.

header file:

#ifdef BUILD_DLL
// the dll exports
#define EXPORT __declspec(dllexport)
#else
// the exe imports
#define EXPORT __declspec(dllimport)
#endif

// function to be imported/exported
EXPORT int tstfunc (void);

EXPORT long tststr (void); //I want to use function too

..c file

#include <stdio.h>
#include "dllfct.h"

EXPORT int tstfunc (void)
{
return 200;
}

EXPORT long tststr (void) { //am returning a long due to wanting to use
the pointer in VB because
//experimenting with what
values I can return and use from the dll
char p[10];
p = (char *) "hello\0";
return (long *) p;
}

If I do the below it gives me an error at compile time due to an undefined
reference to _imp__tststr, the name of the second function I wish to export.

#include "dllfct.h"

int main ()
{
tstfunc ();
tststr();
return (0);
}

I guess I need to change this to export the second function, but how? What
does it mean?

#ifdef BUILD_DLL
// the dll exports
#define EXPORT __declspec(dllexport)
#else
// the exe imports
#define EXPORT __declspec(dllimport)
#endif



Thanks for any help.
 
Ad

Advertisements

C

Christian Janßen

Jason said:
Hello, I've got an example from the mingw website of creating a dll. It is
3 files: a header, .c file and another file containing main. I want to use
the dll in VB and it works for tstfunc, but I am not able to use tststr as
it wont export.

header file:

#ifdef BUILD_DLL

Ever though of what this might mean? And when to define it?
 
Ad

Advertisements

J

Jason

sorry, my mistake, i should ask this in comp.lang.c :) I don't mind if you
answer it anyway though!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top