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 8024217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:48:07+00:00 2026-06-04T22:48:07+00:00

I am quite new to linux development, and having trouble using a class from

  • 0

I am quite new to linux development, and having trouble using a class from a separate file in my main. The error I am getting when making (after having created makefile with cmake) is that system does not name a type, I think the code in system class is correct as if I compile without attempting to create an object of the system class I have no errors, so I think it may be to do with the way I have written the CMakeLists.txt file.

This is my CMakeLists file:

    cmake_minimum_required (VERSION 2.6)
    project (GL_PROJECT)

    add_library(system system.cpp)

    include_directories(${GL_PROJECT_SOURCE_DIR})
    link_directories(${GL_PROJECT_BINARY_DIR})

      find_package(X11)

      if(NOT X11_FOUND)
        message(FATAL_ERROR "Failed to find X11")
      endif(NOT X11_FOUND)

       find_package(OpenGL)
      if(NOT OPENGL_FOUND)
        message(FATAL_ERROR "Failed to find opengl")
      endif(NOT OPENGL_FOUND)

    set(CORELIBS ${OPENGL_LIBRARY} ${X11_LIBRARY})

    add_executable(mainEx main.cpp system.cpp)

    target_link_libraries(mainEx ${CORELIBS} system)

I have in the source directory my main.cpp, system.h (class definition) and system.cpp (class implementation)

In main:

      #include"system.h"


      system sys;

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

      while(1) 
        {
            sys.Run();
        }

      }

X11 and GL includes etc are in system.h, I think the code in there is correct and not causing the error (as it builds fine if i dont try and create an instance of the class). I have omitted the actual header and implementation for brevity in the hope that it will be an obvious error in the CMakeList file, but if necessary I can add these too?

Any ideas?

Thanks in advance.

EDIT: Here are the errors in terminal

    [tims@localhost build]$ make
    Scanning dependencies of target system
    [ 33%] Building CXX object CMakeFiles/system.dir/system.cpp.o
    Linking CXX static library libsystem.a
    [ 33%] Built target system
    Scanning dependencies of target mainEx
    [ 66%] Building CXX object CMakeFiles/mainEx.dir/main.cpp.o
    /home/tims/Code/GL_Project/main.cpp:5:1: error: ‘system’ does not name a type
    /home/tims/Code/GL_Project/main.cpp: In function ‘int main(int, char**)’:
    /home/tims/Code/GL_Project/main.cpp:11:3: error: ‘sys’ was not declared in this scope
    make[2]: *** [CMakeFiles/mainEx.dir/main.cpp.o] Error 1
    make[1]: *** [CMakeFiles/mainEx.dir/all] Error 2
    make: *** [all] Error 2

Edit 2: system.h

    #include<stdio.h>
    #include<stdlib.h>
    #include<X11/X.h>
    #include<X11/Xlib.h>
    #include <GL/gl.h>           
    #include <GL/glx.h>                                                                
    #include <GL/glu.h>    

    class system {
    public:
        system(void);

        ~system(void);

        void CreateGLXWindow();

        void Run();

        //Contains information about X server we will be communicating with 
        Display *display;

    XEvent xEvent;

    //Window instance
    Window rootWindow;
    XVisualInfo *xVisInfo;
    XSetWindowAttributes setWindAttrs;
    XWindowAttributes xWindAttrs;

    //GL 
    GLXContext context;
    Colormap  cmap;

    Window window;
private:

};
  • 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-04T22:48:09+00:00Added an answer on June 4, 2026 at 10:48 pm

    The class name system clashes with the int system(const char*) function, declared in stdlib.h, which is included by your system.h. You either need to rename the system class or move it into a namespace, because a class and a function can’t have the same name in C++.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to linux kernel programming, and for quite a long time I'm trying
Still quite new to Haskell.. I want to read the contents of a file,
I'm quite new to javascript, so maybe it's a silly error. I created an
I'm quite new to Android programming but familiar with C/C++ and Linux enough to
Im quite new in Scala. I need to get the parametrization of a class.
I am quite new to the embedded linux programming and did not really understand
Okay, I'm reading about Linux kernel development and there are some code snippets using
I'm quite new to programming for Linux. You could say I'm a Windows guy.
Quite new to maven here so let me explain first what I am trying
Im quite new to doctrine2. I need to make a connection like this: Tag

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.