I'm trying to move my MSVC8 code over to Code::Blocks on Ubuntu. I was using the gcc compiler but switch to the Intel one when this problem occured, unfortunately that didn't change anything. Here is the code and the complaints from Code::Blocks
#include <boost/thread.hpp>
namespace renwin
{
// calls glfwInit on construction and glfwTerminate on destruction
class GLFWInstance
{
public:
GLFWInstance() { glfwInit(); };
~GLFWInstance() { glfwTerminate(); };
};
class Window // THIS IS THE ERROR
{
public:
// constructs window
Window(const std::string &appTitle,math::vector2i &resolution,bool isFullscreen);
// sets the window dimensions
void SetResolution(math::vector2i &resolution);
// swaps the display buffers
void SwapBuffers() const { glfwSwapBuffers(); };
// issues request to close window
void Quit() {};
private:
boost::mutex mutex; // thread mutex for window // THIS IS THE ERROR TOO
GLFWInstance glfwIns; // glfw Instance
};
}
Quote:
Code::Blocks
/home/bernard/C++ Projects/glfwHello/renwin.h:15: undefined reference to `boost::mutex::~mutex()'
/home/bernard/C++ Projects/glfwHello/renwin.h:15: undefined reference to `boost::mutex::~mutex()'
/home/bernard/C++ Projects/glfwHello/rewnwin.cpp:15: undefined reference to `boost::mutex::mutex()'
/home/bernard/C++ Projects/glfwHello/rewnwin.cpp:20: undefined reference to `boost::mutex::~mutex()'
/home/bernard/C++ Projects/glfwHello/rewnwin.cpp:15: undefined reference to `boost::mutex::mutex()'
/home/bernard/C++ Projects/glfwHello/rewnwin.cpp:20: undefined reference to `boost::mutex::~mutex()'
// reads count objects into output iterator dest
template <typename Stream,typename OutputIterator,typename ValueT>
void Read(Stream &s,OutputIterator &dest, boost::uint32_t count)
{
std::iterator_traits<OutputIterator>::value_type temp; // THIS IS THE ERROR
while (count--)
{
Read(s,temp);
*dest++=temp;
}
}
Quote:
Code::Blocks
/home/bernard/C++ Projects/glfwHello/iolib.h:13: error: expected `;' before ‘temp’
/home/bernard/C++ Projects/glfwHello/iolib.h:16: error: ‘temp’ was not declared in this
namespace renwin
{
lg::Log<std::fstream> Log()
{
boost::shared_ptr<std::fstream> pLogFile(new std::fstream("log.txt",std::ios::out|std::ios::app));
return lg::Log<std::fstream>(pLogFile,"PakFile");
}
}
using namespace renwin;
Window::Window(const std::string &appTitle,math::vector2i &resolution,bool isFullscreen)
{
if( !glfwOpenWindow( resolution[math::X], resolution[math::Y], 0, 0, 0, 0, 16, 0, (isFullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW) ) );
throw ex::open_failed_error(Log(),std::string("Failed to open window: ")+appTitle); // THIS IS THE ERROR
glfwSetWindowTitle(appTitle.c_str());
}
The log header is
#pragma once
namespace lg
{
class endl
{
};
template <typename Stream>
Stream& operator << (Stream& os,const endl& end) { os<<")>-"<<std::endl;return os; };
template <typename Stream>
class Log
{
public:
Log(boost::shared_ptr<Stream> pOutputStream,const std::string ownerLabel) : ownerLbl(ownerLabel), pLS(pOutputStream) { };
~Log() { pLS->flush(); }; // writes output to log
// returns stream for logging errors
Stream &Error(void) { (*pLS)<<"-<("<<ownerLbl<<"-Error: ";pLS->flush();return *pLS; };
// returns stream for logging warnings
Stream &Warning(void) { (*pLS)<<"-<("<<ownerLbl<<"-Warning: ";pLS->flush();return *pLS; };
// returns stream for logging messages
Stream &Message(void) { (*pLS)<<"-<("<<ownerLbl<<"-Message: ";pLS->flush();return *pLS; };
private:
boost::shared_ptr<Stream> pLS; // pointer to stream for log output
std::string ownerLbl; // string label for owner of log
};
};
Quote:
Code::Blocks
/home/bernard/C++ Projects/glfwHello/rewnwin.cpp:18: error: no matching function for call to ‘ex::open_failed_error::open_failed_error(lg::Log<std::basic_fstream<char, std::char_traits<char> > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)’
/home/bernard/C++ Projects/glfwHello/exceptions.h:153: note: candidates are: ex::open_failed_error::open_failed_error(LOG&, std::string) [with LOG = lg::Log<std::basic_fstream<char, std::char_traits<char> > >]
/home/bernard/C++ Projects/glfwHello/exceptions.h:150: note: ex::open_failed_error::open_failed_error()
/home/bernard/C++ Projects/glfwHello/exceptions.h:148: note: ex::open_failed_error::open_failed_error(const ex::open_failed_error&)
/home/bernard/C++ Projects/glfwHello/rewnwin.cpp:9: instantiated from here
/home/bernard/C++ Projects/glfwHello/log.h:27: warning: ‘lg::Log<std::basic_fstream<char, std::char_traits<char> > >::ownerLbl’ will be initialized after
/home/bernard/C++ Projects/glfwHello/log.h:26: warning: ‘boost::shared_ptr<std::basic_fstream<char, std::char_traits<char> > > lg::Log<std::basic_fstream<char, std::char_traits<char> > >::pLS’
/home/bernard/C++ Projects/glfwHello/log.h:15: warning: when initialized here
Any help would be much appreciated.