Creating a DLL

Eeeesh.
Sorry for being a newbie idiot for posting things question but …

I’m trying to compile a set of routines that use SDL into a library.

Heck, I don’t care if it’s statically or dynamically linked (dynamic would
be cool though). I’m a win32 user with Visual Studio 6.0.
I created a project that said it would be a dynamically linked dll.

It generated a .dll file. I could not link that into a project that used
SDL and I could not get it to do anything.

Sorry for being stupid,

Rob_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

How do I go about compiling the libraries (such as sdl_ttf, sdl_mixer,
etc.) under VC++? I’m assuming I should end up w/ some .lib files, correct?--------------------------
Real software engineers don’t debug programs, they verify correctness.
This process doesn’t necessarily involve execution of anything on a
computer, except perhaps a Correctness Verification Aid package.

In-Reply-To:

How do I go about compiling the libraries (such as sdl_ttf, sdl_mixer,
etc.) under VC++? I’m assuming I should end up w/ some .lib files, correct?

I think I answered my own question =)… that’d be a static link library…
heheh>Date: Mon, 05 Feb 2001 21:08:07 -0600

To: sdl at lokigames.com
From: Joe Tennies
Subject: compiling libraries in VC++


Real software engineers don’t debug programs, they verify correctness.
This process doesn’t necessarily involve execution of anything on a
computer, except perhaps a Correctness Verification Aid package.

Heck, I don’t care if it’s statically or dynamically linked (dynamic would
be cool though). I’m a win32 user with Visual Studio 6.0.
I created a project that said it would be a dynamically linked dll.

It generated a .dll file. I could not link that into a project that used
SDL and I could not get it to do anything.

It should have also generated a .lib. Try including that in your other
project, like you do for sdl.lib and sdlmain.lib. Also, make sure the .dll
is in an appropriate directory. ( : If you still can’t link, maybe you
could post your error messages.

Keep in mind, when you are building and benchmarking your projects, that
there are differences between debug and release versions of the lib and dll
files.

  • Brent

I had problems with a .dll I was making recently (mainly it did’nt
generate a .lib when I knew it should). It turned out that the
functions that need to be exported (so other stuff can get to them)
need to be declared as DECLSPEC, and example would be.

void MyCoolFunction(void);
did’nt generate nada

extern DECLSPEC void MyCoolFunction(void);
spit out the .lib I needed to link :slight_smile:

not saying this is what happened here, but it bit me just last week.

Brent Schartung wrote:

Heck, I don’t care if it’s statically or dynamically linked (dynamic
would> > be cool though). I’m a win32 user with Visual Studio 6.0.

I created a project that said it would be a dynamically linked dll.

It generated a .dll file. I could not link that into a project that used
SDL and I could not get it to do anything.

It should have also generated a .lib. Try including that in your other
project, like you do for sdl.lib and sdlmain.lib. Also, make sure the .dll
is in an appropriate directory. ( : If you still can’t link, maybe you
could post your error messages.

Keep in mind, when you are building and benchmarking your projects, that
there are differences between debug and release versions of the lib and dll
files.

  • Brent

Keep in mind, when you are building and benchmarking your projects, that
there are differences between debug and release versions of the lib and
dll files

There shouldn’t be any differences between the lib files of a release or
debug dll. Since the lib file is the part of the library that is actually
linked into the program, it should even be the same between two dlls which
export the same functions.
That way, the lib and the linked program is independent of the structures
inside the dll, resulting in either an easily updatable system or “dll hell”
:slight_smile:

You have to declare the functions which should be exported like
"extern DECLSPEC int SDL_Init(Uint32 flags);",
a good tool to check if those exports exist is the Dependency Walker
"depends.exe" from the MS Platform SDK (should be also with VC)

Oh, and Visual C 5 has this stupid bug where the program will compile, link,
and then fail to load inside the dev. environment because of a missing dll
(without a message box). Simply copy the dll to the search path to solve
this.

HTH

Great, thanks guys.
How do I ‘export’ a class in a c++ project?
I see how I can apply extern DECLSPEC easily to a function, but not to a
class. Do I have to apply it to each public member function I want to
export or what?> > Keep in mind, when you are building and benchmarking your projects, that

there are differences between debug and release versions of the lib and
dll files

There shouldn’t be any differences between the lib files of a release or
debug dll. Since the lib file is the part of the library that is actually
linked into the program, it should even be the same between two dlls which
export the same functions.
That way, the lib and the linked program is independent of the structures
inside the dll, resulting in either an easily updatable system or “dll
hell”
:slight_smile:

You have to declare the functions which should be exported like
"extern DECLSPEC int SDL_Init(Uint32 flags);",
a good tool to check if those exports exist is the Dependency Walker
"depends.exe" from the MS Platform SDK (should be also with VC)

Oh, and Visual C 5 has this stupid bug where the program will compile,
link,
and then fail to load inside the dev. environment because of a missing
dll
(without a message box). Simply copy the dll to the search path to solve
this.

HTH


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Thanks for everyone’s help so far.

I’ve now been able to create a dynamically linked dll and lib file of my
classes I want, but I still have a couple of problems.

The dll’s all share an external class that they access the contents of.
This variable is defined in my main.cpp function. This used to work fine,
but now the dll doesn’t receive the created variable, even though I have
extern myClass *test; in the dll’s classes. Is there something special I
have to do to share between a dll and my main project?

Also, fprintf(stderr, “”) doesn’t appear to write anything from within the
dll, again, am I missing something simple.

Thanks for all the help,

Rob_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

I don’t think anyone actually answered this for you, so I will try… though
I am not sure if this is a valid arguement or not… just my best guess.

I believe what you need to do is pass a pointer (or reference) around (note:
you’ll probably have to make these long pointers). If you are trying to
pass a class that is declared and made in the DLL but the .exe doesn’t know
about it until it is loaded, that’s not gonna happen. You will need to
create an abstract class that the one in the DLL must inherit from.

Some good info on this can be found on Borland’s community site
(community.borland.com)… do a search for ‘class dll’. (not in quotes…
just two words)

Joe Tennies> ----- Original Message -----

From: owner-sdl@lokigames.com [mailto:owner-sdl at lokigames.com]On Behalf
Of Robert Clayton
Sent: Tuesday, February 06, 2001 4:01 PM
To: sdl at lokigames.com
Subject: Re: [SDL] Re: Creating a DLL

Great, thanks guys.
How do I ‘export’ a class in a c++ project?
I see how I can apply extern DECLSPEC easily to a function, but not to a
class. Do I have to apply it to each public member function I want to
export or what?