Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mox123

macrumors 6502
Original poster
Jul 18, 2007
259
1
Chicago
So I have begun using XCode as my default C++ writer. I have been trying to link IT++ and Newmat libraries to do vector and matrices computations using C++. Sadly, I can't get XCode to link up when i compile....

#include <itpp/itbase.h>

I have put the folder inside the project folder, but somehow it can't recognize the path. Could someone please please pretty please give me some suggestions? :confused::(
 
thank you! I have installed FFTW and ITPP v4.2 in my system. But

#include <itpp/itbase.h>

is still not recognized when I compile from Xcode....what else am i missing? :( :confused:

i apologize for being a noob about Xcode...
 
So I have begun using XCode as my default C++ writer. I have been trying to link IT++ and Newmat libraries to do vector and matrices computations using C++. Sadly, I can't get XCode to link up when i compile....

#include <itpp/itbase.h>

I have put the folder inside the project folder, but somehow it can't recognize the path. Could someone please please pretty please give me some suggestions? :confused::(

I think what you probably want to use is

#include "itpp/itbase.h"

If you use angle brackets (as you did) the preprocessor looks in the system libraries. If you use quotes, the preprocessor looks in the current directory. Also note that you have a directory name specified there -- it is going to look for a directory named "ittp", and in that directory should be the "itbase.h". You'll need to fix that if it is not the case.

Alternatively you could add the current directory to the $LIB variable (er... XCode does this different I think...) but that is not recommended.

Cheers,
 
You haven't specified which version Xcode you're using but I'll assume it's some version of Xcode 4.x and point you at Xcode's "Source Trees" documentation. If you haven't already gone to "Preferences" -> "Documentation" and fetched the most current documentation I'd suggest doing so.

<file:///Library/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/index.html#recipes/xcode_help-source_trees_preferences/About.html#//apple_ref/doc/uid/TP40010512-CH1-SW2>
 
Last edited:
Go into project settings and make sure that the header and library paths are included:

ZZ1F69F41F.jpg


Don't tick recursive.

ZZ5BA455FC.jpg


This is: -litpp -lfftw3 -llapack -lblas

Here is an example you can test:

Code:
#include <itpp/itbase.h>

using namespace itpp;
using std::cout;
using std::endl;

int main()
{
    vec a, b, c;
    mat A, B;
    
    a = linspace(1.1, 2.0, 10);
    b = "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0";
    c = a + b;
    
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
    cout << "c = " << c << endl;
    
    A = "1.0 2.0;3.0 4.0";
    B = inv(A);

    cout << "A = " << A << endl;
    cout << "B = " << B << endl;
    
    return 0;
}

The results should be:

Code:
a = [1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2]
b = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]
c = [1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3]
A = [[1 2]
 [3 4]]
B = [[-2 1]
 [1.5 -0.5]]
 
Go into project settings and make sure that the header and library paths are included:

Image

Don't tick recursive.

Image

This is: -litpp -lfftw3 -llapack -lblas

Here is an example you can test:

Code:
#include <itpp/itbase.h>

using namespace itpp;
using std::cout;
using std::endl;

int main()
{
    vec a, b, c;
    mat A, B;
    
    a = linspace(1.1, 2.0, 10);
    b = "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0";
    c = a + b;
    
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
    cout << "c = " << c << endl;
    
    A = "1.0 2.0;3.0 4.0";
    B = inv(A);

    cout << "A = " << A << endl;
    cout << "B = " << B << endl;
    
    return 0;
}

The results should be:

Code:
a = [1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2]
b = [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]
c = [1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3]
A = [[1 2]
 [3 4]]
B = [[-2 1]
 [1.5 -0.5]]


THANK YOU!!!! This does the trick!!! Using command line in the command prompt is definitely way more straightforward.

What version of XCode do you have? yours doesn't look like mine at all in project settings...

Is there any way I can make the linker flags my default setting, as supposed to setting it in every project that makes use of itpp??

thank you SO MUCH again for your help!!
 
I'm using XCode 4. I haven't found a place to put default flags but I'm sure it's possible.
 
pardon my another noob xcode question: is XCode 4 out already? I have only 3.2, and i thought it had come with snow leopard? :confused:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.