Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > dll help, syntax question

Reply
Thread Tools

dll help, syntax question

 
 
Jason
Guest
Posts: n/a
 
      01-19-2004
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.



 
Reply With Quote
 
 
 
 
Christian Janßen
Guest
Posts: n/a
 
      01-19-2004

"Jason" <> schrieb im Newsbeitrag news:buh21g$fpi$...
> 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?


 
Reply With Quote
 
 
 
 
Jason
Guest
Posts: n/a
 
      01-19-2004
sorry, my mistake, i should ask this in comp.lang.c I don't mind if you
answer it anyway though!

"Jason" <> wrote in message
news:buh21g$fpi$...
> 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.
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Why does Ruby use both tcl83.dll and tk83.dll (instead of just tk83.dll)? H. Simpson Ruby 4 08-03-2004 04:45 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
WinXP "Windows Explorer has encountered a problem and needs to close...." Shell32.dll and ntdll.dll question. Sparky Computer Support 3 01-24-2004 11:53 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57