I'm a new user to Visual Studio .Net, writing most of my projects in C++. I have this problem with the OO paradigm when I tried to apply it to my projects. Variables for classes which I described in eg. dXmanager.h fails to appear in my dXmanager.cpp; when I try to compiled them it just say that variable ABC is not found in dXmanager.cpp even though I have declared it in the classes in dXmanager.h. I ended up having to declare them again in dXmanager.cpp.

Secondly after I have built all the files which I needed, compiling them individually is fine with no errors. But when I tried building the whole solution there seem to be problems linking functions in my classes (in dXmanager.cpp) to the main windows program (in winmain.cpp). I kept getting the error LNK 2019 unresolved external symbol "<classname>::<functionname>" referenced in <file_name|function_name>. Is there something which I am missing here? Something which I must do to enable linking between the classes files with their header files and these classes files with the main program file?

Thanks for helping.

I'm a new user to Visual Studio .Net, writing most of my projects in C++. I have this problem with the OO paradigm when I tried to apply it to my projects. Variables for classes which I described in eg. dXmanager.h fails to appear in my dXmanager.cpp; when I try to compiled them it just say that variable ABC is not found in dXmanager.cpp even though I have declared it in the classes in dXmanager.h. I ended up having to declare them again in dXmanager.cpp.

Have you included the header file in the source file? like

#include "dxmanager.h

Secondly after I have built all the files which I needed, compiling them individually is fine with no errors. But when I tried building the whole solution there seem to be problems linking functions in my classes (in dXmanager.cpp) to the main windows program (in winmain.cpp). I kept getting the error LNK 2019 unresolved external symbol "<classname>::<functionname>" referenced in <file_name|function_name>. Is there something which I am missing here? Something which I must do to enable linking between the classes files with their header files and these classes files with the main program file?

Looks like you haven't added the necessary files to your project file. Can you see your files in the Solution Explorer Window of .NET?

Yes I have included the #include "dsmanager.h" at the beginning of both the dsmanager.cpp and the winmain.cpp. Also yes I can see all 3 files (dsmanager.h, dsmanager.cpp and winmain.cpp) in my Solution Explorer Window of .NET.

Zip your code without the debug and release folders and attach here. That will help in figuring things out.

Please find zip file attached. Thanks a lot for your help btw, anyhow it is a directx application but I doubt that should be the problem, more like how visual studio .net is handling the linkage since all files compile fine indivdually. Once again thanks!

There are two other files: dsutil.h and dsutil.cpp that are not included in the project. Dont you need them?

adding them helps reduce the number of errors from 10 to 6, the remaining 6 are still errors caused by unable to link to the functions from winmain.cpp to functions in dsmanager.h and dsmanager.cpp

Change the

void shutdownDirectSound(void)
{
...
}

function in the dsmanager.cpp file to

void dsmanager::shutdownDirectSound(void)
{
...
}

Similar for the other functions.

Oh man! It worked!! damnit! I would have hugged you if you are in the same room as me but since you aren't I shall thank you tremendously for taking time to not just look into my problem but help solve it! Cheers!

thanks a lot guys this thread solved my issue as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.