codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

error LNK2019: unresolved external symbol referenced in function main


By : , Category : c++

extern "C" implies a leading underscore (c-style function naming). Just prefix your function in .asm file and it'll start linking.

UPD: if your project does not build, be sure, you included MASM build customizations: go to project Context Menu -> Build Customizations... -> check the tickbox for masm (.targets, .props).

Then go to properties of you .asm file and select Item Type as 'Microsoft Macro Assembler'.

ReLated :
if(main = 1)
{   //^^should be ==, same as the one below
    c.EmployeeMenu();
}
else if(main = 2)
{
    b.CustomerMenu();
}

Member functions should be defined with scope resolution operator:

int CustomerMenu()

should be:

int Customer::ustomerMenu()

Minor point:

class employee:store

Here you used private inheritance, you really need to think about whether you need it or not.

Most likely cause is that you're not linking in the object created from Agent.cpp.

You should check to ensure that it's part of the project and that you're using the correct version, compiled with this current compiler as well (since you state you haven't touched it in a while, it may be that the objects were built with an earlier compiler version, potentially making them incompatible - different name mangling methods, for example).

The first thing to try (once you've established all correct files are in the project) is a full clean-and-build.

On a few other points:

  1. The error is occurring in World::processMouse meaning that the source for GLView::processMouse is probably irrelevant.

  2. I find your mixing of printf and cout slightly ... disturbing. You should probably avoid printf for serious C++ programming. It works, but it's mostly intended for legacy C support.

The main function must be in the global namespace. C++ is not C#/Java where all functions must be inside classes.

Linker errors are generated due to how c++ and many other similar languages compile and link code. The compiler generates object files (*.obj) and only requires function declarations in order to compile code that calls these functions- that's why forward declarations and header files work. After compilation, at link time, the linker looks for the definitions of these functions in compiled files (usually in object files (*.obj) or libraries (*.lib). A linker error saying "Unresolved external symbol" means a declaration without matching definition has been used. Most often this is because of a spelling error in the declaration or definition, or because the file containing the definition was never linked.

Long story short, you are missing a reference to a library. That might be libcmt.lib for release and libcmtd.lib for debug.

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .