Code:
#include <iostream>
#include "cv.h"
#include "highgui.h"

using namespace std;

int main ()
{
  VideoCapture cap(0);

  if (cap.isOpened() == true) {
    cout << "success\n";
  } else {
    cout << "error\n";
  }

  return 0;
}
I compiled the above code using MinGW's g++ and it gave me lots of error messages:
In file included from C:/OpenCV2.0/include/opencv/cxcore.hpp:2243,
from C:/OpenCV2.0/include/opencv/cxcore.h:2123,
from C:/OpenCV2.0/include/opencv/cv.h:58,
from camtest01.cpp:2:
C:/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv::Ptr<_
Tp>::addref()':
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: there are no arguments
to `__exchange_and_add' that depend on a template parameter, so a declaration o
f `__exchange_and_add' must be available
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1442: error: (if you use `-fpermiss
ive', G++ will accept your code, but allowing the use of an undeclared name is d
eprecated)
C:/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `void cv::Ptr<_
Tp>::release()':
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1446: error: there are no arguments
to `__exchange_and_add' that depend on a template parameter, so a declaration o
f `__exchange_and_add' must be available
C:/OpenCV2.0/include/opencv/cxoperations.hpp: In member function `cv::Ptr<_Tp>&
cv::Ptr<_Tp>::operator=(const cv::Ptr<_Tp>&)':
C:/OpenCV2.0/include/opencv/cxoperations.hpp:1473: error: there are no arguments
to `__exchange_and_add' that depend on a template parameter, so a declaration o
f `__exchange_and_add' must be available
In file included from C:/OpenCV2.0/include/opencv/cxcore.hpp:2244,
from C:/OpenCV2.0/include/opencv/cxcore.h:2123,
from C:/OpenCV2.0/include/opencv/cv.h:58,
from camtest01.cpp:2:
C:/OpenCV2.0/include/opencv/cxmat.hpp: In copy constructor `cv::Mat::Mat(const c
v::Mat&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:102: error: `__exchange_and_add' undeclare
d (first use this function)
C:/OpenCV2.0/include/opencv/cxmat.hpp:102: error: (Each undeclared identifier is
reported only once for each function it appears in.)
C:/OpenCV2.0/include/opencv/cxmat.hpp: In constructor `cv::Mat::Mat(const cv::Ma
t&, const cv::Range&, const cv::Range&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:174: error: `__exchange_and_add' undeclare
d (first use this function)
C:/OpenCV2.0/include/opencv/cxmat.hpp: In constructor `cv::Mat::Mat(const cv::Ma
t&, const cv::Rect&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:189: error: `__exchange_and_add' undeclare
d (first use this function)
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `cv::Mat& cv::Mat::ope
rator=(const cv::Mat&)':
C:/OpenCV2.0/include/opencv/cxmat.hpp:239: error: `__exchange_and_add' undeclare
d (first use this function)
C:/OpenCV2.0/include/opencv/cxmat.hpp: In member function `void cv::Mat::addref(
)':

...and still a lot more...
the command :
g++ camtest01.cpp -o out/camtest01 -I"C:\OpenCV2.0\include\opencv" -L"C:\OpenCV2.0\lib" -llibcv200 -llibcxcore200 -llibhighgui200
could someone please tell me what's wrong?