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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:51:15+00:00 2026-05-20T18:51:15+00:00

I apologize if this has been answered, I’ve searched for some time and could

  • 0

I apologize if this has been answered, I’ve searched for some time and could not find a straight answer.

I’m used to windows visual c++ where I use a header file (*.h) for declaring classes and it’s functions and a source file (*.cpp) where the actual class’s functions are coded in detail. I am now working under Linux using Kdevelop which uses cmake. I’ve created some header files with classes in them and declared their functions and then coded the functions in their respective source files. Every time I try to build, I get errors that tells that Class::function() is an undefined reference. If I add the actual function in the header file, building works fine. So I am assuming that cmake is not linking correctly the respective source file for the header file. I was assuming that this would happen automatically, but I’m now guessing that this is not the case. How can I do that? For every header file I create, using the exact same name for the source file, have it all linked and build?

If this has been answered already, please post a link, if not, I would love a simple explanation. I understand there are many ways of doing this (autoconf, make dep, etc?) but for now I’m stuck with cmake.

  • 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-05-20T18:51:16+00:00Added an answer on May 20, 2026 at 6:51 pm

    Here is a example CMakeLists.txt for a project named Test that links two source files into an executable named test.

    cmake_minimum_required( VERSION 2.6 )
    project( Test )
    add_executable( test test.cpp testlib.cpp )
    

    if you want to add more source files just add them to the list.

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

Sidebar

Related Questions

I apologize if this has been asked before. I searched but did not find
Apologies if this has been answered before (I couldn't find the answer when I
I apologize if this has been asked and answered elsewhere. I searched and read
Apologize if this particular problem has been answered already (a search didn't turn anything
My apologies if this has been answered before or is obvious...did some searching here
I apologize if this has already been asked - I'm not certain of the
I apologize if this question has been answered elsewhere, but I couldn't seem to
Apologies if this has been answered before, but I find it very difficult to
I apologize if this question has been answered already, but I cannot seem to
Many apologies if this has been answered, but I have been unable to find

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.