[RESOLVED] Add header files & lib files at runtime?
Hi,
I was created a dynamic library (Used win32 App) & compiled with no error.
Then i was created my main application (MFC) & paste the .h,.lib,.dll files from the source path(dll App Path) to destination path(Main App Path).
If i used the below command in my app means the project working good.
here Alg.h contains the some methods , In future i will edit the function like below for my client requirement but no function name & Arguments change. The changes made in inside function(Logically changed) only.
My client contains only .exe file + .dll file.
My requirement,
So after change the method i will send only .dll file to my client
If i change my lib file name VTAlg2.lib instead of VTAlg1.lib (But Same Function name & Arg type)means how can i edit the code below
A header and .lib files have nothing to do with running the final executable. They only are used when building your application.
Similarly, a DLL has nothing to do when building your application -- a DLL only is used when you're running your application.
So I have no idea what you're asking. You build your application, then you install the EXE's and DLL's at the client site, and you run the app at the client's site. Your source code or lib files have absolutely no part in running the final application.
Instead of using a header file and lib file, use LoadLibrary and GetProcAddress to call your DLL function. Then you can just distribute the DLL without having to rebuild the client app.
If I change the dll name & lib name ? Header file is same.
First I'm used add.h, Alg1.lib & Alg1.dll files & prepared MyApp.exe, after changed made in logic, I'm having add.h, Alg2.lib & Alg2.dll. Now how can I run my application?
Code:
For Example - Alg1.dll logic :
int add(int a,int b)
{
return a+b;
}
In Future, I will change the logic like below, Alg2.dll - logic :
int add(int a ,int b)
{
return a+b + 100;
}
That is, I given the MyApp.exe & Alg1.dll to my client .
For avoid confusion, After changes made, I'm changed the name like Alg2.dll.
Now how can i run my application.
At this time how can I import & include the library & header files.
If I change the dll name & lib name ? Header file is same.
First I'm used add.h, Alg1.lib & Alg1.dll files & prepared MyApp.exe, after changed made in logic, I'm having add.h, Alg2.lib & Alg2.dll. Now how can I run my application?
Code:
For Example - Alg1.dll logic :
int add(int a,int b)
{
return a+b;
}
In Future, I will change the logic like below, Alg2.dll - logic :
int add(int a ,int b)
{
return a+b + 100;
}
That is, I given the MyApp.exe & Alg1.dll to my client .
For avoid confusion, After changes made, I'm changed the name like Alg2.dll.
Now how can i run my application.
At this time how can I import & include the library & header files.
I don't know of a practical way to do that. What's the point in renaming your DLL?
To run your application if you really, really want to have the version number as part of the .dll name and you want to use the latest dll version and you are using LoadLibrary then a 'kludge' is to try to use LoadLibrary with a name which has a very high version number. Assuming this fails, then try LoadLibrary with a lower version etc etc until LoadLibrary succeeds. You then have loaded the latest version of the .dll. Something like
Code:
const string dllname = "Alg";
char num[10];
int maxver = 100;
HMODULE library;
do {
string name = dllname + _ltoa(maxver, num, 10) + ".dll";
library = LoadLibrary(name.c_str());
} while (maxver-- && (library == NULL));
If I change the dll name means its very convenient for my clients to replace the old one.
How is that convenient? I now have to change my source code or whatever code I'm writing that uses the DLL to read a new name. That is not convenient, as it now puts my own code at risk because of the changes that I would need to make.
You shouldn't be changing the name of the DLL. What you should be doing is ensuring that the current version of the DLL that is "good" is the one being loaded. And you do that by telling your clients "I have a later version of the DLL. Make sure you are loading version xxx.xxx of the DLL". Programmers who know how to use DLL's are perfectly capable of loading the correct version at runtime if you tell them that a later version is available.
I declare my function like DataProcess(int **InData, int width, int height, int **OutData);
I did some logic using algorithm for some calculation using **InData 2D Array.
In future, I found one more best algorithm means, just i will replace the logic using the 2D( **InData) array.
For this I will get the best result in my application.
If I change the dll name means its very convenient for my clients to replace the old one.
Also, gives a hint to find the logic to me.
I don't see how that's more convenient and it seems like a design flaw to me. I'd rethink your approach rather than chasing something that doesn't make sense. Other app builders don't do it that way, and there's a reason for it.
If I change the dll name & lib name ? Header file is same.
First I'm used add.h, Alg1.lib & Alg1.dll files & prepared MyApp.exe, after changed made in logic, I'm having add.h, Alg2.lib & Alg2.dll. Now how can I run my application?
I cannot see anything here to doubt about. If you change .lib file, you have no option other than full rebuild of your .exe and .dll. The new .exe will know the new name of .dll by linking to the proper .lib. No matter what the name of header or lib was.
It one of my project requirement. Then How can i say no possible?
But I'm not hot code the DLL Name In My project.
Just Browse the dll from particular location & save the path in to a string then only i will load the DLL at run time.
Originally Posted by GCDEF
I don't see how that's more convenient and it seems like a design flaw to me.
I'm sure, Myself only didn't clear you correctly.
Originally Posted by Igor Vartanov
If you change .lib file, you have no option other than full rebuild of your .exe and .dll. The new .exe will know the new name of .dll by linking to the proper .lib.
But I just copied the 1st version of dll & lib files in to my main project header files location & then Build the mainapp.exe
Here by i prepared sample .exe & .dll for your reference.
Kindly find the attachment.
I attached DLLExport.dll, DLLAlg1.dll & VTMain.exe.
First load any dll using browse button & Click the CALC Button.
The result will be display in message box.
For example only i add 25 +45 = 70 & 25 + 75 + 100 = 170.
Just Browse the dll from particular location & save the path in to a string then only i will load the DLL at run time.
I'm sure, Myself only didn't clear you correctly.
But I just copied the 1st version of dll & lib files in to my main project header files location & then Build the mainapp.exe
When loading DLL explicitly at runtime, you never need LIB file at compile time. So all your talks about LIB were definitely misguiding. If you want to get some real help, you have to learn explaining your problem clear, concise and unambiguously.
As for the archives you uploaded, I never experiment with binaries which origins I'm uncertain of.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.