I'm just beginning a project that will use some opencv functions so I wrote some simple code to verify that my linking, etc., was correct.
I put opencv under "Libraries used in project" under Project/Properties/Libraries; under Build options/Linker settings/Link libraries I listed cv and highgui; and under Project/Set programs' arguments/Release - Program arguments I have ../../lena.bmp 
(lena.bmp is in the project root directory.)
Compiles OK, and if I open a Konsole window, cd to the Release directory and run it with ../../lena.bmp as a command line argument everything is good -- the openCv window displaying the image opens & waits for a keypress (any key) to close it.  This is as it should be.
But if I run it within Code::Blocks, a terminal window opens saying
"Process returned 0 (0x0)  execution time : 0.000 s
 Press ENTER to continue."
and no image is displayed.
Or, maybe the image is displayed but closes too quickly to be visible.   Why does the Code::Blocks terminal report "Process returned ..."?   The program shouldn't return until a key is pressed.
This is the code:
#include <cv.h>
#include <highgui.h>
int main( int argc, char* argv[] ) {
  IplImage *img;
  if ( (img = cvLoadImage( argv[1], 0)) != 0) {
    cvNamedWindow( "Original image", 1 );
    cvShowImage( "Original image", img );
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Original image" );
  }
  return 0;
}
Edit: I forgot to mention that I also used LibraryFinder (under Project/Properties/Libraries clicked "Add Manual Build Script") to get it to compile.  That worked beautifully.   But the problem described above still remains.