473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

dll help, syntax question

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.

Jul 22 '05 #1
2 1371

"Jason" <ja***********@btinternet.com> schrieb im Newsbeitrag news:bu**********@titan.btinternet.com...
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?
Jul 22 '05 #2
sorry, my mistake, i should ask this in comp.lang.c :) I don't mind if you
answer it anyway though!

"Jason" <ja***********@btinternet.com> wrote in message
news:bu**********@titan.btinternet.com...
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.

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthew Robinson | last post by:
i tried to create a new table using phpmyadmin, but it gave me an error - can anybody see what the problem is, and the correct code i could put into the SQL section (kind of like the mysql command...
3
by: slash | last post by:
Hi , Im new to MySql and i have no idea how to convert a sql server user defined function to MySql. Can any one help me.. CREATE FUNCTION ChildCategories (@categoryId int, @taxId int,...
1
by: Amit D.Shinde | last post by:
Hi Experts, i am writting a stored procedure in sql server 7. Its a simple stored procedure It is my first stored procedure. I want insert a record in table if the primary key field user id...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
2
by: yaffa | last post by:
dear python gurus, quick question on syntax. i have a line of code like this for incident in bs('tr', {'bgcolor' : '#eeeeee'}): what i want it to do is look for 'bgcolor' : '#eeeeee'...
36
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
1
by: anil | last post by:
hello all i am anil kumar, pursuing master's degree in Computer applications . now i have got some opensource project. that is related to USB sniffing. tha t is snoopypro. Actalluy this is...
6
by: toch3 | last post by:
i am writing a c program that is basically an address book. the only header we are using is #include<stdio.hwe are to use a global array, loops, and pointers. we are to have a menu at the...
1
by: mshroom12 | last post by:
Hello to all. I am having difficulty trying to do this Java project using Eclipse. The following is what I have to do. Election Day It's almost election day and the election officials need a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.