From c722128ddd36e29c5587b2dd086b6d31d9b07b35 Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Thu, 21 Jul 2011 01:03:41 +0000 Subject: [PATCH] edited another way of using eclipse using cmake --- .../linux_eclipse/linux_eclipse.rst | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/doc/tutorials/introduction/linux_eclipse/linux_eclipse.rst b/doc/tutorials/introduction/linux_eclipse/linux_eclipse.rst index 1e0f58611..25feb7fab 100644 --- a/doc/tutorials/introduction/linux_eclipse/linux_eclipse.rst +++ b/doc/tutorials/introduction/linux_eclipse/linux_eclipse.rst @@ -4,7 +4,7 @@ Using OpenCV with Eclipse (plugin CDT) **************************************** .. note:: - For me at least, this works, is simple and quick. Suggestions are welcome + Two ways, one by forming a project directly, and another by CMake Prerequisites =============== @@ -195,4 +195,64 @@ Assuming that the image to use as the argument would be located in ` section of the OpenCV Wiki) + +Say you have or create a new file, *helloworld.cpp* in a directory called *foo*: + +.. code-block:: bash + #include + #include + int main ( int argc, char **argv ) + { + cvNamedWindow( "My Window", 1 ); + IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 ); + CvFont font; + double hScale = 1.0; + double vScale = 1.0; + int lineWidth = 1; + cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC, + hScale, vScale, 0, lineWidth ); + cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font, + cvScalar( 255, 255, 0 ) ); + cvShowImage( "My Window", img ); + cvWaitKey(); + return 0; + } + +1. Create a build directory, say, under *foo*: ``mkdir /build``. Then ``cd build``. + +#. Put a *CmakeLists.txt* file in build: + +.. cod-block:: bash + + PROJECT( helloworld_proj ) + FIND_PACKAGE( OpenCV REQUIRED ) + ADD_EXECUTABLE( helloworld helloworld.cxx ) + TARGET_LINK_LIBRARIES( helloworld ${OpenCV_LIBS} ) + +#. Run: ``cmake-gui ..`` and make sure you fill in where opencv was built. + +#. Then click ``configure`` and then ``generate``. If it's OK, **quit cmake-gui** + +#. Run ``make -j4`` *(the ``-j4`` is optional, it just tells the compiler to build in 4 threads)*. Make sure it builds. + +#. Start ``eclipse``. Put the workspace in some directory but **not** in ``foo`` or ``foo\\build`` + +#. Right click in the ``Project Explorer`` section. Select ``Import`` And then open the ``C/C++`` filter. Choose *Existing Code as a Makefile Project`` + +#. Name your project, say *helloworld*. Browse to the Existing Code location ``foo\\build`` (where you ran your cmake-gui from). Select *Linux GCC* in the *"Toolchain for Indexer Settings"* and press *Finish*. + +#. Right click in the ``Project Explorer`` section. Select ``Properties``. Under ``C/C++ Build``, set the *build directory:* from something like ``${workspace_loc:/helloworld}`` to ``${workspace_loc:/helloworld}/build`` since that's where you are building to. + + a. You can also optionally modify the ``Build command:`` from ``make`` to something like ``make VERBOSE=1 -j4`` which tells the compiler to produce detailed symbol files for debugging and also to compile in 4 parallel threads. + +#. Done! + + +