troubleshooting Question

Multiple Definition in build process

Avatar of goloap
goloap asked on
15 Comments1 Solution876 ViewsLast Modified:

I'm having a strange problem with a makefile. I have multiple files that include a .h file which includes another .h file. During compilation, each c file is compiled separately using the "-c" flag. Even so, i get a multiple definition of all the function defined in the second .h file during linking. This is the structure of the program:

#ifndef _foo_
#define _foo_

<some variable declaration>
#include "bar.h"


#ifndef _bar_
#define _bar_

<some definition of inline functions>

#include foo.h

#include foo.h

I don't get why it shouldn't work since it works fine when compiling with Visual C 8, but I want to use GCC to compile it now and it won't work.

Any help would be appreciated.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros