Sign in to follow this  

problem with boost

This topic is 4093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to work with a resource manager in my project but the compiler keeps giving these mistakes In function `ZN11ResourceMgr6CreateERKSs': [Linker error] undefined reference to `boost::filesystem::path::path(std::string const&)' In function `ZN11ResourceMgr12LoadResourceERKSs': [Linker error] undefined reference to `boost::filesystem::path::path(std::string const&)' [Linker error] undefined reference to `boost::filesystem::extension(boost::filesystem::path const&)' I don't understand how this is possible as I've installed the boost libary a,d included in the "to look into files"
 
#include "resourcemgr.h"
#include <assert.h>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/convenience.hpp>

using namespace boost;



ResourceMgr::~ResourceMgr()
{
    ResourceMap::iterator it = m_resources.begin();
    while (it != m_resources.end()) 
    {
        IResource * pRes = (*it).second;
        delete pRes;
        ++it;
    }
}


void ResourceMgr::Register(ResourceMaker * pMaker)
{
    assert (pMaker != NULL);
    m_makers[std::string(pMaker->GetExtension())] = pMaker;
}


IResource * ResourceMgr::Create(const std::string & filename)
{
    filesystem::path full_path (filename);
      
    ResourceMap::iterator it = m_resources.find(full_path.string());
    if (it != m_resources.end()) 
        return (*it).second;
        
    IResource * pRes = LoadResource(full_path.string());    
    if (pRes == NULL)
        return NULL;
    
    m_resources[full_path.string()] = pRes;     
    return pRes;
}


IResource * ResourceMgr::LoadResource(const std::string & filename)
{
    filesystem::path path (filename);
    std::string ext = filesystem::extension(path);
    
    MakerMap::iterator it = m_makers.find(ext);
    if (it == m_makers.end())
        return NULL;

    ResourceMaker * pMaker = (*it).second;
    assert (pMaker != NULL);
    
    FILE * fin = fopen(filename.c_str(), "rt");
    if (fin == NULL)
        return NULL;        
    IResource * pRes = pMaker->Create(fin);
    fclose(fin);
        
    return pRes;
}


std::ostream & operator<< (std::ostream & o, const IResource & res)
{
   res.Dump(o);
   return o;
}


Share this post


Link to post
Share on other sites
Did you compile the library? Not everything in Boost works from headers - some of the bigger libraries (including Boost.Filesystem) require Boost to be compiled with Boost.Jam.

Check the official site on how to compile Boost.

Share this post


Link to post
Share on other sites

This topic is 4093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this