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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:24:22+00:00 2026-06-14T13:24:22+00:00

I’m working on a multiple file project in C++ that gives me linker errors

  • 0

I’m working on a multiple file project in C++ that gives me linker errors and I don’t understand why. Yes, I have been searching but others all seem to have troubles with third-party libraries and -l link flags, which is not the case here. A small excerpt that should include all relevant pieces of code:

main.cpp

#include "common.h"
//...
void sort_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE], const unsigned int beg = 0, const unsigned int end = TABLE_LENGTH)
{
    //..
}
void precompute_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE])
{
    //..
    #ifdef METHOD_HELLMAN
    precompute_hellman_table(table);
    #endif
    //..
}
int main()
{
    //..
    byte table [TABLE_LENGTH][2][CIPHER_SIZE];
    precompute_table(table);
    //..
}

common.h

#ifndef COMMON_H
#define COMMON_H
//..
typedef unsigned char byte;
//..
#define METHOD_HELLMAN
#define TABLE_LENGTH 40000
#define CIPHER_SIZE 2
//..
void sort_table(byte[TABLE_LENGTH][2][CIPHER_SIZE]);
//..
#endif

hellman.h

#ifndef HELLMAN_H
#define HELLMAN_H

#include "common.h"

extern void precompute_hellman_table(byte[TABLE_LENGTH][2][CIPHER_SIZE]);

#endif

hellman.cpp

#include "hellman.h"
//..
void precompute_hellman_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE])
{
    //..
    sort_table(table);
}

So hellman.cpp uses a general function in main.cpp, which is forward declared in common.h. The following errors are produced when compiling/linking using MinGW:

File                                Message
obj\Release\hellman.o:hellman.cpp   undefined reference to `sort_table(unsigned char (*) [2][2])'

Why is my code incorrect?

  • 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-14T13:24:24+00:00Added an answer on June 14, 2026 at 1:24 pm

    Here’s your declaration

    // common.h
    void sort_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE]);
    

    Here’s your definition

    // main.cpp
    void sort_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE], 
        const unsigned int beg = 0, const unsigned int end = TABLE_LENGTH)
    {
        ...
    

    See the difference?

    The declaration and the definition should be the same, except the default values should be in the declaration only.

    Like this

    // common.h
    void sort_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE], 
        const unsigned int beg = 0, const unsigned int end = TABLE_LENGTH);
    

    and this

    // main.cpp
    void sort_table(byte table[TABLE_LENGTH][2][CIPHER_SIZE], 
        const unsigned int beg, const unsigned int end)
    {
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have been unable to fix a problem with Java Unicode and encoding. The

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.