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

  • Home
  • SEARCH
  • 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 6987523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:56:55+00:00 2026-05-27T18:56:55+00:00

I have a strange multiple definitions error in my project. I’m using the #ifndef

  • 0

I have a strange multiple definitions error in my project.
I’m using the #ifndef preprocessor command to avoid including the same file multiple times. I cleared all other code. Here are my simplified files:

1 – main.cpp

#include "IP.hpp"

int main()
{
    return 0;
}

2 – IP.cpp

#include "IP.hpp"

//some codes!

3 – IP.hpp

#ifndef IP_HPP_INCLUDED
#define IP_HPP_INCLUDED

unsigned char LUTColor[2];

#endif // IP_HPP_INCLUDED

Using codeblocks & gnu gcc in win7, it says:

obj\Debug\main.o:C:\Users\aaa\Documents\prg\ct3\main.cpp|4|first defined here|

||=== Build finished: 1 errors, 0 warnings ===|

Before I deleted all of the other code, the error was:

||=== edgetest, Debug ===|

obj\Debug\IP.o||In function `Z9getHSVLUTPA256_A256_12colorSpace3b’:|

c:\program files\codeblocks\mingw\bin..\lib\gcc\mingw32\4.4.1\include\c++\exception|62|multiple definition of `LUTColor’|

obj\Debug\main.o:C:\Users\aaa\Documents\prg\edgetest\main.cpp|31|first defined here|

||=== Build finished: 2 errors, 0 warnings ===|

And ‘LUTColor’ is in IP.hpp !

What’s wrong?

  • 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-27T18:56:56+00:00Added an answer on May 27, 2026 at 6:56 pm

    The problem is in the header – you need:

    #ifndef IP_HPP_INCLUDED
    #define IP_HPP_INCLUDED
    
    extern unsigned char LUTColor[2]; // Declare the variable
    
    #endif // IP_HPP_INCLUDED
    
    • Do not define variables in headers!

    You also need to nominate a source file to define LUTColor (IP.cpp is the obvious place).

    See also: What are extern variables in C, most of which applies to C++ as well as C.

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

Sidebar

Related Questions

I have a very strange error using NSMutableArray in cocos2d/xcode In my code, I
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
I have this strange issue with my web app. You see, I'm using jQuery
I have strange issue. My application have multiple activitys, on one activity is setting
I have the strange aversion to passing in multiple ID parameters to a single
I have the following query. What is strange is that it is returning multiple
I have run into a strange to me problem. For some reason multiple ||
I have a strange problem when deleteting records using linq, my suspicion is that
I have a strange problem in my ASP.Net 3.5 application. When multiple users try
I have multiple buttons, each having a 32x32 pixels PNG image. The strange thing

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.