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

The Archive Base Latest Questions

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

So my program is working fine. Compiling, linking, running, the works. Then, I decide

  • 0

So my program is working fine. Compiling, linking, running, the works. Then, I decide to add a simple function to one of my files, like this:

#ifndef UTILITY_HPP
#define UTILITY_HPP

/* #includes here.  There's no circular include, I've checked. */

namespace yarl
{
    namespace utility
    {
        (several function declarations and definitions)

        bool isVowel(const char c)
        {
            if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
                return true;
            else return false;
        }
    }
}

#endif

That function definition is the only change I’ve made to my code. Everything else is exactly the same as it was. Nothing calls it yet. I compile, and it fails to link, with g++ giving one of these errors for every file that #includes this one:

./obj/Feature.o: In function `yarl::utility::isVowel(char)':
/home/max/Desktop/Development/Yarl Backup/yarl v0.27/src/Utility.hpp:130: multiple     definition of `yarl::utility::isVowel(char)'
./obj/Events.o:/home/max/Desktop/Development/Yarl Backup/yarl v0.27/src    /Utility.hpp:130: first defined here
./obj/GameData.o: In function `yarl::utility::isVowel(char)':

If I comment out isVowel, it works again. I’ve tried renaming it, still doesn’t work. I’ve tried replacing it with just void randomFunctionName() {}, still doesn’t work. I’ve tried making it non-inline and putting the function body in Utility.cpp, still doesn’t work. I am extremely confused. Why would adding one simple function screw up the linker?

  • 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-15T12:33:07+00:00Added an answer on May 15, 2026 at 12:33 pm

    Either declare the function inline, or define it in a separate .cpp file. Otherwise every C++ file in which you include the header is trying to make its own, publicly-available definition of the function.

    Edit: and fwiw, you don’t need to explicitly return true or false if you’re testing a conditional. Just return the conditional itself:

    inline bool isVowel(const char c)
    {
        return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a socket program and everything seems fine when compiling. First I
My MS Visual C# program was compiling and running just fine. I close MS
Everything was working fine in this program I've been writing, and then out of
I am using Junit 4. My whole program is working fine. I am trying
I'm trying to get a simple winsock program working, so I create my socket
I'm using Visual studio c++ 2010. My program was working fine until I linked
I have created a sample Hello World program in android it was working fine
I have recently created a disk catalog program for myself, it is working fine.
I'm tring to setup a little chat program in python. Everything was working fine
The project was doing fine, running fine, compiling fine. Until some seemingly random time

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.