Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1206
  • Last Modified:

Static Linking instead of using dll

My MFC application  currently links dynamically to a "dll file", which I have to provide when i ship the software. The dll is a MFC dll project.

I am trying to convert the MFC Application to do a STATIC linking process instead of Dynamic Linking (with the dll or a lib file)  

Is the "Implicit Linkng" option similar to the static link option ? I am getting confused between the implicit and explicit linking methods used in Visual Studio for linking MFC projects...
http://msdn2.microsoft.com/en-us/library/253b8k2c.aspx

What is the best way to proceed in order to perform a static link when i have MFC dll and a MFC executable.

Thanks
0
hari4130
Asked:
hari4130
  • 2
1 Solution
 
mahesh1402Commented:
>>I am getting confused between the implicit and explicit linking methods used in Visual Studio for linking MFC projects...

In Implicit linking you link in a very small lib file that contains little more than a jump table, and at run the time OS loads the DLL and fills in the jump addresses. but if the DLL is not found your program doesn't run.

Explicit linking is awkward but gives you flexible control.  You have to load the DLL yourself (LoadLibrary) and get and use function pointers to the functions you wish to call (GetProcAddress).  But your program can run without the DLL, you can select which DLL to load at run time and you can select when and if the DLL is loaded.  It is a primitive form of a "plug-in" option.

In static linking, the linker gets all the referenced functions from the static link library and places it with your code into your executable. Using DLLs instead of static link libraries makes the size of the executable file smaller. Dynamic linking is faster than static linking. but in static mfc linking you don't have to redistribute mfc*.dll etc with program.

If you statically link to the MFC code library, your .DLL will incorporate within itself all the MFC code it needs. Thus, it will be a larger .DLL, but it won't be dependent on the client computer having the proper MFC code library .DLL. If you can't rely on the host computer having the right version of MFC available, this is the way to go. If your application users are all within your own company, and you have control over what versions of the MFC .DLLs are lurking on their computers, or if your installation program also loads the right MFC .DLL, this might not be an issue.

http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c4017/
http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c4019/

-MAHESH
0
 
mahesh1402Commented:
>>What is the best way to proceed in order to perform a static link when i have MFC dll and a MFC executable.

Creating Static-linked Executables using VC++ :http://www.codeproject.com/dll/staticlink.asp <====

-MAHESH
0
 
bastibartelCommented:
Hi there,

If I understand your question right, you would like to link statically to some library (DLL) that you currently have to ship along.
That is not possible, unless you can rebuild that library, i.e. have te source code at hand.
If you do, you must turn the DLL project into a static library project - ask along if that is an option for you.

The 'link statically/dynamically' option in DevStudio refers to the actual MFC libraries only, that is to the parts that represent MFC functionality.
It has nothing to do with other libraries, may they be your own or third party, and may they be using MFC or not.

The only concern of yours will be, that programs that are linked to MFC dynamically will usually not work with DLL's linked statically to MFC (and vice versa)
But that is currently not your problem I suppose.

Cheers,
Sebastian


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now