Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:43:31+00:00 2026-06-14T11:43:31+00:00

I am currently trying to debug a program, which is rather determined to not

  • 0

I am currently trying to debug a program, which is rather determined to not run. I guess the mistake is rather simple, I am really new to c++ and using cmake.

Here is the error message:

Scanning dependencies of target viewer

[ 25%] Building CXX object CMakeFiles/viewer.dir/Main.cpp.o
[ 50%] Building CXX object CMakeFiles/viewer.dir/TriangleMesh.cpp.o
[ 75%] Building CXX object CMakeFiles/viewer.dir/Camera.cpp.o
[100%] Building CXX object CMakeFiles/viewer.dir/MainWindow.cpp.o
Linking CXX executable viewer
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mousePressed(int, int, int, int): error: undefined reference
to 'MainWindow::mouse_button'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mousePressed(int, int, int, int): error: undefined reference
to 'MainWindow::mouse_state'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::render(): error: undefined reference to 'MainWindow::cam'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::render(): error: undefined reference to 'MainWindow::mesh'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::mouse_button'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::old_y'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::old_x'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::cam'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::cam'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::mouse_button'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::old_x'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::old_y'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::mouse_button'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::mouseMove(int, int): error: undefined reference to
'MainWindow::cam'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::MainWindow(Camera*, int, char**): error: undefined reference
to 'MainWindow::old_x'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::MainWindow(Camera*, int, char**): error: undefined reference
to 'MainWindow::old_y'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::MainWindow(Camera*, int, char**): error: undefined reference
to 'MainWindow::mesh'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::MainWindow(Camera*, int, char**): error: undefined reference
to 'MainWindow::mesh'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::MainWindow(Camera*, int, char**): error: undefined reference
to 'MainWindow::mesh'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::getInstance(Camera*, int, char**): error: undefined reference
to 'MainWindow::instance'
CMakeFiles/viewer.dir/MainWindow.cpp.o:MainWindow.cpp:function
MainWindow::getInstance(Camera*, int, char**): error: undefined reference
to 'MainWindow::instance'
collect2: ld returned 1 exit status
make[2]: *** [viewer] Error 1
make[1]: *** [CMakeFiles/viewer.dir/all] Error 2
make: *** [all] Error 2 

So, the code compiles just fine, it just cannot really link one of the 4 source files..

Edit:

Here is the gist of MainWindow.hpp

class MainWindow
{
        private:
                MainWindow() {}
                MainWindow(const MainWindow&) {}
                MainWindow(Camera *cam, int argc, char* argv[]);
                static MainWindow *instance;
                static Camera *cam;
                static TriangleMesh mesh;
                static int old_x;
                static int old_y;
                static int mouse_button;
                static int mouse_state;
                static void mousePressed(int button, int state, int x, int y);
                static void initGlut(int argc, char* argv[]);
                static void initCallbacks();
                static void render();
                static void reshape(int w, int h);
                static void keyPressed(unsigned char key, int x, int y);
                static void mouseMove(int x, int y);

        public:
                static MainWindow* getInstance(Camera *cam, int argc, char* argv[]);
                static void setCamera(Camera* cam);
                static void setMesh(TriangleMesh* mesh);
                static void destroy();
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:43:32+00:00Added an answer on June 14, 2026 at 11:43 am

    If you have static member variables, they need to be defined as well, not only declared:

    In a header file:

    class Foo
    {
        ...
    
        // This declares a static member variable
        static int static_member_variable;
    
        ...
    };
    

    In a source file:

    // This defines the variable
    int Foo::static_member_variable;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to build a simple component which should monitor, if the user
I'm trying to debug a program which crashes. In normal circumstances, when the program
I'm currently trying to debug a piece of simple code and wish to see
How to disable qt creator from auto building when trying to debug? Currently when
I'm currently trying out Aptana Studio 3 for PHP development (I'm pretty new to
I'm currently trying this: using DocumentFormat.OpenXml.Packaging; using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(fileNameDocx as string, true))
I am trying to find leaks in my program, which is a framework based
I'm currently trying to run MSTest.exe from NCover, but I believe the question could
I have a very persistent problem, im trying to debug the program through the
I'm currently working on a program using MFC. The current third party function starts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.