A
A
Alexander2019-02-14 18:47:26
C++ / C#
Alexander, 2019-02-14 18:47:26

How to properly create header, implementation files in C++?

Do not judge strictly)
Hello C++ people)
I am learning Python 3 and set myself the task of translating the glut library into Python 3
Here is the header file

PythonGlut.hpp
#include <glut.h>                       //подключаем заголовочный файл glut.h
#pragma comment (lib, "glut32.lib")    // link with Win32 GLUT lib

namespace pyglut{
    class PythonGlut{
        public:
            PythonGlut();
            ~PythonGlut();

            // Инициализация GLUT и создание окна
            void PythonGlutInitDisplayMode(unsigned int mode);
    };

}

Here is another C++ file (I don't know what to name it)
PythonGlut.cpp
#include "PythonGlut.hpp" //подключаем заголовочный файл PythonGlut.hpp

namespace pyglut{

    PythonGlut::PythonGlut() { }
    PythonGlut::~PythonGlut() { }

    // Инициализация GLUT и создание окна

    void PythonGlut::PythonGlutInitDisplayMode(unsigned int mode){
        glutInitDisplayMode(mode);
    }

}

And here is the implementation
glut_window.cpp
#include "PythonGlut.hpp"

using namespace pyglut;

int main(int argc, char **argv) {

    //создаем объект типа PythonGlut
    PythonGlut pythonglut;

  // инициализация
    pythonglut.PythonGlutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

  return 1;
}

I have 2 questions >
1 Have I created the files correctly? If not, please tell me how.
Do not send to Google there was, in the examples everything is different.
2 How to fix this error
Mistake
C:\PyScripterProjects\PyGlut>cl glut_window.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

glut_window.cpp
Microsoft (R) Incremental Linker Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:glut_window.exe
glut_window.obj
glut_window.obj : error LNK2019: unresolved external symbol "public: __thiscall
pyglut::PythonGlut::PythonGlut(void)" ([email protected]@@[email protected]) referenced
in function _main
glut_window.obj : error LNK2019: unresolved external symbol "public: __thiscall
pyglut::PythonGlut::~PythonGlut(void)" ([email protected]@@[email protected]) referenced
 in function _main
glut_window.obj : error LNK2019: unresolved external symbol "public: void __this
call pyglut::PythonGlut::PythonGlutInitDisplayMode(unsigned int)" (?PythonGlutIn
[email protected]@[email protected]@[email protected]) referenced in function _main
glut_window.exe : fatal error LNK1120: 3 unresolved externals

C:\PyScripterProjects\PyGlut>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question