Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Weird Cxx11 Undefined Error  (Read 1031 times)

0 Members and 1 Guest are viewing this topic.

remotesh

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Weird Cxx11 Undefined Error
« on: July 02, 2017, 11:06:03 pm »
I'm using C++ with SFML libraries with VisualCode on Xubuntu with G++ as my compiler.
I installed the SFML library via the packages (libsfml-dev).

I have a basic texture Manager class.

    #ifndef TEXTUREMANAGER_HEADER
    #define TEXTUREMANAGER_HEADER
   
    #include <SFML/Graphics.hpp>
    #include <map>
    #include <string>
   
    class TextureManager {
       private:
          std::map<std::string, sf::Texture> _textures;
       public:
          void loadTexture(std::string, std::string);
          sf::Texture& getSpecificTexture(std::string);
   
          TextureManager()
          {
          }
    };
    #endif

That I call in another one of my class functions:

    void Test::loadTextures()
    {
        std::string text = "texture_brunette_girl";
        std::string loc  = "../sprites/brunette.png";
        _texmgr.loadTexture(text, loc);
    }

(_texmgr is just an initialized TextureManager object)

However I get this error message when I compile:

    test.o: In function `Test::loadTextures()':
    /dev/open-engined/./src/Test.cpp:32: undefined reference to `TextureManager::loadTexture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
    collect2: error: ld returned 1 exit status


I'm compiling with G++, here's my compile command for good measure:

    g++ -c -std=c++11 -Wall -g ./src/test.cpp
    g++ test.o -o open-engine -lsfml-graphics -lsfml-window -lsfml-system


I'm not sure why it's complaining about the undefined reference when I'm clearly calling that function with the correct data type. Googling and whatnot hasn't been much help.

Thanks in advance!

remotesh

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Weird Cxx11 Undefined Error
« Reply #1 on: July 04, 2017, 07:25:26 am »
I was a dummy guys,

My make file wasn't hitting that particular file which was throwing me the error. This can be closed.