Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GLFW Across multiple files

GLFW Across multiple files

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chris Copeland
    wrote on last edited by
    #1

    Hey there guys, Okay I have my current code working for GLFW. Effectively i'm just trying to build a small main-frame which I can build on. I have IniApi.cc that stores the main() routine. I have CharKeyCallback.cc which handles the glfwSetCharCallback() just fine. However, i'm trying to make a Texture class which will load textures from a file and store them in memory. So, I placed this at the top of the Texture.cc file:

    #include <Windows.h>
    #include <GL/glfw.h>
    #include <stdio.h>

    #include "Texture.h"

    And my "load" function works like this:

    bool Texture::ReadImage()
    {
    glfwReadImage(_filename, ImageData, _flags);
    return !(ImageData == NULL);
    }

    (If it appears messy or simple, it's because i'm just laying the foundations at the moment). However, when I go to compile, I receive the following error:

    error LNK2019: unresolved external symbol _glfwReadImage referenced in function "public: bool __thiscall Texture::ReadImage(void)" (?ReadImage@Texture@@QAE_NXZ)

    Now, my InitApi.cc runs the lpfw functions just fine, which means the library & DLL have been loaded (glfwOpenWindow opens a window successfully) but Texture.cc won't recognise the lpfw functions, even though i've included #include <GL/glfw.h> at the top. Any suggestions? Thank you :)

    C 1 Reply Last reply
    0
    • C Chris Copeland

      Hey there guys, Okay I have my current code working for GLFW. Effectively i'm just trying to build a small main-frame which I can build on. I have IniApi.cc that stores the main() routine. I have CharKeyCallback.cc which handles the glfwSetCharCallback() just fine. However, i'm trying to make a Texture class which will load textures from a file and store them in memory. So, I placed this at the top of the Texture.cc file:

      #include <Windows.h>
      #include <GL/glfw.h>
      #include <stdio.h>

      #include "Texture.h"

      And my "load" function works like this:

      bool Texture::ReadImage()
      {
      glfwReadImage(_filename, ImageData, _flags);
      return !(ImageData == NULL);
      }

      (If it appears messy or simple, it's because i'm just laying the foundations at the moment). However, when I go to compile, I receive the following error:

      error LNK2019: unresolved external symbol _glfwReadImage referenced in function "public: bool __thiscall Texture::ReadImage(void)" (?ReadImage@Texture@@QAE_NXZ)

      Now, my InitApi.cc runs the lpfw functions just fine, which means the library & DLL have been loaded (glfwOpenWindow opens a window successfully) but Texture.cc won't recognise the lpfw functions, even though i've included #include <GL/glfw.h> at the top. Any suggestions? Thank you :)

      C Offline
      C Offline
      Chris Copeland
      wrote on last edited by
      #2

      Nevermind. For those who might encounter this problem, it turns out I had to add #define GLFW_DLL before the #include <GL/glfw.h> Resolved.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups