Yotam
Yotam

Reputation: 10685

c++ can't compile on linux because of a line I have deleted

I'm trying to compile my code which had a faulty line. I have deleted that line but still the compilation fail because of some ghost:

/tmp/ccaWghvE.o: In function show(lipid*)': membrane.cpp:(.text+0xf52): multiple definition ofshow(lipid*)' /tmp/ccQicBxx.o:main.cpp:(.text+0x150): first defined here collect2: ld returned 1 exit status

How can I get rid of that?

Thanks

Solved

I have used ralu tip and created anew folder and copied everything into it. Thanks

Upvotes: 2

Views: 121

Answers (3)

Alexander Gessler
Alexander Gessler

Reputation: 46617

You have a doubly defined symbol.

presumably you defined show(lipid*) in a header file and included that header file from multiple translation units. To solve this issue, declare it inline or move the definition (the actual code) to a cpp file, retaining the declaration in the header file.

Upvotes: 1

Mark B
Mark B

Reputation: 96261

You defined show(lipid*) both in main.cpp and in membrane.cpp. Either you have copies of the same function in both files or you have the function defined non-inline in a header they both include.

Upvotes: 8

AshleysBrain
AshleysBrain

Reputation: 22591

It says 'multiple definition'. You've defined something more than once. Make sure you only define it once!

Deleting the line the error is on rarely fixes the problem. That's often just the point the compiler realised something was wrong. You need to understand the error message, and correct the whole program, not just that line.

Upvotes: 1

Related Questions