Home c++ Error Error LNK2005

Error Error LNK2005

Author

Date

Category

wrote a program that takes data from the site and displays them to DataGridView, everything works when one form. But when I added a second form to open in it increased mistakes:

Type: Error Error LNK2005


Answer 1, Authority 100%

You were brilliantly demonstrated how no questions should be asked. No useful information, not quite the corresponding tag, does not even specify the compiler, the whole bunch of your files is drawn …

judging by what lnk2005 , you managed, for example, double-described one And the same function – adding this second form. As a result, there are two functions with the same name, and the linker does not know what to choose.

Here is the official opinion of MS 🙂 why this happens and what to do. Allow me and I ask you a question: What happened to you here?
(Because to believe that a person did not try to deal with the problem itself, and did not seek the decision on the official website of the compiler, and I just didn’t go to So – I just can’t. Programmers do not do this :))

So:

  1. Mixing static and dynamic libraries while using / CLR.

  2. The character is a packaged function (created by compiling with the / GY parameter) and was included in more than one file, but is changed in the interval between compilations. Recompline all files including SYMBOL.

  3. The character is defined differently in two member objects in various libraries, and both member objects are used.

  4. The absolute value is defined twice with different values.

  5. The header file is declared and defined as a variable. Below are possible solutions.

    Announce a variable in the H-file: Extern Bool Mybool;, and then assign a value in a C-file or CPP file: BOOL MyBool = False;.

    Announce a variable as static.

    Announce a variable as selectany.

  6. You use uuid.lib in combination with other LIB files that define the GUID identifiers (for example OLEDB.LIB and adsiid.lib).

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions