By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,900 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,900 IT Pros & Developers. It's quick & easy.

Why need .dll if I use static lib?

P: n/a
Hi!
Please be patient with a newbie...

I use DevC++.
I've found and compiled succefully various openGL examples.
Before build the application, I link the project with static libs,
like, in example, libglut32.a.

The executables running fine, but if I try them on a system without
glut32.dll, they don't start.

I'm a bit confused about libraries: if I use static libs, all code
should be included in final executable, right? ...so if I use
libglut32.a, why is needed glut32.dll?

I assume I'm compiling using static libs, because if I don't add the
libglut.a to project, the compiler return a link error. Besides I don't
see, in DevC++, an option like "compile using dynamic libs" and
goggling, I've found an article that explain that, to use dynamic libs,
it's needed a special code, like:

HMODULE LoadLibrary(LPCSTR lpFileName);
FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
BOOL FreeLibrary(HMODULE hModule);
etc...

And lines like these are not in files I'm compiling...

I've found a definition of static libs:
---------------
Just a collection of pre-compiled material declared in the relevant
header files. Needed by the linker. Include into the project.
---------------

So I can compile separately various cpp files, that contains all
functions definitions, to obtain various .o
Finally I compile all into a static lib, that is like "zipping" all .o
in a sort of special compressed file.

So, the .a has ALL I NEED! All objects are into the .a, so the .dll is
not needed...

I've just try to compile a simple static lib and use it in a basic
project...it work, without dll!

An example here:
http://www.crasseux.com/books/ctutor...a-library.html

but using DevC++ is more simple, just choose "static lib" in project
option and compile it.
Later, make a new project that use some functions defined in lib, and
compile it after added the lib to project...

So, I don't understand what happen when I link the linglut32.a or
opengl.a, and why the application need anyway glut32.dll and
opengl32.dll...

Thanks,

Manuel

Jan 12 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 12 Jan 2006 03:54:52 -0800, "in**@dedalo-3d.com"
<in**@dedalo-3d.com> wrote:
Hi!
Please be patient with a newbie...

I use DevC++.
I've found and compiled succefully various openGL examples.
Before build the application, I link the project with static libs,
like, in example, libglut32.a.

The executables running fine, but if I try them on a system without
glut32.dll, they don't start.

I'm a bit confused about libraries: if I use static libs, all code
should be included in final executable, right? ...so if I use
libglut32.a, why is needed glut32.dll?


This is off-topic - it's not a C++ language question. Ask somewhere
more appropriate, and search Google for "import library".
Jan 12 '06 #2

P: n/a
<in**@dedalo-3d.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi!
Please be patient with a newbie...

I use DevC++.
I've found and compiled succefully various openGL examples.
Before build the application, I link the project with static libs,
like, in example, libglut32.a.

The executables running fine, but if I try them on a system without
glut32.dll, they don't start.

I'm a bit confused about libraries: if I use static libs, all code
should be included in final executable, right? ...so if I use
libglut32.a, why is needed glut32.dll?

I assume I'm compiling using static libs, because if I don't add the
libglut.a to project, the compiler return a link error. Besides I don't
see, in DevC++, an option like "compile using dynamic libs" and
goggling, I've found an article that explain that, to use dynamic libs,
it's needed a special code, like:

HMODULE LoadLibrary(LPCSTR lpFileName);
FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
BOOL FreeLibrary(HMODULE hModule);
etc...

And lines like these are not in files I'm compiling...

I've found a definition of static libs:
---------------
Just a collection of pre-compiled material declared in the relevant
header files. Needed by the linker. Include into the project.
---------------

So I can compile separately various cpp files, that contains all
functions definitions, to obtain various .o
Finally I compile all into a static lib, that is like "zipping" all .o
in a sort of special compressed file.

So, the .a has ALL I NEED! All objects are into the .a, so the .dll is
not needed...

I've just try to compile a simple static lib and use it in a basic
project...it work, without dll!

An example here:
http://www.crasseux.com/books/ctutor...a-library.html

but using DevC++ is more simple, just choose "static lib" in project
option and compile it.
Later, make a new project that use some functions defined in lib, and
compile it after added the lib to project...

So, I don't understand what happen when I link the linglut32.a or
opengl.a, and why the application need anyway glut32.dll and
opengl32.dll...


I believe the answer is that the static lib you are linking to is calling
the dynamic library itself.

Althought this is really a windows questions, you should try in
microsoft.public.vc.language as I could be totally wrong.
Jan 12 '06 #3

P: n/a
On 12 Jan 2006 03:54:52 -0800, "in**@dedalo-3d.com"
<in**@dedalo-3d.com> wrote:
Hi!
Please be patient with a newbie...


There are helpful people in the newsgroups below:

comp.graphics.algorithms
comp.graphics.api.opengl

Good Luck
Jan 12 '06 #4

P: n/a
> So, I don't understand what happen when I link the linglut32.a or
opengl.a, and why the application need anyway glut32.dll and
opengl32.dll...


Quick reply only as you're off-topic: under Windows, you need to link
with a .lib / .a when you're calling a DLL - basically, the lib
resolves the linker symbols for the DLL functions - telling it to load
them from the DLL at startup; hence you still need the DLL. LoadLibrary
etc. is usually needed if you only know which DLLs are needed at
runtime [not the case here].

Jan 12 '06 #5

P: n/a
Paul Henderson wrote:
Quick reply only as you're off-topic: under Windows, you need to link
with a .lib / .a when you're calling a DLL - basically, the lib
resolves the linker symbols for the DLL functions - telling it to load
them from the DLL at startup; hence you still need the DLL. LoadLibrary
etc. is usually needed if you only know which DLLs are needed at
runtime [not the case here].


Thanks!
Jan 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.