Fatal error LNK1169: find one or more multi-definition symbols

Source: Internet
Author: User

Declare global variables, the global function must be declared in the CPP, the other class refers to the global variable to include the CPP h file, and then an extern. Otherwise, the duplicate definition error is prone to occur.

How does this "easy" explain it?

For example, if a global variable is declared in A.h

int Global;

In the B.h

" A.h " ..... extern int Global, ... ..

Then you include A.h equivalent to the declaration of global variables in A.h also included, the compiler will be considered a duplicate definition.

So global variables and function declarations must be in CPP, and when a function is implemented in the. h file, the VS compiler reports this error.


Workaround
1. Add inline before the function declaration in. h
2. Add/force in the additional options, command line, link, properties----

The above is loaded from David_hu.

I also encountered this error, but the whole project contains too many files, bad analysis contains the relationship, but the problem should be similar.

My solution is to:

Item –> Properties –> linker –> command line –> additional options add/force

It solved the error, but there was a bunch of warning.

Fatal error LNK1169: find one or more multi-definition symbols

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.