943,685 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 3241
  • C++ RSS
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Dec 21st, 2007
0

Re: DLL and Application

Hi,
when i ->include linking as
errors


Circular Untitled2 <- Untitled2.o dependency dropped.

Circular Untitled2 <- Untitled2.o dependency dropped.


When i turn off linking i get 3 more files ,
.dll, .lib, .a
And when i use my WIN API file who is some were above.Get no errors.BUT i did not see message box ,and it was ON included linking.
Last edited by kv79; Dec 21st, 2007 at 3:25 pm. Reason: And "Makefile "
Reputation Points: 30
Solved Threads: 7
Posting Whiz in Training
kv79 is offline Offline
292 posts
since Nov 2007
Dec 21st, 2007
0

Re: DLL and Application

Click to Expand / Collapse  Quote originally posted by elite1986 ...
Hi,
when i ->include linking as
errors


Circular Untitled2 <- Untitled2.o dependency dropped.

Circular Untitled2 <- Untitled2.o dependency dropped.


When i turn off linking i get 3 more files ,
.dll, .lib, .a
And when i use my WIN API file who is some were above.Get no errors.BUT i did not see message box ,and it was ON included linking.
Well I could not understand the errors. I don't know how do you add lib refreence in dev++. however you can use

#pragma comment(lib, "myfile.lib") in your cpp. It will autometicallty link the lib. After that you need not call the LoadLibrary. Just declare the prototype of function and call the function.
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
Dec 21st, 2007
0

Re: DLL and Application

Did you tried the impliementation I suggested earlier ? What is the error code ?
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
Dec 21st, 2007
0

Re: DLL and Application

Hi,
C++ Syntax (Toggle Plain Text)
  1.  
  2. #include <windows.h>
  3. #pragma comment(lib, "myfile.lib")
  4. typedef void (*function1_ptr) ();
  5. function1_ptr function1=NULL;//Now create pointer and set its default value to NULL
  6.  
  7.  
  8. int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
  9.  
  10. HMODULE myDll = LoadLibrary("myfile.dll");
  11.  
  12. if(myDll) {
  13. //obtain the function address
  14. function1 = (function1_ptr)GetProcAddress(myDll,"function1");
  15. }
  16.  
  17. //use function where needed, but check before
  18. if(function1)
  19. function1();
  20.  
  21. //finally free library
  22. FreeLibrary(myDll);
  23.  
  24.  
  25. return 0;
  26. }
Had no errors and i have not seen message box
Last edited by kv79; Dec 21st, 2007 at 8:23 pm.
Reputation Points: 30
Solved Threads: 7
Posting Whiz in Training
kv79 is offline Offline
292 posts
since Nov 2007
Dec 21st, 2007
0

Re: DLL and Application

I am now really confused ,
Were to go to understand these dll,
When i seen MSDN i understud 2 types but when i seen code it is really confusing.
Reputation Points: 30
Solved Threads: 7
Posting Whiz in Training
kv79 is offline Offline
292 posts
since Nov 2007
Dec 22nd, 2007
0

Re: DLL and Application

Hi,
I am really sorry it is my mistake.
It is working ,i get a message only when i put a
dll in same directory where is my exe and correct the names of .dll look up there code.

Thank you all for your effort for trying help me but basicly i needed to help my self.

But one or two more question 's what i do not understand.
1)When i writeing program in other language can i use dll or not?
2)It is his mistake or MSND

http://www.apitalk.com/document.php?id=1184209001_1
http://support.microsoft.com/kb/815065

Because he call this EXPLICITE and but msdn not.
3)MSND call load-time dyna... EXPLICIT
is it mind that run-time dyna... IMPLICIT?
4)When i use load-time is it mind when i load first time i do not need anymore dll?
5)Can i use any windows XP dll's?
6)What i need to do to attach another dll with this one?Do i need any other knowlage?
7)
if(function1)
function1();
Why the program won't work right without this ?
8)How to create different moduls in point of
runing faster programs.OR separate moduls.
9)I downloaded Visual C++ 2005 Expres Edition ,why i can't make a project ,what to do reslove that?
Last edited by kv79; Dec 22nd, 2007 at 1:16 pm.
Reputation Points: 30
Solved Threads: 7
Posting Whiz in Training
kv79 is offline Offline
292 posts
since Nov 2007
Dec 22nd, 2007
0

Re: DLL and Application

>>I downloaded Visual C++ 2005 Expres Edition ,why i can't make a project ,what to do reslove that?

To create a project: select menu File -->New -->Project, then set Project Type to Win32 and Visual Studio Installed Templates to Win32 Console Application. At the bottom of the screen enter the project name and select the desired location. Finally on that window press the Ok button.

The next window to appear is the Application Settings window. Select Console Application and press the Finish button.

All done.
Last edited by Ancient Dragon; Dec 22nd, 2007 at 7:12 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,950 posts
since Aug 2005
Dec 22nd, 2007
0

Re: DLL and Application

It's working but only when i put
in additional option ,empty project.
Reputation Points: 30
Solved Threads: 7
Posting Whiz in Training
kv79 is offline Offline
292 posts
since Nov 2007
Dec 22nd, 2007
0

Re: DLL and Application

1)When i writeing program in other language can i use dll or not?
Yes, you can use a DLL in any language. The trick is only to match the correct "calling convention". Google it and read more about it. Most Windows DLLs have "stdcall" calling convention.

2)It is his mistake or MSND ... Because he call this EXPLICITE and but msdn not.
Both are correct. The difference between explicit and implicit linking is just whether or not the compiler links for you. For example, when writing windows programs, if you include <windows.h> then you can use all kinds of functions found in Windows DLLs without having to explicitly say which DLLs you want to use.

3)MSND call load-time dyna... EXPLICIT is it mind that run-time dyna... IMPLICIT?
This is non-sequitur. If you use LoadLibrary() then that is run-time loading. Otherwise it is load-time loading. This is a fairly simple, but technical issue. You shouldn't need worry about it.

The main interest for the programmer is that if a load-time DLL is not found, your program will not run. However, a run-time DLL (loaded with LoadLibrary()) allows you to choose whether to continue execution or not.

4)When i use load-time is it mind when i load first time i do not need anymore dll?
I don't understand your question.

5)Can i use any windows XP dll's?
Sure, why not?

6)What i need to do to attach another dll with this one?Do i need any other knowlage?
DLLs are separate things. One DLL may use another DLL, just as your EXE may use a DLL, but they are still separate, self-contained things.

7)
if(function1)
function1();
Why the program won't work right without this ?

It is possible that the DLL you loaded doesn't have the requested function. You must check to make sure that the function exists before you use it.

Keep in mind that you are really using a C shortcut here. "function1" is a pointer to a function. So first you test to see if the pointer is not NULL, and if not, then you call the function. To be absolutely explicitly correct it should read:
if (function1 != NULL) (*function1)();
C and C++ are nice and let you write it a shorter way:
if (function1) function1();

8)How to create different moduls in point of runing faster programs.OR separate moduls.
It makes no difference. (That is, if I understand your question correctly.)

Good luck!
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Dec 22nd, 2007
0

Re: DLL and Application

Thank you all of you for makeing something clear.
Last edited by kv79; Dec 22nd, 2007 at 7:52 pm.
Reputation Points: 30
Solved Threads: 7
Posting Whiz in Training
kv79 is offline Offline
292 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help reading/writing to text files...
Next Thread in C++ Forum Timeline: Read a text file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC