Resolving CVT1100

by Codewiz51 January 08, 2012 09:19

If you work with message files in your C++ project, you may have encountered the following error:

CVTRES : fatal error CVT1100: duplicate resource -- type:MESSAGETABLE, name:1, language:0x0409
fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

I wrestled with this error recently, and for nearly 12 hours, it drove me crazy.  There is a lot of speculation on the internet regarding this error, with lots of "try this or that"

Here is a concrete solution to my problem:

  • I had included the message.rc file in my C++ project, along with the project's .rc file.
  • The message.rc file is also listed as an included resource in the project's .rc file.
  • Solution: Remove the message.rc file from your project, but leave it as an included resource in your project's .rc file.
  • Reason: The resource compiler dutifully includes the message.rc.  The linker then dutifully tries to link in the compiled message.res file included in the project; ergo, duplicate resource!
  • If you are going to include the message.rc as a resource in another .rc file, then you should not add message.rc to your solution.

Put this down as a hard lesson learned.  How hope my experience aids another developer.

Scott Meyer's C++11 Presentation Materials

by Codewiz51 December 10, 2011 06:02

I wish I worked some place that though attending this conference was important.  This is well worth the $30 bucks to download the material (in my opinion.)

http://www.artima.com/shop/overview_of_the_new_cpp

 

 

So, you think you know C++?

by Codewiz51 December 10, 2011 05:55

Check out Herb Sutter's site.  He's doing his part to ask the hard questions.

GotW #102: Exception-Safe Function Calls (Difficulty: 7/10)

 

Sorting an XML file

by Codewiz51 November 09, 2011 11:22

I needed to sort an xml file based on an attribute rather than a tag value.  This proved to be a little more subtle problem than I first imagined.  I've worked up a simple example of what is required to sort an xml file on an attribute value:

// FYI, there is a build event that copies the item dictionary to the correct
// directory.  If you get a run time error because the dictionary is missing,
// you need to check the output of the build event.

using System;
using System.Xml;
using System.Xml.XPath;

namespace XMLSort
{
    class Program
    {
        static void Main(string [ ] args)
        {
            // Create an xml doc instance and load the item dictionary

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(@"ItemDictionary.xml");

            // Creeat the sorted document place holder

            XmlDocument xmlSortedDoc = new XmlDocument();

            // Copy the dictionary structure by loading the outer xml from doc

            xmlSortedDoc.LoadXml(xmlDoc.OuterXml);

            // remove the unsorted nodes

            xmlSortedDoc.SelectSingleNode("//items").RemoveAll();

            // Select the items node

            XmlNode node = xmlDoc.SelectSingleNode("//items");

            // Create an xpath navigator object

            XPathNavigator navigator = node.CreateNavigator();

            // Now the fun begins.  We want to navigate the item nodes.
            // There are four nodes in the itemdictionary.xml file.

            XPathExpression selectExpression = navigator.Compile("item");

            // Finally!  We get to define the sort conditions.
            // In this case, I want to sort on the name attribute of the item tag.

            selectExpression.AddSort("@name", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text);

            // We need to create an iterator to loop through the nodes.
            // This allows us to create the inner xml item elements for
            // the sorted document

            XPathNodeIterator nodeIterator = navigator.Select(selectExpression);

            // Loop through the iterator, adding the nodes to the sorted document

            while ( nodeIterator.MoveNext() )
            {
                // Clone the iterator so we do not lose position

                XPathNavigator clone = nodeIterator.Current.Clone();

                // Try to move to name attribute

                if ( clone.MoveToFirstAttribute() )
                {

                    // Select the node from the xml document

                    XmlNode linkNode = xmlDoc.SelectSingleNode("//item[@name=\"" + clone.Value + "\"]");

                    // Copy the node by importing it to a temporary node

                    XmlNode importedLinkNode = xmlSortedDoc.ImportNode(linkNode, true);

                    // Select the items node, then append the imported node as a child

                    xmlSortedDoc.SelectSingleNode("//items").AppendChild(importedLinkNode);
                }
                else
                {
                    Console.WriteLine("Skipping node.");
                }
            }

            // Save the sorted dictionary to a new file

            xmlSortedDoc.Save(@"SortedItemDictionary.xml");
        }
    }
}

Here's the VS 2010 project, which includes the itemdictionary.xml file used in the example:

XMLSort.7z (7.75 kb)

Data Classification Algorithms, DBSCAN and Mahalanobis Distance

by Codewiz51 October 22, 2011 07:16

I've been working on data classification algorithms for the last several weeks.  For the multi-feature (multi-dimensional) data I am working with, I've settled in on a modified version of DBSCAN that utilizes Mahalanobis distance.  Using the Mahalanobis distance instead of the Euchlidean distance (ED) offers some great advantages.  (Mahalanobis distance will be referred to as MD in the rest of this posting to save me some typing.)  MD has an advantage over ED (no pun intended) in that it is not as sensitive to large differences in the order of magnitude of features (dimensions).  e.g. In multi-featured data, one feature may have an order of magnitude (OOM) of 10**5 and another feature may have an OOM of 10**-2.  If you attempt to utilize ED, the first feature is so much larger than the second that it tends to dominate the distance calculation.  MD, because of the nature of the covariance matrix calculation, tends to scale the results so that one or more large OOM features do not dominate the MD.   See this reference for a visualization of this effect.

For all of it's promise and effective results, I am discovering that the entire process is very dependent upon my assumptions.  Guessing the limiting MD to judge whether the point is in a group or how many points a point must be bound to before it is considered a member of the group has a great effect on how points are classified.  Often, slight changes to the MD limit, or the number of points necessary to define a group can rearrange the entire output of the algorithm.  This becomes a very real problem when there are more than three features (dimensions) to you data.  If you cannot visualize your data, then how do you determine if the starting assumptions are "good".

I'll address my partial solution to this issue as I am able to test methods for improving the algorithm.

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen | Modified by Mooglegiant

Disclaimer

This blog represents my personal hobby, observations and views. It does not represent the views of my employer, clients, especially my wife, children, in-laws, clergy, the dog, the cats or my daughter's horse. In fact, I am not even sure it represents my views when I take the time to reread postings.

© Copyright 2008-2011