How to fix linking files C++ in VS 2017(LNK2005)?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
8 views
Hi!
There is a problem in VS 2017 with an error of linking files (LNK2005), will attach screenshots for clarity.
In the project 3 files:
  • MyForm.the. h file of the form C++\\CLI, here I'm doing #include "source.cpp" that probably falls here also use the methods of interaction with the form of type openFileDialog, etc.
    spoiler
    5ae43dbb2f7b7003435962.jpeg5ae43dc33f59b774396348.jpeg
by | 8 views

1 Answer

0 like 0 dislike
1. In *.h files should only be the headers of the functions and declaring global variables.

2. *.cpp files do not write in #an include macro, Oh ( they only write *.h)*.cpp are compiled separately and then the resulting object files linkouts together into a single executable.

3. To avoid the inclusion of several times the same file, use #ifndef:
// file MyForm.h #ifndef __MYFORM__ #define __MYFORM__ // here the contents of the file #endif
by
110,608 questions
257,186 answers
0 comments
35,647 users