Xcode 4 can't find CPPUNIT - unit-testing

I installed Xcode 4 awhile ago and I finally got around to getting cppunit installed. I tried using it in one of my projects last night and I keep getting errors that Xcode cannot find cppunit files.
E.g. Lexical or Preprocessor Issue 'cppunit/extensions/TestFactoryRegistry.h' not found.
main.cpp
#include <iostream>
#include "exception.h"
#include "dataStruct.h"
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main ()
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest (registry.makeTest ());
return runner.run ("", false);
}
So I checked /usr/local/include and /usr/local/lib and all the cppunit files are there. There were no errors when I installed cppunit either. It is my understanding that Xcode searches /usr/local/include and /usr/local/lib by default. Do I need to add something to a path variable or change a project setting to get it to work?
Thanks in Advance,
Madison

Figured it out. You need to add custom search paths to the project:
And then you have to tell the linker what to do:

Related

Using gdcm libs in UE4

For my UE4 project I want to use the GDCM libraries for C++ to load CT Scans. So I really tried a lot the last few days but I'm still not able to use GDCM... But where is the error? Can someone help me?
I created the dll and lib files with CMake (VS 2013 Win64) successfully.
I put all the libs in ...Unreal Projects\VolumeImport\ThirdParty\Includes\GDCM\Libraries
I added each of the 16 libs in the VolumeImport.Build.cs with
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "gdcmMSFF.lib"));
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "gdcmCommon.lib")); ...
I put all the header files in Unreal Projects\VolumeImport\ThirdParty\Includes\GDCM\Includes
I set the Includepath to this location in the project properties.
I put all the dlls in C:\Windows\System32
Then I used the headers:
#include "VolumeImport.h"
#include <gdcmVersion.h>
#include <gdcmReader.h>
#include <gdcmPixmapReader.h>
#include <gdcmImageReader.h>
#include <gdcmAttributes.h>
bool CTFileLoader::Convert_DICOM()
{
/** ... other well working code ... */
gdcm::Trace::SetDebug(false); gdcm::Trace::SetError(true);
gdcm::ImageReader reader;
reader.SetFilename(files_to_process[i].c_str());
if(!reader.Read()) { }
}
And I get an error in the gdcmMediaStorage.h: "error C4515: 'gdcm': Namespace uses itself."
I tried using different includes but this causes diffrent errors in diffrent headers... Is there something wrong with the libraries? But I'm sure they were added, because using only the gdcmTrace.h and the gdcm::Trace::functions works fine.
Now I got the solution:
In my VolumeImport.Build.cs I additionally added the DLLs:
PublicDelayLoadDLLs.Add(Path.Combine(LibrariesPath, "gdcmMSFF.dll")); ...
I changed the gdcmMediaStorage.h file: Comment out the "using namespace gdcm;"
Furthermore I had dynamic_cast problems with this big library and it needs to enable RTTI

Using Boost library in XCode

not particularly good with this kind of stuff I have managed to install the Boost C++ library and this basic program works with the g++ compiler and linking to the right .dylib files.
#include <iostream>
#include <boost/filesystem.hpp>
using namespace boost;
int main()
{
filesystem::path path1("/Users/username/Documents/testfile.txt");
filesystem::remove(path1);
std::cout << "It worked" << std::endl;
return 0;
}
Now I would like to do the same, just using Xcode to build and run the program, but it doesn't work. I have done everything in this tutorial:
http://buddypanda.com/?p=10
i.e. include header and library search paths, as well as linked the .dylib files of filesystem and system under the 'Build Phases' tab.
The Build succeeds but then the program crashed with an error of EXC_BAD_ACCESS.
I can maybe provide more specifics on what goes wrong if you tell me where to look.
Thanks!
EDIT1: I am using g++-4.9 and Boost-1.58 and Xcode 6.4

Compile C++ with static lib

