I have a lot of data that I was compiling into a *.lib file. It's basically the equivalent of an Excel spreadsheet with 4,000 rows and 75 columns. I wrote a quick routine that read from a .cdf (.xls saved as .cdf) and wrote in the proper format of an array of structs with 4,000 elements, each element having 75 members to a .cpp which was part of my library project. Everything works fine and I was happy with doing it that way - the user gets a single .exe file. In VC2008, it takes about 40 minutes for the .lib file to build which isn't a big problem for me because I only need to change the data about once a year. FYI, the .cdf file is proprietary so I don't want to distribute it to the users who may inadvertently (or purposefully) modify it, but the .exe file needs to have access to the data.
I have migrated from VS2008 to VS2010. The build time for the .lib file is a little longer (about 50 minutes) but the big problem is that the .exe files that use it now take just as long to build (in VS2008, they took about 30 seconds each). That's about 100 times longer in VS2010 than in VS2008, with the same project settings in both. I can't be productive with the .exe projects (which I'm constantly updating and adding to) if it's going to take 50 minutes every time I want to test a change.
Someone suggested that I look into a user-defined resource which wouldn't be compiled and would significantly speed up my build times. Does anyone have a sample of how to use an .xls, .cdf, .txt, etc. file as a resource (or a better way of doing it than an array of structs in a library file)?
Thanks in advance,
Ed
Here is some sample code to show you how I do it now - Thanks, Ed
////////////////////////////////////////////////////////////////////////////////////////
// This is a sample of the kind data structure I use to exchange stored data between the
// .lib file and the .exe file, and load into a dialog
// Significantly shortened for simplicity - the real one has 75 members
//
struct EMDData // in a header file #included in both the .lib and the .exe
{
CString csKey; // The key
CString csName; // (e.g. "PART_0375221")
double dWeight; // Weight (lbs)
double dDepth; // Depth (in)
int nFlange; // Flange type
int nBase; // Base type
};
////////////////////////////////////////////////////////////////////////////////////////
// Here's the Function from the .lib project that has all the data
// Significantly shortened for simpliity - the real one has #define NUMNAMES 4125
// and remember the EMDData struct has 75 members
// The MY_DATA[] array was written by a short routine that read from an .sdf file and
// wrote it this way. The .sdf file is like:
//
// W2209613 WXPRQTBG 335.0 44.000 21 1001 .....
// W3389512 VYAPSAFH 322.0 43.875 21 1001 ......
//
/****** FUNCTION getDataFromStruct() ******/
BOOL getDataFromStruct(CString csKey, struct EMDData *EData) // in file My_Data.cpp
{
int i;
BOOL bFound = FALSE;
struct EMDData MY_DATA[NUMNAMES];
MY_DATA[0].csKey = _T("W2290613");
MY_DATA[0].csName = _T("WXPRQTBG");
MY_DATA[0].dWeight = 335.0000;
MY_DATA[0].dDepth = 44.0000;
MY_DATA[0].nFlange = 21;
MY_DATA[0].nBase = 1001;
MY_DATA[1].csKey = _T("W3389512");
MY_DATA[1].csName = _T("VYAPSAFH");
MY_DATA[1].dWeight = 322.0000;
MY_DATA[1].dDepth = 43.8750;
MY_DATA[1].nFlange = 21;
MY_DATA[1].nBase = 1001;
// -> continues through MY_DATA[4124]
for(i=0;i<numnames;i++)>
if(MY_DATA[i].csKey.Compare(csKey) == 0) {
EData->csKey = MY_DATA[i].csType;
EData->csName = MY_DATA[i].csName;
EData->dWeight = MY_DATA[i].dWeight;
EData->dDepth = MY_DATA[i].dDepth;
EData->nFlange = MY_DATA[i].nFlange;
EData->nBase = MY_DATA[i].nBase;
bFound = TRUE;
break;
}
}
return bFound;
} /* end of function getDataFromStruct() */
////////////////////////////////////////////////////////////////////////////////////////
// From the .exe file, from a dialog where the user selects the Part, I would have a
// something like the following:
//
if(getDataFromStruct(m_csPart, &EData) {
// -> load the dialog box
// etc.....
} else {
EMDAlert(_T("Error 469: Data not retrieved."));
// etc.....
}