Ask coding questions

← Back to all posts
Linker exit code 1
Nintenerd7 (0)

i was programming and once i elimated all errors except for one can you tell me what it is so i can fix it.

the console is showing this message: clang version 7.0.0-3~ubuntu0.18.04.1 (tags/RELEASE_700/final)
 clang++-7 -pthread -o main Game.cpp main.cpp
/tmp/main-92a71b.o: In function menu()': main.cpp:(.text+0x0): multiple definition ofmenu()'
/tmp/Game-9970b6.o:Game.cpp:(.text+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
compiler exit status 1

Commentshotnewtop
mwilki7 (418)

I took a look at
https://stackoverflow.com/questions/249701/why-arent-my-compile-guards-preventing-multiple-definition-inclusions
and it seems the linker doesn't like it when you define stuff in places that have multiple inclusions.

I changed
functions.h

void menu()
{

}

to
functions.h

extern void menu();

and added a file:
functions.c

#include "functions.h"
void menu()
{

}

https://repl.it/@mwilki7/wild-battle-encounter

Nintenerd7 (0)

@mwilki7 awesome! thanks for resolving it.