Mario.Tapilouw

Wednesday, April 22, 2009

Installing Intel Threading Building Blocks

This is an interesting library to explore. I'm curious about the easeness of thread programming that is offered by this library so I tried to install it on my laptop and see how it runs.

These are the steps for installing this library:

  1. Download the library from www.threadbuildingblocks.org, there are two options, commercial aligned products and open source.
  2. Unzip the file and copy it to somewhere, I copied it into this directory:
    C:\Program Files\Intel\TBB\2.1\
  3. Open the batch file () inside this directory (depends on the compiler that you use)
    C:\Program Files\Intel\TBB\2.1\ia32\vc8\bin\
    then change this line:
    IF NOT DEFINED TBB21_INSTALL_DIR SET TBB21_INSTALL_DIR=C:\Program Files\Intel\TBB\2.1
    Please note that you must fill the TBB21_INSTALL_DIR= with the directory where you unzip the files
  4. Run the batch file, if you're using Windows Vista, you must run it as administrator.


Then the next step is to configure the library in Visual Studio

  1. Open Visual Studio, then choose Tools menu then choose Options
  2. Add the directories for include files and the library files of TBB on the "VC++ Directories" settings.
  3. Then when you want to add TBB into your projects you can add the library to the project by setting the Project Properties.

I hope this configuration works in your computer..

Good luck.

Labels: , , ,

Saturday, April 18, 2009

Selecting Multiple Files in Visual C++

Due to my job, I have to change the compiler to Visual C++. It's a big job and the first thing I have to do is to familiarize myself to the compiler. This is what I usually need in my program, selecting multiple files.

What you need to do is to use CFileDialog as the class to show the dialog box. So you need to initialize it like this:
CFileDialog * openFileDialog = NULL;

TCHAR strFilter[] = { TEXT("Picture Files (*.bmp)|*.bmp||") };
TCHAR strBuffer[MAX_PATH*10] = _T("");

openFileDialog = ( CFileDialog * )new CFileDialog( TRUE,
TEXT(".bmp"),NULL,
OFN_ALLOWMULTISELECT|OFN_LONGNAMES|OFN_ENABLESIZING,
strFilter, this );

openFileDialog->m_ofn.nMaxFile = sizeof(strBuffer);
openFileDialog->m_ofn.lpstrFile = strBuffer;

then what we need to do is to call this dialog as follow, we can use CStringArray or vector to save the array of filenames.

if(openFileDialog->DoModal() == IDOK)
{
POSITION currentPos;
currentPos = openFileDialog->GetStartPosition();

CString str;
CStringArray
strArray;
vector filenames;

strArray.SetSize(0);
filenames.clear();

while(currentPos != NULL)
{
str = openFileDialog->GetNextPathName(currentPos);
filenames.push_back(str);
m_ListBoxLog.AddString(str);
strArray.Add(str);
}
}

Then if you want to show it, just use listbox:

for(filenamesit=filenames.begin();filenamesit!=filenames.end();filenamesit++)
{
m_ListBoxLog.AddString(*filenamesit);
}

/*
int strCount = strArray.GetCount();

for(int i=0;i<strcount;i++)><
{
m_ListBoxLog.AddString(strArray.ElementAt(i));
}

-2009/4/18-

Labels: ,