compiler gives me error message " boost/smart_ptr.h: No such file ordirectory"

Discussion in 'C++' started by Pallav singh, Apr 27, 2009.

  1. Pallav singh

    Pallav singh Guest

    Hi All ,

    while compiling the following code my compiler gives me error message
    " boost/smart_ptr.h: No such file or directory" . do i need to give
    some comiplation option for it ...such as where to find header file

    > g++ -g file.cc


    #include<iostream>
    #include "boost/smart_ptr.h"
    using namespace std;

    class A
    {
    int a,b;
    public :
    void printf()const
    { cout<<" value of a "<<a <<"Value of b "<<b <<endl ;}
    };

    int main()
    {
    boost::shared_ptr< A > sample(new A);
    printf("The Sample now has %i references\n", sample.use_count());

    boost::shared_ptr< A > sample2 = sample;
    printf("The Sample now has %i references\n", sample.use_count());

    sample.reset();
    printf("The Sample now has %i references\n", sample2.use_count());

    return 0;
    }

    Thanks
    Pallav Singh
     
    Pallav singh, Apr 27, 2009
    #1
    1. Advertising

  2. Re: compiler gives me error message " boost/smart_ptr.h: No such fileor directory"

    On Apr 27, 8:26 pm, Pallav singh <> wrote:
    > Hi All ,
    >
    > while compiling the following code my compiler gives me error message
    > "  boost/smart_ptr.h: No such file or directory" . do i need to give
    > some comiplation option for it ...such as where to find header file


    Try: #include <boost/smart_ptr.hpp>

    You may need to add the -I option with the path where your boost
    library is installed, if not already present in the INCLUDE
    environment
    variable.
     
    Gert-Jan de Vos, Apr 27, 2009
    #2
    1. Advertising

  3. Pallav singh

    James Kanze Guest

    Re: compiler gives me error message " boost/smart_ptr.h: No such fileor directory"

    On Apr 27, 8:35 pm, Gert-Jan de Vos <gert-
    > wrote:
    > On Apr 27, 8:26 pm, Pallav singh <> wrote:


    > > while compiling the following code my compiler gives me error message
    > > " boost/smart_ptr.h: No such file or directory" . do i need to give
    > > some comiplation option for it ...such as where to find header file


    > Try: #include <boost/smart_ptr.hpp>


    That shouldn't change anything. The standard says that when
    using #include "...", if the search fails, the directive is
    reprocessed as if it were #include <...>.

    > You may need to add the -I option with the path where your
    > boost library is installed, if not already present in the
    > INCLUDE environment variable.


    He definitely needs to tell the compiler where to look for the
    headers, if they aren't installed in the "standard places".
    What the standard places are, of course, depends on the
    compiler; for g++, it's derived from where the compiler itself
    is installed, with the adjunction (at least under Unix) of
    "/usr/include", and maybe "/usr/local/include".

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Apr 28, 2009
    #3
  4. Re: compiler gives me error message " boost/smart_ptr.h: No such fileor directory"

    On Apr 28, 9:41 am, James Kanze <> wrote:
    > On Apr 27, 8:35 pm, Gert-Jan de Vos <gert-
    >
    > > wrote:
    > > On Apr 27, 8:26 pm, Pallav singh <> wrote:
    > > > while compiling the following code my compiler gives me error message
    > > > "  boost/smart_ptr.h: No such file or directory" . do i need to give
    > > > some comiplation option for it ...such as where to find header file

    > > Try: #include <boost/smart_ptr.hpp>

    >
    > That shouldn't change anything.  The standard says that when
    > using #include "...", if the search fails, the directive is
    > reprocessed as if it were #include <...>.


    ..hpp rather than .h might make the difference..
     
    Gert-Jan de Vos, Apr 28, 2009
    #4
  5. Pallav singh

    James Kanze Guest

    Re: compiler gives me error message " boost/smart_ptr.h: No such fileor directory"

    On Apr 28, 11:03 am, Gert-Jan de Vos <gert-
    > wrote:
    > On Apr 28, 9:41 am, James Kanze <> wrote:


    > > On Apr 27, 8:35 pm, Gert-Jan de Vos <gert-


    > > > wrote:
    > > > On Apr 27, 8:26 pm, Pallav singh <> wrote:
    > > > > while compiling the following code my compiler gives me error message
    > > > > " boost/smart_ptr.h: No such file or directory" . do i need to give
    > > > > some comiplation option for it ...such as where to find header file
    > > > Try: #include <boost/smart_ptr.hpp>


    > > That shouldn't change anything. The standard says that when
    > > using #include "...", if the search fails, the directive is
    > > reprocessed as if it were #include <...>.


    > .hpp rather than .h might make the difference..


    Using the correct name of the file is a requirement, yes:).
    I'd missed that you'd changed the name of the file, as well as
    changing the form from "..." to <...>. (And generally, if Boost
    is correctly installed, you probably should consider it part of
    the "implementation", so <...> would be more appropriate.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Apr 29, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,147
  2. Kim Nørby Andersen
    Replies:
    5
    Views:
    1,352
    Jim Cheshire [MSFT]
    Dec 19, 2003
  3. Ram
    Replies:
    0
    Views:
    2,857
  4. Replies:
    3
    Views:
    259
    Martin Ambuhl
    Oct 25, 2005
  5. _Who
    Replies:
    0
    Views:
    270
Loading...

Share This Page