Thread: multiple source files opengl HELPPP

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    2

    Exclamation multiple source files opengl HELPPP

    hey guys,

    im trying to split up my engine into classes with different cpp's then implement them into the main.cpp file. i dont know how to do this, please help:

    errors:
    Code:
    Error	1	error LNK2019: unresolved external symbol _glfwSetWindowTitle referenced in function "public: int __thiscall Initialization::initializeWindow(void)" (?initializeWindow@Initialization@@QAEHXZ)	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\initialization.obj
    Error	2	error LNK2019: unresolved external symbol __imp__glewInit referenced in function "public: int __thiscall Initialization::initializeWindow(void)" (?initializeWindow@Initialization@@QAEHXZ)	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\initialization.obj
    Error	3	error LNK2019: unresolved external symbol _glfwTerminate referenced in function "public: int __thiscall Initialization::initializeWindow(void)" (?initializeWindow@Initialization@@QAEHXZ)	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\initialization.obj
    Error	4	error LNK2019: unresolved external symbol _glfwOpenWindow referenced in function "public: int __thiscall Initialization::initializeWindow(void)" (?initializeWindow@Initialization@@QAEHXZ)	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\initialization.obj
    Error	5	error LNK2019: unresolved external symbol _glfwOpenWindowHint referenced in function "public: int __thiscall Initialization::initializeWindow(void)" (?initializeWindow@Initialization@@QAEHXZ)	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\initialization.obj
    Error	6	error LNK2019: unresolved external symbol _glfwInit referenced in function "public: int __thiscall Initialization::initializeWindow(void)" (?initializeWindow@Initialization@@QAEHXZ)	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\initialization.obj
    Error	7	error LNK2019: unresolved external symbol _glfwGetWindowParam referenced in function _main	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\main.obj
    Error	8	error LNK2019: unresolved external symbol _glfwGetKey referenced in function _main	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\main.obj
    Error	9	error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\main.obj
    Error	10	error LNK2019: unresolved external symbol _glfwEnable referenced in function _main	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\main.obj
    Error	11	error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function _main	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\main.obj
    Error	12	error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\SkylineGame\MSVCRTD.lib(crtexew.obj)
    Error	13	error LNK1120: 12 unresolved externals	C:\Users\adam\documents\visual studio 2010\Projects\SkylineGame\Debug\SkylineGame.exe	1



    main.cpp
    Code:
    #include "main.h"#include "initialization.h"
    
    
    
    
    int main()
    {
    	Initialization *Init;
    	Init = new Initialization;
    
    
    	Init->initializeWindow();
    	glClearColor(0.0f, 0.0f, 0.3f, 0.0f);
    
    
    	// Ensure we can capture the escape key being pressed below
    	glfwEnable( GLFW_STICKY_KEYS );
    
    
    	do{
    		
    
    
    		// Swap buffers
    		glfwSwapBuffers();
    
    
    	} // Check if the ESC key was pressed or the window was closed
    	while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
    		glfwGetWindowParam( GLFW_OPENED ) );
    
    
    
    
    	return 0;
    }

    main.h
    Code:
    //INCLUDES#ifndef MAIN_H_
    #define MAIN_H_
    
    
    #include "initialization.h"
    #include <GL/glew.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <GL/glfw.h>
    
    
    //math lib
    #include <glm/glm.hpp>
    using namespace glm;
    #endif
    
    
    //POINTERS & DECLARATIONS


    initialization.cpp

    Code:
    #include "initialization.h"#include "main.h"
    
    
    
    
    
    
    int Initialization::initializeWindow()
    {
    
    
    //Init GLFW
    if(!glfwInit())
    {
    	fprintf(stderr, "could not initiailize GLFW\n");
    	return -1;
    }
    
    
    glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); //4x anti-aliasing
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); //using opengl 3.1
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //destroying legacy opengl
    
    
    //open a window
    if (!glfwOpenWindow(1024, 768, 0,0,0,0, 32,0,GLFW_WINDOW))
    {
    	fprintf(stderr, "failed to open the window\n");
    	glfwTerminate();
    	return -1;
    }
    //init GLEW
    if (glewInit() != GLEW_OK)
    {
    	fprintf( stderr, "failed to init GLEW\n");
    }
    //window title
    glfwSetWindowTitle("Skyline Engine (x86)");
    
    
    return 1;
    }




    initialization.h
    Code:
    #ifndef INITIALIZATION_H_
    #define INITIALIZATION_H_
    
    
    
    
    class Initialization
    {
    public:
    	int initializeWindow();
    	int dropWindow();
    
    
    };
    
    
    
    
    #endif

    a user friendly response would be greatly appreciated :P

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    You need to link in the gl libraries. I'm quite sure whatever tutorial you're using for this provides these instructions. Or perhaps not, because if you're unaware of how to link libraries, IMHO you're probably not ready to be doing graphics programming.

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Well here is the tutorial, it suggests installing drivers, I am not about to go through the pages but on first glance some of the advice seems a bit ropey, I dont beleive for one minute that anybody should just jump into this type of programming with no basic knowledge, have you had any success with any of the example stuff this tutorial gives you? Or is this the first one you tried?
    Tutorial 1 : Opening a window | opengl-tutorial.org
    Last edited by rogster001; 02-06-2012 at 01:37 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    2
    sorry about that i just forgot to use the right build configuration. ive been programming in c++ for two years now but im new to visual studio.. this is what i hate about a lot of other programmers, they're arrogant.

  5. #5
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Quote Originally Posted by Adam West View Post
    this is what i hate about a lot of other programmers, they're arrogant.
    Try to understand, trying to find an error done by another programmer in a 20,000 lines of code with little to none documentation can really alter the behaviour of many, especially if they haven't had their coffee!( or had too many )
    Devoted my life to programming...

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    this is what i hate about a lot of other programmers, they're arrogant.
    There certainly is an arrogance yes, probaly borne of actually doing hard graft to gain their genuine depth of knowledge, and combined with a jaded view after seeing too many posts full of copy and paste code that is trying to be hacked into a working version ahead of the coders time. There is certainly no reason why in two years one could not be capable of very powerful programming, but then i suppose one would also know how to do simple stuff like link required libraries? combine multiple source files into a project?
    Last edited by rogster001; 02-07-2012 at 01:50 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use multiple source files?
    By Sevko in forum C++ Programming
    Replies: 2
    Last Post: 04-25-2011, 02:24 PM
  2. Multiple Source Files, make files, scope, include
    By thetinman in forum C++ Programming
    Replies: 13
    Last Post: 11-05-2008, 11:37 PM
  3. multiple source files
    By AmazingRando in forum C Programming
    Replies: 6
    Last Post: 03-13-2005, 03:39 PM
  4. Multiple Source Files!?!?
    By Padawan in forum C Programming
    Replies: 14
    Last Post: 04-04-2004, 12:19 AM
  5. Replies: 1
    Last Post: 05-01-2003, 02:52 PM

Tags for this Thread