Jump to content
  • Advertisement
Sign in to follow this  
Sylvarant

problem with boost

This topic is 4372 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
Advertisement
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
You also may need to add Boost.Filesystem to the libraries you are linking against in your project options.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!