9

I am working on a cross-platform C++ project with 8 other people which uses the following libraries:

  • OpenCV Library
  • Boost C++ Library

The project is inteded to be cross-platform so all users have agreed not to use platform-specific code, and, to keep things as simple as possible, all users will be using Eclipse as their IDE. However, some will be using Eclipse for Windows while other will be using Eclipse for Linux.

Since the project will be hosted on SVN, we would like to avoid conflicts with different configuration files (like make files, eclipse project files etc..) which are shared. We would also like to share as much of the configuration files as possible through SVN, to keep the configuration as simple as possible.

Let's assume that all users have properly configured system variables and installed the required build tools (such as make, cmake etc.), and have configured their Eclipse settings configured properly (but not the project-specific settings).

How to configure the project once and what of the configuration files to share on the repository, so that both Windows and Linux users can compile it without modifying configuration files retrieved from the SVN repository?

(I am not looking for the complete solution which would specifically work for those 2 libraries I mentioned, so I would appreciate a general how-to step-by-step explanations which would enable me to easily add another library.)

eold
  • 5,972
  • 11
  • 56
  • 75
  • I've looked into using Eclipse this way and hit quite a few problems. To begin with, I'd try and make completely separate DEBUG/RELEASE configurations per platform and it at all possible, stick to the exact same version of Eclipse and CDT! You end up having to use SVN only to share code and keep Eclipse build configs maintained locally. I'm interested to know how you get on! – John McFarlane May 25 '11 at 04:58
  • 1
    Im currently investigating setting up a cross-platform open-cv project with Eclipse and SVN. I would be interested to know how you got on ? It would be great if you were now in a position to answer your own question based on your experiences. – volting Sep 14 '12 at 15:41

2 Answers2

0

General discussion:

You will need to install Cygwin or something similar to it to make GNU Autotools toolchain available to Eclipse on Windows: How to deal with Eclipse CDT+Cygwin?

Once your toolchain, Eclipse, with CDT and SVN connectors are ready on your development machines, go through the following steps.

  1. Open Eclipse and switch to CDT: Click Window->Open Perspective->Other... and select C/C++
  2. Select: Eclipse->File->New->C++ Project
  3. Project name: viewer
  4. Select: Project type->GNU Autotools->Hello World C++ Autotools Project
  5. Click: Next
  6. Click: Finish
  7. Right-click in Project Explorer: viewer->Reconfigure project
  8. Click: Console->Display Selected Console submenu-># CDT Global Build Console. If "autoreconf -i" output is nominal, proceed to step 9. If Console reports: sh: autoreconf: command not found, then add the path to the autoreconf command to the Project Build Environment:
    1. Right-click in Project Explorer: viewer->Properties->C/C++ Build->Environment->Add...
    2. Name: PATH
    3. Value: path_to_autoreconf:${env_var:PATH}
    4. Click: OK
    5. Click: Apply
    6. Go back to step 8.
  9. Double-click: Project Explorer->viewer->src->viewer.cpp
  10. Add some code:

    include <opencv/cv.h>

    include <opencv/highgui.h>

    include <cassert>

    int main(int argc, char *argv[]) {

    assert(argc > 1);

    CvMat* img = cvLoadImageM(argv1);

    cvNamedWindow("Picture", CV_WINDOW_AUTOSIZE);

    cvShowImage("Picture", img);

    cvWaitKey(0);

    return 0;

    }

  11. Double-click: Project Explorer->viewer->configure.ac and enter the following code below AC_PROG_CXX.

    AC_CHECK_LIB([opencv_core],[cvSetZero],[],[])

    AC_CHECK_LIB([opencv_highgui],[cvShowImage],[],[])

    AC_CHECK_LIB([boost_regex-mt],[regexecA],[BOOST_LIB_SUFFIX="-mt"],[BOOST_LIB_SUFFIX=""])

    AC_SUBST(BOOST_LIB_SUFFIX)

  12. Double-click: Project Explorer->viewer->src->Makefile.am and enter the following code. >

    bin_PROGRAMS=viewer

    viewer_SOURCES=openCvFocusIssue.cpp

    viewer_LDFLAGS = -lboost_regex@BOOST_LIB_SUFFIX@ -lopencv_core -lopencv_highgui

  13. Repeat step 8, autoreconf (Reconfigure project)
  14. Click: Project Explorer->viewer
  15. Build project by clicking the hammer in the toolbar. If you do not see the hammer, Window->Open Perspective->Other... and select C/C++. If C/C++ does not show up, install the CDT.
  16. Click: Project Explorer->viewer and then Run->Run, then in the Run As window->Local C/C++ Application, then in the Launch Debug Configuration Selection window->gdb/mi and press enter. You should see Hello World.
  17. Quit Eclipse and navigate to the viewer project directory.
  18. On the command line, issue make dist
  19. Ensure you got a viewer-1.0.tar.gz or similarly named file, and then remove it: rm viewer-1.0.tar.gz
  20. On the command line, issue make clean
  21. In the same place, issue make distclean.
  22. Navigate to the workspace directory that contains the viewer project.
  23. Move the entire viewer directory to the directory that contains the svn checkout you want to place the viewer project in.
  24. Change directories to where you just moved the viewer.
  25. svn add viewer && svn ci -m "Added eclipse-autotool project"
  26. Open eclipse and make sure that you have an SVN connector installed.
  27. Remove the "viewer" project from the Project Explorer view.
  28. Open eclipse and add this SVN repository checkout to the Team perspective.
  29. Import the viewer project from your SVN repository checkout.
  30. Switch back to the C/C++ perspective and have fun.
Community
  • 1
  • 1
Alexander Patrikalakis
  • 5,054
  • 1
  • 30
  • 48
0

Two suggestions:

  • Use cmake: I love this tool. There is a bit of a learning curve but if you get it right all the project will include is the cmake files and when a person first checks it out they run cmake to generate their makefiles (or VC++ project files, etc) with all the different rules for linux or windows one might need.

or

  • Check in a basic config for the project, then add those configs to the git/svn ignore so no one ever checks them in again, then when you checkout for the first time you have to get your config running but after that it won't be overwritten.
RobC
  • 502
  • 4
  • 17