Making a Sample Win32 DLL project Using Visual Studio 2010 Professional
I made a Win32 DLL project I called 'Win32DLLExample'. It compiles fine, and the DLL was created in its the Debug folder. I also made a win32 executable project in Visual Studio 2010 to run and access the functions in the DLL: I find it strange, but it looks like I can only have one project open at a time. When I open the new project the
other one closes.
Is that correct, in Visual Studio 2010?
Then, when I try to compile, it doesn't work of course:
------ Build started: Project: MyWin32CppApp, Configuration: Debug Win32 ------Build started 1/30/2016 10:23:47 AM.InitializeBuildStatus: Touching "Debug\MyWin32CppApp.unsuccessfulbuild".ClCompile: Main.cppc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(6): error C2871: 'Win32CppDLLExample' : a namespace with this name does not existc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2065: 'MyWin32ClassOne' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2146: syntax error : missing ';' before identifier 'sc1'c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(13): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(13): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(14): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(14): error C2228: left of '.Setvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(15): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(15): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(17): error C2065: 'MyWin32ClassTwo' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(17): error C2146: syntax error : missing ';' before identifier 'sc2'c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(17): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(18): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(18): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(19): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(19): error C2228: left of '.Setvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(20): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(20): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''Build FAILED.Time Elapsed 00:00:01.76========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I already have additional include directories set up to cover the DLL header files: BUT!
I cannot add reference to DLL project - no projects are selectable:
So, what can I do so that it compiles?
Also, once done, how can I run the compiles program and the compiled DLL together, outside the IDE?
Thanks.
C++Visual C++.NETProgramming
Last Comment
AndyAinscow
8/22/2022 - Mon
David Johnson, CD
you are mixing up solutions and projects
a solution can consist of several projects and only 1 solution can be active at a time.
Yes you are right, once I import the the DLL project to the executable solution, I get this if I try to build:
------ Build started: Project: Win32CppDLLExample, Configuration: Debug Win32 ------Build started 1/31/2016 10:04:45 AM.InitializeBuildStatus: Creating "Debug\Win32CppDLLExample.unsuccessfulbuild" because "AlwaysCreate" was specified.ClCompile: All outputs are up-to-date.ManifestResourceCompile: All outputs are up-to-date.Link: Creating library C:\Documents and Settings\user\My Documents\Visual Studio 2010\Projects\MyWin32CppApp\Debug\Win32CppDLLExample.lib and object C:\Documents and Settings\user\My Documents\Visual Studio 2010\Projects\MyWin32CppApp\Debug\Win32CppDLLExample.expManifest: All outputs are up-to-date.LinkEmbedManifest: Win32CppDLLExample.vcxproj -> C:\Documents and Settings\user\My Documents\Visual Studio 2010\Projects\MyWin32CppApp\Debug\Win32CppDLLExample.dllFinalizeBuildStatus: Deleting file "Debug\Win32CppDLLExample.unsuccessfulbuild". Touching "Debug\Win32CppDLLExample.lastbuildstate".Build succeeded.Time Elapsed 00:00:04.09------ Build started: Project: MyWin32CppApp, Configuration: Debug Win32 ------Build started 1/31/2016 10:04:50 AM.InitializeBuildStatus: Touching "Debug\MyWin32CppApp.unsuccessfulbuild".ClCompile: Main.cppc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(6): error C2871: 'Win32CppDLLExample' : a namespace with this name does not existc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2065: 'MyWin32ClassOne' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2146: syntax error : missing ';' before identifier 'sc1'c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(13): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(13): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(14): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(14): error C2228: left of '.Setvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(15): error C2065: 'sc1' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(15): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(17): error C2065: 'MyWin32ClassTwo' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(17): error C2146: syntax error : missing ';' before identifier 'sc2'c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(17): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(18): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(18): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(19): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(19): error C2228: left of '.Setvar' must have class/struct/union type is ''unknown-type''c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(20): error C2065: 'sc2' : undeclared identifierc:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(20): error C2228: left of '.Getvar' must have class/struct/union type is ''unknown-type''Build FAILED.Time Elapsed 00:00:01.16========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
a solution can consist of several projects and only 1 solution can be active at a time.