|
Being a begginer, I have many problems...
Consider this situation
Suppose I am building a usefull library. One way is that I distribute it along with all the source and all the header files.... Right? Client programer will include the main header and will start using the functionality present in the library.
Other scenario, what if I only give him the header files along with lib files? How I can do that? Means what compiler options I will have to set? (Assuming I am using VC.NET 2003)
Lastly, I present here a realife example that somewhat confused me... Its the FreeType Library which is a true type rasterizer. http://www.freetype.org
There are two distributions, one is the source of the library, and the other is library in usable form.
I set my include paths as indicated by the documentation of FreeType. When I compile, I get "Uresovled symbols in function _tmain()". Ok, I figure out that either I have to provide the linker with the .lib file. Ok, I do so... All very well... Program complies and executes but terminates... It says "Cannot load library freetype6.dll".
At the next step I find the .dll library and place it in the current directory of the program. Now I compile, and execute... all very well... Program is running...
My question is that when I provided it with .lib file, FreeType library should be statically linked to my program why it requires the .dll to be accessible for the EXE?
Please explain me what are .obj and .lib and .dll files are and what is there relation to each other and how they fit togather?
Morevoer, if there is any article, book or tutorial on these issues, please let me know...
If anything seems to you stupid, please dont mind as I am a begginer...
Best regards,
Mohsin Hijazee
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
Polite Programmer wrote: My question is that when I provided it with .lib file, FreeType library should be statically linked to my program why it requires the .dll to be accessible for the EXE?
No, this is not entirely true. The lib files doesn't not contain the code of the library but rather the 'prototypes' of the functions from the dll. So, you need to link with it in order to know wich are the functions from your dll. Then, of course you need to have your dll in your working folder in order to load the functions at run-time. You don't need the lib file only if you load explicitely the functions from the dll (using LoadLibrary and GetProcAddress).
Of course, you can also have lib files which contain code (so, that are not associated with a dll).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
One more major difference is .lib file comes into picture at Compile time.
Where as .dll comes into picture at Run Time.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
It implies that if I create a DLL, I will get a .LIB file for free? Any details or any article addressing these issues please?
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
Hi,
I have a function that is declared as follows:
void func(int A, int B, int C, int D=-1, int E=-1);
arguments D and E are optional, and so if the function is called like this:
func(A,B,C); then D and E recieve the value -1.
What I want to do is add another optional argument, let's say int F that will also receive -1 as default, for example.
The problem is that sometimes I want to call the function only with the parameters A,B,C and F. If I declare the function like this:
void func(int A, int B, int C, int D=-1, int E=-1, F);
will I be able to call the function in this manner:
func(A,B,C,,,F); ?
|
|
|
|
|
SWDevil wrote: void func(int A, int B, int C, int D=-1, int E=-1, F);
will I be able to call the function in this manner:
func(A,B,C,,,F); ?
No.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
SWDevil wrote: void func(int A, int B, int C, int D=-1, int E=-1, F);
forget about calling the funtion, C++ won't allow to declare the funtion like this.
If you declare an argumnet with default value then all the arguments after that should have default value .
Regards
Anil
|
|
|
|
|
oops - my mistake...
I meant to declare the function:
void func(int A, int B, int C, int D=-1, int E=-1, F=-1);
but if I declare it this way, will I be able to call the func without specifying the parameters D and E?
|
|
|
|
|
Nope. You have to provide the arguments in the same order. Whenever you supply a value for an optional parameter, it will be used for the first optional parameter.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
SWDevil wrote: but if I declare it this way, will I be able to call the func without specifying the parameters D and E?
Well if you are desperate to get it working take a look at va_arg , va_list , va_start , va_end . It's an option.
Owner drawn
Jesus Loves
|
|
|
|
|
Owner drawn wrote:
Well if you are desperate to get it working take a look at va_arg, va_list, va_start, va_end. It's an option.
Well Back after long time
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Where are you buddy? These days you are not posting messages to the board.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: Where are you buddy? These days you are not posting messages to the board.
Hmm.. I was away for quite a while but now alive and kicking.
Owner drawn
Jesus Loves
|
|
|
|
|
No you can't
What you want is calling the function
void func(int A, int B, int C, int D=-1, int E=-1, F=-1);
in func(A,B,C,,,F);
Suppose( which will never happen)if you succeed, you will get D and E as -1.
So you can call
func(A, B, C, -1, -1, F); :-)
Regards
Anil
|
|
|
|
|
why not putting the F parameter between C and D ?
void foo(int A, int B, int C, int F = -1, int D = -1, int E = -1) {
}
so that you can use it like this :
int A, B, C, D, E, F;
foo(A, B, C);
foo(A, B, C, F);
foo(A, B, C, F, D);
foo(A, B, C, F, D, E);
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
But I also sometimes want to call the function without the F parameter (and with the D and E parameters)...
|
|
|
|
|
|
SWDevil wrote: ut I also sometimes want to call the function without the F parameter (and with the D and E parameters)..
What about using Variable Argument System!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
the simples solution is to provide a wrapper macro for your function
void func(int A, int B, int C, int D=-1, int E=-1, int F=-1);
#define FUNC(a_, b_, c_, f_) func(a_, b_, c_, -1, -1, f_)
This way you can simply call it through the macro in those rare occasions where only the F should be given.
void Call()
{
int A, B, C, D, E, F;
func(A, B, C);
func(A, B, C, D, E, F);
FUNC(A, B, C, F);
}
codito ergo sum
|
|
|
|
|
I have an Edit Control created using WINAPI in a COM component which is called by an Outlook Addin. Now whenever I want to retrieve the text on the Edit Control using GetWindowText , I don't get anything? Also, when I try to use SendMessage using WM_GETTEXT , I get an Unhandled Exception in Outlook.EXE(USER32.dll) 0xC0000005:Access Violation error. Can anyone explain why this happens?
SetWindowText works fine and so does the other APIs. The Edit Control is not a multiline Edit Control.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
-- modified at 2:19 Wednesday 31st May, 2006
|
|
|
|
|
Are you sending the WM_GETTEXT message between processes?
Steve
|
|
|
|
|
Stephen Hewitt wrote: Are you sending the WM_GETTEXT message between processes?
Nope. I have created the Edit Control in the COM component which runs under the same process as outlook does. A peculiar behavior is that, when the Edit control has focus and I press the Backspace key, the Backspace key gets transferred to Outlook and it is outlook that reacts to the Edit key, not the Edit control. Can you explain this peculiar behavior or the scenarios when this happens?
Thanks for replying.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Stephen Hewitt wrote: Are you sending the WM_GETTEXT message between processes?
Usually People use this Message to reterive text from other UI
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Yeah, but the scenario I enquired about could explain the crash which is why I asked: the address in LPARAM is only valid within the sending process.
Steve
|
|
|
|
|
I think, u r trying 2 use a pointer with out allocating it.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|