471,599 Members | 1,009 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Why need .dll if I use static lib?

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
5 4948
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
<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
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
> 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
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.

Similar topics

3 posts views Thread by SteveM | last post: by
11 posts views Thread by Matthew | last post: by
13 posts views Thread by PinkBishop | last post: by
19 posts views Thread by subramanian100in | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.