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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:15:33+00:00 2026-05-30T11:15:33+00:00

I have the following .h and .cpp files If i have to I will

  • 0

I have the following .h and .cpp files

If i have to I will include the full codes of the function definitions

When i compile my program i get the errors shown at the end

hash.h

    #define BUCKETS 64
       #define B_ENTRIES 50000
       int curr_tanker;
       typedef unsigned long int ulong;
typedef struct bucket
{
    int bucket_id;
    ulong bucket_entries;
}bucket;

typedef struct tanker_record
{
    ulong tanker_id;
    ulong tanker_size;
    ulong num_of_entries;
    ulong bucket_entry_count;
   }tanker_record;
typedef struct fpinfo
{ 
    unsigned long chunk_offset;
    unsigned long chunk_length;
    unsigned char fing_print[33];

}fpinfo;

struct fpinfo* InitHTable(fpinfo *);
int CreateTanker(tanker_record tr[]);
int Hash_CreateEntry(struct fpinfo *,struct fpinfo he,tanker_record tr);

ht.cpp

#include <stdlib.h>
#include <string.h>
#include<stdio.h>
#include <iostream>

#include "ht.h"

struct fpinfo* InitHTable(struct fpinfo ht[][B_ENTRIES])
{
}
int CreateTanker(tanker_record tr[])
{
}
int
Hash_CreateEntry(struct fpinfo *t[][B_ENTRIES],struct fpinfo he,tanker_record tr[])
{
}
static void
WriteHTtoFile(struct fpinfo *t[][B_ENTRIES],int this_tanker)
{
}

main.cpp

#include<iostream>
#include"ht.cpp"
#include<conio.h>
#include<stdlib.h>

void main(int argc, char **argv)
{
static fpinfo hash_table[BUCKETS][B_ENTRIES];
static tanker_record tr[100];
InitHTable(&hash_table[0][0]);
CreateTanker(tr);
struct fpinfo fp;
... 
ar = Hash_CreateEntry(&hash_table[0][0], fp,tr[0]);

i get the following errors when i try to compile it using vc2010

1>main.obj : error LNK2005: “struct fpinfo * __cdecl InitHTable(struct fpinfo (* const)[50000])” (?InitHTable@@YAPAUfpinfo@@QAY0MDFA@U1@@Z) already defined in ht.obj

1>main.obj : error LNK2005: “int __cdecl CreateTanker(struct tanker_record * const)”
(?CreateTanker@@YAHQAUtanker_record@@@Z) already defined in ht.obj

1>main.obj : error LNK2005: “int __cdecl Hash_CreateEntry(struct fpinfo * (* const)[50000],struct fpinfo,struct tanker_record * const)” (?Hash_CreateEntry@@YAHQAY0MDFA@PAUfpinfo@@U1@QAUtanker_record@@@Z) already defined in ht.obj
1>main.obj : error LNK2005: “int curr_tanker” (?curr_tanker@@3HA) already defined in ht.obj
1>main.obj : error LNK2019: unresolved external symbol “int __cdecl Hash_CreateEntry(struct fpinfo *,struct fpinfo,struct tanker_record)”
(?Hash_CreateEntry@@YAHPAUfpinfo@@U1@Utanker_record@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol “struct fpinfo * __cdecl InitHTable(struct fpinfo *)” (?InitHTable@@YAPAUfpinfo@@PAU1@@Z) referenced in function _main

THANKS FOR YOUR HELP!!

  • 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-30T11:15:35+00:00Added an answer on May 30, 2026 at 11:15 am

    You’re including ht.cpp from main.cpp, which will include all the definitions of functions already defined in ht.cpp itself.

    You want to include ht.h instead.

    It won’t help in this situation, but you should also protect the header file with include guards:

    #ifndef HT_H
    #define HT_H
    
    // contents of ht.h
    
    #endif
    

    You also need the arguments of the function declarations to match those of the definitions:

    struct fpinfo* InitHTable(struct fpinfo[][B_ENTRIES]);
    // Missing:                              ^^^^^^^^^^^
    
    int CreateTanker(tanker_record tr[]); // OK
    
    int Hash_CreateEntry(struct fpinfo*[][B_ENTRIES],struct fpinfo,tanker_record[]);
    // Missing                         ^^^^^^^^^^^^^                            ^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code will cause compile errors in g++4.4: // File test.cpp namespace A
Assume the following scenario. I have two files A.cpp and B.cpp in trunk. At
Static variable has file scope. Say I have two following files: file1.h file1.cpp file2.h
I'm working with a large library of files, and have one .cpp to compile.
I have the following CPP code snippet and the associated error message: Code snippet
In a makefile, I have the following line: helper.cpp: dtds.h Which ensures that helper.cpp
Right now I have the following in my .vimrc : au BufWritePost *.c,*.cpp,*.h !ctags
I have a CPP source file that uses #if / #endif to compile out
I have built a simple GUI application in QtCreator-2.0.1 i have following files: first.pro
HI, I have some questions about .h files and .cpp files in c++/linux(ubuntu). It

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.