-2

I have no idea what's wrong with my code. I have include guards in all my header files. Since there is quite some code and I'd like to keep it private the question is rather how I'd go about solving these errors.

Error 1 error LNK2001: unresolved external symbol "public: static class std::_Generic_error_category std::_Error_objects::_Generic_object" (?_Generic_object@?$_Error_objects@H@std@@2V_Generic_error_category@2@A)

Error 9 error LNK2011: precompiled object not linked in; image may not run

Error 10 error LNK2019: unresolved external symbol "void __cdecl myVars::setNumofp(int *)" (?setNumofp@myVars@@YAXPAH@Z) referenced in function _main

Community
  • 1
  • 1
  • Please check that you are including your binary files on the -L flag, not just the -I for the headers. – Marco Aurelio Apr 07 '15 at 00:03
  • 1
    Have you checked out [What is an undefined/unresolved external symbol?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) Is there a reason why this should not be closed as a duplicate of that question? – Jonathan Leffler Apr 07 '15 at 00:22
  • Marco: -L flag? No idea what this is. Jonathan: – user-1289389812839 Apr 07 '15 at 00:27
  • The question I referenced is the canonical C++ Q&A for issues related to "unresolved external symbol" errors. The answer is almost certainly there. I'm carefully not wielding Mjölnir -- that is, I'm not forcibly closing this question as a duplicate of that -- waiting for you to tell me which aspect of your question is unique and not covered there. The LNK2019 error looks like you haven't defined one of the functions you declared in your `myVars` class. I'm not sure about the other two; I don't work on Windows. Note that we probably need to know the command line you're using to link your code. – Jonathan Leffler Apr 07 '15 at 00:31
  • Jonathan: Yes I have googled this problem, both the LNK codes and unresolved external symbol separately and together. Well, I feel no matter how much research I do on the subject (been trying to figure this one out for at least 5 good hours) I still don't come any closer to finding a solution. Maybe there's a specific solution for when these three linker errors appear together, what do I know? If mod/whoever checks these things feels this is a duplicate, please refer to another thread with the same issues. Also: myVars is a namespace if that matters – user-1289389812839 Apr 07 '15 at 00:35
  • Since it's not closed yet and I was under influence at the time of writing this, I'm going ahead to tell you that I have in func.cpp defined all functions. Then in func.h I've got the declarations of the functions. The decs are not red and the IDE recognizes them up until compilation time. func.h is included in stdafx.h, but I have to put it in the main.cpp too, otherwise the IDE won't recognize the classes I created – user-1289389812839 Apr 07 '15 at 15:32
  • I faced the same problem when switching from VS2010 to VS2012 - seems like there is a difference in pre-compiled header handling and in VS2012 you need to include the OBJ files of the PCH into your compilation – Philip Helger Feb 10 '17 at 06:11

1 Answers1

0

So since I didn't find my mistake I merged the two .cpp files, and it now works. However, it annoys me that I could not make it work in two separate .cpp files.