user2019985
user2019985

Reputation:

GCC multiple definition of functions linker error

I am trying to create a makefile and was able to get all of the files to compile but it fails on the linker step. Every function in the project is getting an error where it says GCC multiple definition of 'Function Name' then claims that it was first defined in the exact same spot. For example...

project/src/provCreator.o: In function `ProcessArgs':
/home/kevin/project/src/provCreator.c:380: multiple definition of `ProcessArgs'
project/src/provCreator.o:/home/kevin/project/src/provCreator.c:380: first defined here

What are possible causes of this error and how can it be fixed?

Thank you for helping.

Upvotes: 1

Views: 5160

Answers (2)

Srikanth  P S
Srikanth P S

Reputation: 43

Any linker throws a multiple definition error while functions with the same name compiled or same function compiled multiple times due to duplicate listings in makefile. After compilation, while linking linker will be in confusion which object definition it has to link hence it throws an error.

In your case, please check your makefile, probably you might have listed provCreator.c twice.

Upvotes: 1

Alex Cohn
Alex Cohn

Reputation: 57173

Your makefile has project/src/provCreator.c file listed twice. Possibly, with different relative paths.

From your description, it seems that all c files are listed twice (ctrl-c/ctrl-v error?)

Upvotes: 2

Related Questions