Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old January 12th, 2006, 12:05 PM
info@dedalo-3d.com
Guest
 
Posts: n/a
Default 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

  #2  
Old January 12th, 2006, 12:25 PM
W Marsh
Guest
 
Posts: n/a
Default Re: Why need .dll if I use static lib?

On 12 Jan 2006 03:54:52 -0800, "info@dedalo-3d.com"
<info@dedalo-3d.com> wrote:
[color=blue]
>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?[/color]

This is off-topic - it's not a C++ language question. Ask somewhere
more appropriate, and search Google for "import library".
  #3  
Old January 12th, 2006, 12:25 PM
Jim Langston
Guest
 
Posts: n/a
Default Re: Why need .dll if I use static lib?

<info@dedalo-3d.com> wrote in message
news:1137066892.777186.83520@z14g2000cwz.googlegro ups.com...[color=blue]
> 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...[/color]

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.


  #4  
Old January 12th, 2006, 02:25 PM
JustBoo
Guest
 
Posts: n/a
Default Re: Why need .dll if I use static lib?

On 12 Jan 2006 03:54:52 -0800, "info@dedalo-3d.com"
<info@dedalo-3d.com> wrote:
[color=blue]
>Hi!
>Please be patient with a newbie...[/color]

There are helpful people in the newsgroups below:

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

Good Luck
  #5  
Old January 12th, 2006, 05:45 PM
Paul Henderson
Guest
 
Posts: n/a
Default Re: Why need .dll if I use static lib?

> So, I don't understand what happen when I link the linglut32.a or[color=blue]
> opengl.a, and why the application need anyway glut32.dll and
>opengl32.dll...[/color]

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].

  #6  
Old January 12th, 2006, 08:05 PM
Manuel
Guest
 
Posts: n/a
Default Re: Why need .dll if I use static lib?

Paul Henderson wrote:
[color=blue]
> 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].
>[/color]

Thanks!
 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles