Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6815357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:47:51+00:00 2026-05-26T20:47:51+00:00

I am trying to use std::shared_ptr in my code. I have seen there have

  • 0

I am trying to use std::shared_ptr in my code. I have seen there have been other questions on the subject, but I am still getting a compiler error. Have I got the right version of gcc and setup?

What I have done:

I have tried to compile my code with both headers separately — <memory> and <tr1/memory> but still get the errors below in both cases.

The version of gcc I am using is

gcc --version
gcc (GCC) 4.3.2

When I include <memory> header I use std::shared_ptr and with the <tr1/memory> header I use std::tr1::shared_ptr? Is this correct?

I have set up the shared_ptr as follows:

std::shared_ptr<A*> ptr_A = shared_ptr( new A() );

The error I get is as follows:

src/WH.cxx:156: error: 'shared_ptr' is not a member of 'std'
src/WH.cxx:162: error: 'shared_ptr' was not declared in this scope

when I try the <tr1/memory> header

src/WH.cxx:156: error: 'std::tr1' has not been declared
src/WH.cxx:162: error: 'shared_ptr' was not declared in this scope

Looks like I am not including something correctly. Any ideas?

I know the boost library has shared_ptr but these libraries are not an option for me at the moment.

EDIT:
Just to add, my compiler options are as follows:
g++ -O3 -g3 -m32 -fPIC -Wno-deprecated -pthread -m32
Am I missing anything?

P.S. Is there any useful literature on the std smart pointers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:47:51+00:00Added an answer on May 26, 2026 at 8:47 pm

    std::tr1::shared_ptr is part of the TR1 additions to the C++ STL.
    With GCC, it is available either through #include <tr1/memory> (GCC 4.1) or #include <memory> (GCC 4.3)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use std:getline() but getting a strange runtime error: malloc: * error
I'm trying to use a for_each loop in my code, but I'm getting the
I'm trying to use std::string instead of char* whenever possible, but I worry I
I'm trying to use stl algorithm for_each without proliferating templates throughout my code. std::for_each
I have a C++ class where I'm trying to use std::bind1st to bind a
I'm trying to use the std::shared_ptr in clang++(clang version 3.1 (trunk 143100)) using libstdc++(4.6.1).
This does not work. I'm trying to learn how to use std::copy but I
I am trying use std::copy to copy from two different iterator. But during course
I am trying to use shared_ptr with my class but for some reason I
Hi I am trying to use std::thread with G++. Here is my test code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.