this will probably a dumb question for you guy's but I have no experience in C++ what so ever. I'm using an open source project osrm (which is awesome). Still to request a route, you have make an http request. To reduce the running time, I would like to build a wrapper around the code and call it using the command line. So I googled a bit and found that osrm already creates a static lib (.a file) when compiling the project. I also found a piece of code that points me in the right directions for building a wrapper. So to begin I build a simple hello world program (see below) that includes some files from that static lib. To compile I followed this tutorial.
My directory structure looks like this:
./helloWorld.cpp
./libs/libOSRM.a
And the command to compile is this:
gcc –static helloworld.cpp –L ./libs –l libOSRM.a
The code it selve:
#include "Router.h"
#include "boost/filesystem/path.hpp"
#include "ServerPaths.h"
#include "ProgramOptions.h"
#include <InternalDataFacade.h>
#include <viaroute.hpp>
#include <iostream.h>
main()
{
cout << "Hello World!";
return 0;
}
the exact error I got:
fatal error: ServerPaths.h: No such file or directory #include "ServerPaths.h"
Add the -IPathToTheHeaderFiles to the compiler options. So it will find the files to be included. Replace PathToTheHeaderFiles with the path where your file ServPaths.h resides.
Edit: Add as many -I as you need for further header files.
Additionally it would be worth to read a book about C++ or/and the GCC manual1
1 Section 3.11 will help.

CodeLite not working with boost library

I'm having some troubles to get my CodeLite IDE working with Boost library.
So basically, I've got CodeLite v.6.1.1 and Boost library downloaded from sourceforge. I would love to make it actually working, but I failed to do so using the following concept:
I did create new workspace, than I did go -> Settings -> Build Settings -> Compilers (here I have two compilers, one of which is CodeLite 4.8.1 and the other one is MinGW Code::Blocks, I did select CodeLite 4.8.1. -> Advanced -> Global Paths -> and I did provide two blank lines of Include Path and Libraries Path with the directory of unpacked boost library (Windows 7): C:\boostlib\boost_1_57_0.
In this catalog (i.e.: C:\boostlib\boost_1_57_0), I have got all neccesary files, all of them are unzipped and yet I can't get it working.
Besides, I can't click on apply when I'm done with setting path to files containing boost library, all I can do is click ok but once I'm done with this I can't work with libraries from boost.
The following code isn't working:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
// ERROR MESSAGE: boost/lambda/lambda.hpp, No such file or directory
typedef std::istream_iterator in;
std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << ” ” );
return 0;
}
The message I get is:
boost/lambda/lambda.hpp: No such file or directory
Is there any chance I can get CodeLite working with boost library or should I simply switch IDE and forget about it ?
Your on the right track but need to point to the libs and include folders inside the boost directory.
I use the the http://nuwen.net/mingw.html version of mingw as STL (the guy) includes boost as part of his distribution.
So in codeLite I just have to add
C:\MinGW\lib to the libraries path
C:\MinGW\include to the include path

boost problem in windows 7

I have written the following code
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <boost/system/windows_error.hpp>
using namespace boost::system;
int main(){
boost::asio::io_service io;
boost::asio::deadline_timer t(io,boost::posix_time::seconds(5));
t.wait();
std::cout<<"hello world";
return 0;
}
and I get the following error:
1>LINK : fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_44.lib'
I dont know how and what do, can you please explain what is happening and what steps I can take to fix it?
Ok, for MSVC++ 2010
Under Project Properties, goto
Configuration Properties -> Linker -> General -> Additional Library Directories and add there the path to the *.lib file (For example: C:\boost_1_41_0\stage\lib)
As far as I can tell from the error message it compiles but can't find the boost compiled libraries.
These you have to build yourselves unless you can find them prebuilt.
IIRC boost are built using a tool called bjam. I think this explains it rather throughly: http://www.highscore.de/cpp/boostbuild/index.html.
After it's built you have to instruct the compiler to link it using the project properties.
I suspect you haven't built the libraries. You can get the pre-built libraries from BoostPro or you can build them yourself following the instructions at http://www.boost.org/doc/libs/1_44_0/more/getting_started/windows.html
I was working in one instance of Visual Studio 2010. When I started up another, to scrawl out a bit of code, I was shocked to see the same error message. Reset includes and lib (Project->NameofProject Properties then select VC++ Directories) and toggled back and forth between debug and release, at first just once, then a few more times, as I grew increasingly alarmed at none of this working.
Even though the IDE didn't report any activity ('Build Failed,' was all it said in the place where it shows includes/libs being enumerated) after a few minutes (of furious web browsing) I came back to discover that it had silently self-fixed.