473,394 Members | 1,893 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,394 software developers and data experts.

static and dynamic linking a dll

17
How to link a dll statically?

How to link a dll dynamically?

When we use Loadlibrary , how are we linking the dll?

Can we load the same dll from different exes at the same time?
Dec 15 '09 #1

✓ answered by Banfa

You link to a DLL statically by linking the .lib associated with the DLL into your program. The program then automatically loads the DLL at start-up, but conversely will fail to run if the DLL can not be found.

When linking to a DLL dynamically you do nothing while linking your program. Your program will always be able to run. You load the DLL by calling LoadLibrary, if the DLL can't be found this API call will fail and must be handled. You look up procedures in the DLL using GetProcAddress.


A DLL can be loaded by more than 1 program, take for example kernel.dll and user.dll which are loaded by pretty much every program.

3 5385
Banfa
9,065 Expert Mod 8TB
You link to a DLL statically by linking the .lib associated with the DLL into your program. The program then automatically loads the DLL at start-up, but conversely will fail to run if the DLL can not be found.

When linking to a DLL dynamically you do nothing while linking your program. Your program will always be able to run. You load the DLL by calling LoadLibrary, if the DLL can't be found this API call will fail and must be handled. You look up procedures in the DLL using GetProcAddress.


A DLL can be loaded by more than 1 program, take for example kernel.dll and user.dll which are loaded by pretty much every program.
Dec 15 '09 #2
weaknessforcats
9,208 Expert Mod 8TB
Get a copy of Windows via C/C++ by Jeffrey Richter. There are over 100 pages of examples on exactly how to do this.
Dec 15 '09 #3
solita
17
thanks a lot for your reply
Dec 16 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dibyendu Roy | last post by:
Hi All, I build an object called "dblorcle" to connect to oracle database in Sun solaris box. This is built linking with various oracle ".a" (archived, for static linking) files come with standard...
7
by: BekTek | last post by:
When I build boost libs, I realized that there is static link at runtime.. What does that mean? I thought static linking is done at compile time. Am I wrong?
6
by: Andrew S. Giles | last post by:
Is it possible to bring in a static library (developed in C++) into a C# project/solution? Thanks in advance for any information. Andrew S. GIles
5
by: info | last post by:
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...
1
by: srikar | last post by:
what is the difference between static linking & dynamic linking, what are the advantages of each? How to perform static linking & Dynamic linking by using gcc -o liniking will be done , but...
0
by: ardentfreaker | last post by:
Hi Banfa and Everybody, This is my first post. Well, I have a problem with a Visual Studio .NET application and was wondering if anybody could help me with figuring out the solution. I have a...
1
by: Rajeshwaran | last post by:
Hi, I have an application which uses 4 libraries.(cppunit, factory, awscomm, pthread) I need to statically link the cppunit library and dynamically link the other libraries. Is this possible?...
2
by: amarok | last post by:
I've got a problem - I must to static link to dll library, which is placed in subdirectory of application. I knonw how do it in delphi but I don't known how do it in c++ (builder). In delphi I...
6
by: gs | last post by:
Hi, I want to know that when memory get allocated to static data member of a class. class A { static int i; }
20
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.