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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:15:56+00:00 2026-06-16T18:15:56+00:00

I have a multiple definition error in Eclipse when trying to include a file

  • 0

I have a “multiple definition” error in Eclipse when trying to include a file called sniffer.h.

sniffer.h:

#ifndef SNIFFER_H_
#define SNIFFER_H_
#include "sys/types.h"
#include "sys/socket.h"
#include "netinet/in.h"
#include "netdb.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <queue>
#include <pthread.h>
#include <sys/timeb.h>
#include <map>
#include <algorithm>
#include <math.h>
#include <syslog.h>
#include <signal.h>
#include <asm-generic/errno-base.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
//Syslog libraries.
#include <sys/wait.h>
#include <ctime>
using namespace std;


string gconfigfilename = "config";          //Holds the config file name, dynamic     because of the add_interface option.
int pipehandler;                            //pipe handler for     the pipe that the gulp writes to
string pipeFullName;                        //absolute path for the pipe that the gulp writes to
FILE* pipe_fd;

And it has the statements of all the functions in sniffer.cpp:

#include "../h/sniffer.h"

     void OpenPipeRead(/*string sinterface*/)
{
    int ret_val;
    pipeFullName = "";
    pipeFullName.append(mconfig[C_PIPEPATH]);
    //Its not empty only when there is argument for parallal telepath_sniff instances.
    pipeFullName.append(mconfig[C_PIPENAME]);
    //if(strcmp(sinterface.c_str(), "") != 0)
    //  lpipename.append("_" + sinterface);     
    printf("Try to open Pipe for reading\n");
    syslog(LOG_INFO, "Try to open Pipe for reading\n"); 
    /* Create the named - pipe */
    ret_val = mkfifo(pipeFullName.c_str(), 0666);
    if ((ret_val == -1) && (errno != EEXIST)) {
        perror("Error creating the pipe");
        syslog(LOG_ERR, "Error creating the pipe");         
        exit(1);
    }       
    if((pipehandler = open(pipeFullName.c_str(), O_RDWR)) < 1)      /* Open the pipe for reading and writing , in append mode */
    {
       perror("Failed to open pipe");
       syslog(LOG_ERR, "Failed to open pipe");
       exit(1);
    }
    printf("Pipe opened.\n");
    syslog(LOG_INFO, "Pipe opened.\n");
}

However in the first function it says that pipeFullName has multiple definitions again.

I only included it once and the string is defined in sniffer.h.

  • 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-16T18:15:57+00:00Added an answer on June 16, 2026 at 6:15 pm

    You should not include .cpp file!!!

    In doing so you end up violating the One definition Rule.

    The usual way is to place declarations in header files and definitions in cpp files.
    You can declare something as many times as you want but define it only once.

    So you should be including header files only. if you include a cpp file, a copy of definition of symbols in the cpp file get added to every translation unit where you include the header file thus violating the ODR.

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

Sidebar

Related Questions

I have the file long_arithm.cpp: #ifndef LONG_ARITHM.CPP #define LONG_ARITHM.CPP #include <iostream> #include <list> namespace
I have this error: permute_append.o: In function `CISP430_A5::charList_join(char const*, CISP430_A5::linked_list<char>)': permute_append.cpp:(.text+0x0): multiple definition of
I have a strange multiple definitions error in my project. I'm using the #ifndef
I have to use an external library, but am getting a multiple definition error
I am getting the following error: Multiple definition of `main' I have created a
I have a 2 modules (.c files) and one .h header file: file1.c: #include
i have this files: //Q2a.h #ifndef Q2A_H #define Q2A_H inline int MyFactorial(int a) {
...../PluginLoader.h:34: multiple definition of 'Dummy_Func_For_Generating_FUNCTION_NAME_Macro()' The above error is output for the below code.
I have a header file A.h in which i define a const int ID
I have a very simple print program called print.c: #include <stdio.h> int main(void){ printf(Random

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.