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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:40:42+00:00 2026-06-13T12:40:42+00:00

Hi I am just starting to learn C++. I bought this big C++ for

  • 0

Hi I am just starting to learn C++. I bought this big C++ for Dummies book and have been going through it. Its been really interesting so far but now I am stuck. I have been googling this problem, but to no avail. I am using I am using codeblocks 10.05 with GNU GCC.

I keep getting an error that says:

In function 'main':
undefined reference to 'SafeCracker(int)'

The code isn’t complicated. I am just new and am extremely frustrated. I don’t want to skip over this part; I want to know what is going on.

Main:

#include <iostream>
#include "safestuff.h"

using namespace std;

int main()
{
  cout << "Surprise, surprise!" << endl;
  cout << "The combination is (once again)" << endl;
  cout << SafeCracker(12) << endl;
  return 0;
}

Function:

#include <iostream>

using namespace std;

string SafeCracker(int SafeID)
{
    return "13-26-16";
}

Header:

using namespace std;

#ifndef SAFESTUFF_H_INCLUDED
#define SAFESTUFF_H_INCLUDED

 string SafeCracker(int SafeID);

#endif // SAFESTUFF_H_INCLUDED
  • 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-13T12:40:42+00:00Added an answer on June 13, 2026 at 12:40 pm

    You are not compiling the second file you listed along with the first one. Try compiling directly with gcc to understand this.

    assuming your files are named:

    • main.cpp
    • SafeCracker.cpp
    • safestuff.h

    This is what you are doing

    gcc main.cpp

    While you should be doing this

    gcc main.cpp SafeCracker.cpp

    Also, SafeCracker.cpp should be including the header file as well, just for clarity. Any reasons why you have them separated?

    On another note, from seeing Daniel Hu’s answer, <iostream> is automatically including <string> for you. You should not depend on this functionality, and should instead include <string> in each file that uses strings.

    (From comment below)
    You’re probably trying to build your main.cpp as a stand-alone file. This will leave SafeCracker.cpp uncompiled. What you need is create a project in Codeblocks and add all three files to it (both *.cpp files as well as the *.h file).

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

Sidebar

Related Questions

im just starting to learn about sockets and i have been given this code,
I am just starting to learn OpenGL today from this tutorial: http://openglbook.com/the-book/ I got
I am just starting to learn how to use RMI, and I have a
I'm just starting to learn AspectJ, and I have use-case for say, User login.
I'm just starting to learn haskell. I have custom class class MyClass a where
I'm just starting to learn more advanced SQL along with PHP and I'm really
Hi just starting to learn this language, more of a javascript/PHP guy... I can't
I am just starting to learn Python, but I have already run into some
I'm just starting to learn Drupal , and I am really liking it. What
Just starting to learn scala for a new project. Have got to the point

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.