3

Can someone please provide step by step instructions for getting cppunit working on OS X 10.8 Mountain Lion? This includes any downloads needed and any configuration of Netbeans.

Currently, when I add a cppunit test, there is a warning on the Add Test dialog that says "cppunit library is not detected. Test compilation might fail." I've download both from Sourceforge and from svn cppunit and copied the files to /usr/local/include, but this does not make compilation errors go away.

What am I missing? The Google™ has been of no help with this issue.

ollo
  • 24,797
  • 14
  • 106
  • 155
Professor Tom
  • 352
  • 3
  • 16

2 Answers2

6

I used Homebrew to install CppUnit on OS X 10.8 Mountain Lion. Unit tests then worked from within Netbeans without issue.

The process I followed was:

  1. Install the XCode Command Line Tools
    • Available in XCode preferences or Download as separate DMG
  2. Install Homebrew
    • See Link
    • ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
    • Following install instructions (brew doctor at the end for example)
  3. Use brew to install cppunit
    • brew install cppunit
  4. In Netbeans:
    • Create C++ project
    • Add a function to test
    • Right click cpp file, select "Create Test", choose CppUnit Test
    • Select function from list, follow prompts to create test
  5. Execute tests
    • Right click project, select Test (or crtl+F6)
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Andrew Cain
  • 1,193
  • 2
  • 10
  • 8
  • I'm not a johnny-on-the-spot with StackOverflow since I don't ask many questions and have answered ever fewer. However, while I think your answer is very useful and introduced me to Homebrew, I have listed my solution below which only requires Netbeans, Xcode/Xcode Command Line Tools, CPPUnit and OS X 10.8.x As such, I want to give you points but do not want to accept your answer. I do, however, want to thank you for coming to my aid. – Professor Tom Jan 23 '13 at 04:41
  • evidence that Professor Tom is wrong is that Andrews answer helped me 4 years later. brew is much cleaner, allows for upgrades and better maintenance. – Reza Jun 18 '17 at 05:43
5

I finally figured out what I was doing wrong, so I thought I would answer my own question and avoid a Wisdom of the Ancients.

  1. install Xcode.
  2. install Xcode Command Line Tools via the Preferences dialog (Apple's documentation showing how to do this in Xcode 4)
  3. download CPPUnit from Sourceforge
  4. extract
  5. Run ./configure
  6. run make
  7. run sudo make install

It's possible that the first time I tried this I didn't run the correct command for ./configurebut that's a dubious claim given the fact that I was able to tab complete i.e. I shouldn't have been able to run say ./config.

But I think the real key to my problem was having to call sudo on the make install. I was getting a permission error because the script needs admin rights to put the libraries where they need to go. I could have swore I tried this at some point and it too failed.

I had a coworker try this for me a month or so ago and he got it to work. I procrastinated retrying, but once I did, it worked like a charm. As far as I know, there's no bug between OS X 10.8.1 and 10.8.2 or .3.

Once I followed the steps I have listed above, I was able to go back to Netbeans and add a unit test without the dialog complaining. Furthermore, the test code compiled and ran.

Professor Tom
  • 352
  • 3
  • 16