|
1) My answer was intended as an extension to yours.
2) From the article I linked:
Potential Pitfalls:
...
4) Duplicate instances of objects within the code that compiled fine. This is a linking error, often difficult to understand. (In MSVC, you might see something like "error LNK2005: "int myGlobal" (?myGlobal@@3HA) already defined in myotherfile.obj".)
...
If you read the article properly (or at all, if you didn't already) then you will see that this was a perfectly good suggestion.
|
|
|
|
|
get this error when trying to compile my code(C/VC++) in visual studio 2005
error LNK2001: unresolved external symbol ""public: virtual bool __thiscall CxMemFile::Close(void)" (?Close@CxMemFile@@UAE_NXZ)".
Any help to resolve this error will be appreciated
Susanne
|
|
|
|
|
Hi, you should use a meaningful title for your post (see forum guidelines)
susanne1 wrote: get this error when trying to compile my code(C/VC++) in visual studio 2005
error LNK2001: unresolved external symbol ""public: virtual bool __thiscall CxMemFile::Close(void)" (?Close@CxMemFile@@UAE_NXZ)".
Any help to resolve this error will be appreciated
Add cximage.lib to the list of Linker input files.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
using C++ (and MFC) I would like to develop an application that is able to create *.exe executable files. (An example for that would be e.g. creating a self extracting executable zip file.)
Has anyone an idea how to proceed? Are there any examples or articles about that problem in the code project or elsewhere? (I did not find anything )
Thanks.
Joe
|
|
|
|
|
It's not all that hard to use CreateFile to make a file that just happens to end in exe, the hard bit is where is the file's contents going to come from?
You could save an exe as a binary resource in your starter app, then simply save it out.
If you search for FILE_FLAG_DELETE_ON_CLOSE on msdn you should find some articles on exe's that even tidy up after themselves when they finish executing.
(I'm assuming you're not writing a compiler).
Iain.
|
|
|
|
|
To create an executable you need a set of tools, traditionally (for C based languages) a compiler to turn your chosen language into the machine language or assembly language of the target, a linker to link together compilation modules and possibly an assembler to turn the targets assembly language into its machine language. All of these can be written using C++ (and MFC although it won't be that much use outside the GUI). In fact MSVC is written using the previous version of MSVC. To write a compiler from scratch you're going to need to know a lot of things, LALR1 grammar/parser theory to start with and potentially a lot of arcane stuff about branch prediction and tree based optimisation. If you're up for all this you could start with Yac & Lex ( or Bison & Flex on Windows ) as example code for generating a language parser. You could download and examine the sources of projects like GCC ( GNU Compiler Collection ) and doxygen ( a C++ etc documentation engine ). Many people have trodden this path before you so there's a lot of rubble to examine. Most either end up writing their own assembler, developing a scripting language Perl, Python, etc, etc or much for usually just use an existing tool to achieve your specification. You could for example adapt one of the GCC compilers to your own use/lanaguage and build it into your product ( You'll have to contribute your changes back to the community of course )
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Member 191829 wrote: An example for that would be e.g. creating a self extracting executable zip file
If you are looking to create a self extracting archive executable, then have a look at the LZMA sdk[^].
If you want to be able to generally create executables, Matthew Faithfull's reply is excellent!
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Member 191829 wrote: ...create *.exe executable files.
Based on what?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Based on an existing *.exe file, where only resources (e.g. included bitmap resources, icons,...) should be changed.
|
|
|
|
|
You could consider using one or more resource only DLLs instead of using the resources in the exe itself. If the exe is your own code then modifying it to load an external resource dll and use those resources instead should not be too much work. If it isn't then you arguably shouldn't be messing with it in the first place. If you must then there are tools available to rip and replace the resources out of a PE ( Microsoft's Portable Executable format ) binary. Google or Dogpile would be good places to start looking. If you're going to do this then watch out for subtle, or even custom, bitmap formats and other tweaks which the executables code might rely on to render things right. Initially I'd keep everything the same size, i.e. same size bitmaps and same number of bytes in each resource wherever you can.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
I have a CListCtrl control and a child dialog on the parent dialog. When I click on an item in the list, I display the detials of the selcted item in the child dialog.
Now I would like to do the same when I press arrow and page down/up keys.
I'm currently using LVN_KEYDOWN message. The problem is that when I go from item no 0 to item no 1, the selected index change is not seen by the LVN_KEYDOWN (so in the message handler, the selected item will be 0 instead of 1).
One thing more My CListCtrl control is also getting updated after every 8 seconds and by default one item is always selected that is why I am not able to use LVN_ITEMCHANGED.
Please tell me how to achieve this.
Thanks In advance.
modified on Tuesday, September 16, 2008 7:58 AM
|
|
|
|
|
You should be able to use LVN_ITEMCHANGED . It should not matter that the control is being automatically updated.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
I have a CArray of structs that I want to be able to sort.
Ie:
struct _Blah_
{
CString Name;
CSomeOtherStruct other;
DWORD dwSomething;
};
CArray<_Blah_, _Blah_&> BlahArray;
The C libs come with a sort command that takes a compare function, but that does binary swaps. That may be fine for very basic structs in a CArray, but not if it is a class with virtual methods, etc.
I could write a sort function for my particular array / class combo, but I'm sure there's a more elegant way of doing this...
Feel free to give me pointers to some vector::sort library or such... I'm a novice in that area!
Thanks,
Iain.
|
|
|
|
|
Iain Clarke wrote:
I could write a sort function for my particular array / class combo, but I'm sure there's a more elegant way of doing this...
Feel free to give me pointers to some vector::sort library or such... I'm a novice in that area!
I dont normaly use CArray, but with std::vector, having your vectored classes have an operator<</code> and <code>operator!= would be enough.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks - looks more elegant then writing my own predicate!
Iain.
|
|
|
|
|
If its just about the predicates, I also like boost.orgs lambda-lib[^]
With it, you can write the predicate exactly where you need it, not somewhere else.
Comes in handy when your classes do not have the one, inherent order, but instead need to be sorted by varying criteria.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Just added a comparison, and it works a treat, thanks!
Iain.
struct NamedPos
{
CString Name;
... other member data here
bool operator < (NamedPos const &p) const;
}
bool NamedPos::operator < (NamedPos const &p) const
{
return (Name.Compare (p.Name) < 0);
}
...
NamedPos p;
p.Name = "1";
m_NamedPositions.push_back (p);
p.Name = "3";
m_NamedPositions.push_back (p);
p.Name = "2";
m_NamedPositions.push_back (p);
p.Name = "5";
m_NamedPositions.push_back (p);
p.Name = "4";
m_NamedPositions.push_back (p);
std::sort (m_NamedPositions.begin(), m_NamedPositions.end ());
|
|
|
|
|
Iain Clarke wrote: it works a treat
Great!
Actually, operator overloading is a good thing!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Iain Clarke wrote: Feel free to give me pointers to some vector::sort library or such...
I don't know what you are looking for exactly but the STL does have sorting algorithms. You can have a look here[^] (don't look at how he is inheriting from std::vector, because, in my opinion, it is not really the way to do).
The function swap two items, meaning that it uses the assignement operator and the copy constructor (not sure about this one). You could override this operator for your structure if you want to make it more efficient (if possible). I don't really see how you could sort, without swapping items anyway...
Does that more or less answer your question ?
|
|
|
|
|
Cedric Moonen wrote: Does that more or less answer your question ?
Yes thanks - the prevailing winds are blowing in STL's direction. I'll try jwurmbach's idea of providing comparison operator's in my own struct first - seems like less heavy lifting.
Iain.
|
|
|
|
|
|
Thanks for that. Interesting article.
STL's vector and sort are looking more elegant, but I've used a lot of CArray's over the years...
Decisions... decisions!
Iain.
|
|
|
|
|
The 'cheat' I generally use for this is a bit of a zen solution. I don't sort the array at all
Instead I keep a parallel array of simple unsigned integers and I sort that and use it as an index into my array of complex objects. I use the standard sort algorithums but my comparator functions, instead of just comparing integers uses them to look up the real array and returns a comparison result dependent on what it finds there.
If you dig around in the source of my constructional patterns article [^] you'll find an indexed list class, possibly even templated so you use it with your data structures.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
"The best way to sort is to not sort at all".
Very wax-on, wax-off...
My structures are not highly horrible to swap about, luckily, but I can see your method being very useful if copying is an expensive or impossible process (ie, open DB handles are a classic baddie).
As you normally give good answers, I assume your articles are worth a peek too...
Iain.
|
|
|
|