|
Hello all,
Could anyone explain how to link a library statically into an executable in Visual C++ .NET?
My problem is that I'm compiling against library (.lib) files, but I do not have the corresponding (.dll) files. The compilation works fine, but when I attempt to run the application, it falls over as it is not able to find the .dll. It is my understanding that if I statically link the required parts from the .lib files into the executable, it will have everything it needs at run-time and will not go off looking for the .dll. I've looked around the compiler and linker settings within Visual C++ and haven't been able to find anything to make me happy. Googling hasn't produced anything either. Could someone suggest a solution?
Cheers,
Penkov
|
|
|
|
|
|
Thank you for your reply. The options you suggested seem to apply only to the standard C run-time libraries which are provided by MS. My problem is that I need to statically link to my own libraries. I've tried playing around with the /link option, but I have not had any luck with it. Do you have any other suggestions? Thanks in advance.
Penkov
|
|
|
|
|
|
A static library .lib file is not the same as a .lib file used to link to a dll.
The static lib .lib file has all the compiled code.
The dll .lib file only has the export information for the dll.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thank you for your reply.
cmk wrote: A static library .lib file is not the same as a .lib file used to link to a dll.
I was under the impression that they are all static libraries... Could you please elaborate? How do I distinguish between one type of .lib file and another?
I haven't done much Windows C++ development (up until now only had to work on Linux). If you could point me in the direction where I can read a bit more about this, it would be great.
Thanks again,
Penkov
|
|
|
|
|
misha1983 wrote: I was under the impression that they are all static libraries... Could you please elaborate? How do I distinguish between one type of .lib file and another?
No, they are not all static libraries.
As i mentioned, you get different .lib files from building a project as a static lib vs a dll.
There is no obvious way to distinguish, you are usually told when you get the file(s).
If you know more about what to expect in these files then you can use a hex editor to look at their contents and tell from that, but explaining that is too involved.
You are usually either given a x.lib and told 'this is a static lib build of our x API', or you are given a x.lib, x.exp and x.dll and told 'here is our x API dll'.
Actually there is a 3rd option, you are given a x.lib, x.exp and x.exe and told 'here is our application, which exports our y API'.
Search MSDN for information on lib, e.g.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_running_lib.asp[^]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Ok, thanks, that's cleared it up a bit. I've asked around work and managed to dig up the DLLs I needed. So that's taken care of. Thanks to both of you for helping.
Cheers,
Penkov
|
|
|
|
|
I have an Industrial PC with an Embedded Windows XP.
The Embedded Windows XP can only boot up and display a cmd.
I need to control its Digital I/O. I only have the I/O address and Interrupt of it.
At this moment, I am not sure that it has driver or not.
Can any one give any suggestion to me?
Please help!
|
|
|
|
|
If it can only boot up to a prompt then it sounds like the kernel has been built from a reduced sub-system set - sucks for you, sorry.
You would have to look-up any shell commands to query the device sub-system for an appropriate driver, if none exists then you'd have to write one.
I'm suprised you haven't been given an API for the device, or at least told more about the system, makes it tough to help.
The MSDN embedded site has some info on writing device drivers if i remember right:
http://www.microsoft.com/windows/embedded/default.mspx[^]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
In fact that the system don't have any API.
The system is given by other company.
So I have no idea in such situation.
Please help!
|
|
|
|
|
Is it possible to define a class member variable to be read only and also being public? Thx!
|
|
|
|
|
|
That is not what i meant!
I want to know how can I declare a variable as readonly to instances outside the class. For instance:
class X {
int var;
int func( void ) {
var = 12; // Legal
}
};
int main( void )
{
X asd;
asd.var = 12; // illegal
}
To this i would also like to add the fact that this class is supposed to be a base class so, var will maintain its properties on all the derived classes. For instance:
class Y : public X {
int func2( void ) {
X = 12; // Legal!
}
}
Thx!!
hint_54
|
|
|
|
|
The standard way to do something like this in C++ is to make the variable private, add a public method to get it and a protected method to set it. In this way, the class itself and derived classes can modify the value, while it remains visible but unchangeable externally.
|
|
|
|
|
Yes, that I know. I was trying to find some other way without having to use function calls. But I think that is not possible under c++... but thx anyway!
|
|
|
|
|
Hi All,
I'm working on an SDI application that has a CEditView as one of it's views. While I can use the default printing to print the document, things like the margins, the font etc. need to be set. I would like some details about how to do this.
Thanks!
Mark
"Nothing is impossible. Remember once upon a time the world was flat."
|
|
|
|
|
Hi,
Check this[^]
Bye
Cool Ju
Vote for Cool Ju
|
|
|
|
|
No disrespect intended but the linked article does little to help me understand the document view printing process. The code has almost no comments so I don't know what I'm looking at. Looks like a lot of extra work on specialized printing classes.
Thanks anyway,
Mark
|
|
|
|
|
I am using Visual C++ 6.0 MFC Document/View. I need to convert my logical units to pixals. In my myCView's OnDraw(pDC) function I am calling a myCDocument function pDoc->DisplayMyStuff(pDC) which in turn calls the function DisplayMapSetup(pDC, WaferRect). In the DisplayMyStuff(pDC) function I define a CRect to be WaferRect. I then can get the height = myCRect.Height() in logical units but I want them in pixels. If after I define WaferRect, I call pDC->LPtoDP(WaferRect) before calling WaferRect.Height() I still get the height in logical units. I have also tried pDC->LPtoDP(&WaferRect) and several different mapping modes. Here's a little snippet.
void CWaferMapDoc::DisplayMapSetup(CDC* pDC, CRect WaferRect)
{
pDC->LPtoDP(&WaferRect);
int height = WaferRect.Height();
Is there something I am missing in order to convert the logical unitis to pixels?
Thanks,
Buck
|
|
|
|
|
Hi,
What mapping mode are you using and the settings of the origins and extents for the window and viewport? Bcoz LPToDP and DPToLP depend on these settings.
If u r using MM_TEXT mapping mode, then the logical unit is equal to device unit. 1 unit = 1 pixel.
Bye
Cool Ju
Vote for Ju
|
|
|
|
|
Thanks Ju,
I think I know what's going on now. I use a map mode of MM_ANISOTROPIC in my zoom class but otherwise I don't set it (defaulting to MM_TEXT). I'm defining my document size to be CSize(1100, 850) to represent an 8.5 inch by 11 inch page size but I don't set the map mode to MM_LOENGLISH. My brain was thinking 8.5 x 11 inches when in reality it was 1100 x 850 pixels. This would explain it.
Buck
|
|
|
|
|
Hi all,
I am looking for a small sample of code that saves bitmap after getting it from DC.
Can anyone help?
Thanks,
Max
Sincerely,
Max Pastchenko
|
|
|
|
|
Your best bet is to use GDI+ in your application, then you can save as jpg, etc.
I have a number of articles on GDI+ here on CP.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Consider the following:
class A
{
recipient;
queue;
};
class B
{
recipient;
queue;
text;
from;
};
A a;
B b;
if (some_condition)
modify a.recipient, a.queue;
else
modify b.recipient, b.queue, b.text, b.from;
...
if (some_condition)
modify a.recipient, a.queue;
else
modify b.recipient, b.queue, b.text, b.from; This code that modifies the various members is repeated dozens of times. I would like to somehow instantiate just one of either A or B so that the code that modifies the common member variables can do so without having to use a runtime condition. Something like:
modify b.recipient, b.queue;
if (some_condition)
modify b.text, b.from; I thought that I could put the common member variables into a base class and derive A and B from that, but nothing I tried would satisy the compiler. Modify the member variables through the base class and it would complain about text and from . Modify the member variables through the derived class and it would complain about recipient and queue .
One or other of the two classes will eventually be sent to another computer. That computer is expecting data of a certain size. In other words, I can't operate on B if the other computer is expecting A and vice versa.
Thanks,
DC
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|