1

I know there have already been topics on this matter but I unfortunately cannot solve my problem due to my beginner level in C++ programming. I am on OS X Maverick

on this topic: Undefined symbols for architecture x86_64 - Mavericks (Yosemite, El Capitan...)

it is mentioned that the issue of getting the 'Undefined symbols for architecture x86_64' compiling error was often solved by using the option -stdlib=libstdc++ My question is very simple: how do you use this option on Xcode? I am pretty sure it is in Build settings->Apple LLVM 5.1 - Language - C++ -> C++ Standard Library where I can choose libstdc++ instead of libc++ but I am still getting the compiling error when setting this to libstdc++.

The code I'm trying to compile is some template instantiation:

HEADER FILE (range.h)
#ifndef Proj_range_h
#define Proj_range_h

template <class Type> class Range
{
private:
    Type lo;
    Type hi;

public:
    //Constructors
    Range(); //Default constructor
    Range(const Type& low, const Type& high); //low and high value
    Range(const Range<Type>& ran2); //copy constructor

    //Destructor
    virtual ~Range();

    //Modifier functions
    void low(const Type& t1); //to set the low value
    void high(const Type& t1); //to set the high value

    //Accessing functions
    Type low() const; //lowest value in range
    Type high() const; //highest value in range

    Type spread() const; //high - low value

};


#endif



CLASS MEMBER FUNCTIONS CODING (range.cpp)
#include "range.h"
template <class Type> Range<Type>::Range(const Range<Type>& r2)
{
    //Copy constructor
    lo=r2.lo;
    hi=r2.hi;
}

template <class Type> Range<Type>::Range(const Type& low, const Type& high)
{
    lo=*low;
    hi=*high;
}


template <class Type> Type Range<Type>::spread() const
{
    return hi-lo;
}

template <class Type> Range<Type>::~Range<Type>()
{
    //Destructor
}


MAIN FILE (main.cpp)
#include "range.h"
#include <iostream>

int main()
{
    double closingPrice=40;

    double openingPrice=60;

    Range<double> bearish(closingPrice,openingPrice);

    return 0;
}

I hope my question is clear enough.

Thanks

Community
  • 1
  • 1
piof
  • 11
  • 1

0 Answers0