473,396 Members | 2,011 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,396 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 5074
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: SteveM | last post by:
This is probably an easy answer but since I am fairly new to C++ for some reason I can't see it :-( Any help would be appreciated :-) I have a class: class AClass { public:
11
by: Matthew | last post by:
Ok let me try to explain this as good as I can. I am creating this application where it contains a userlogin class. The user logs in before entering the main apploication. I want to do audit trails...
0
by: jhhbr549 | last post by:
Need to write a class called Sales that is extends from a super class called Employee. I feel like I am going in the wrong direction. look at this: Here are the specs: static double field...
32
by: lcdgoncalves | last post by:
Hi everyone Is there a real need to use keyword static with functions, if we simply don't declare their prototypes in .h file? Many textbooks avoid to discuss this matter and/or discuss only...
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
19
by: subramanian100in | last post by:
Stroustrup, in his book TC++PL 3rd Edition, in page 16, under the section '1.8 Advice' has mentioned the following: Don't use global data(use members) Don't use global functions Don't use...
0
by: doobybug | last post by:
Hi all, I really need your help! I am new to java and have some problems with my code. I have a program which inputs questionnaires and creates an object for each questionnaire. These objects are...
9
by: Tool69 | last post by:
Hi, Until now, I was running my own static site with Python, but I'm in need of dynamism. After reading some cgi tutorials, I saw Joe Gregorio's old article "Why so many Python web...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.