Making a Sample Win32 DLL project Using Visual Studio 2010 Professional

AttilaB
AttilaB used Ask the Experts™
on
I made a Win32 DLL project  I called 'Win32DLLExample'. It compiles fine, and the DLL was created in its the Debug folder.
The simple Win32 DLL I madeI also made a win32 executable project in Visual Studio 2010 to run and access the functions in the DLL:
Win32 Executable Project to access DLL functionsI 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.cpp
c:\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 exist
c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2065: 'MyWin32ClassOne' : undeclared identifier
c:\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 identifier
c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(13): error C2065: 'sc1' : undeclared identifier
c:\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 identifier
c:\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 identifier
c:\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 identifier
c:\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 identifier
c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(18): error C2065: 'sc2' : undeclared identifier
c:\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 identifier
c:\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 identifier
c:\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 ==========

Open in new window


I already have additional include directories set up to cover the DLL header files:
Additional Included DirectoriesBUT!
I cannot add reference to DLL project - no projects are selectable:
Cannot set reference to DLL project
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
you are mixing up solutions and projects
a solution can consist of several projects and only 1 solution can be active at a time.
Freelance programmer / Consultant
Commented:
>>I find it strange, but it looks like I can only have one project open at a time
You have two different solutions each with one project.  You can only have one solution open at once BUT a solution can contain many projects.

So import the dll project into the executable solution.

File menu - Add - existing project

Author

Commented:
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.exp
Manifest:
  All outputs are up-to-date.
LinkEmbedManifest:
  Win32CppDLLExample.vcxproj -> C:\Documents and Settings\user\My Documents\Visual Studio 2010\Projects\MyWin32CppApp\Debug\Win32CppDLLExample.dll
FinalizeBuildStatus:
  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.cpp
c:\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 exist
c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(12): error C2065: 'MyWin32ClassOne' : undeclared identifier
c:\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 identifier
c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(13): error C2065: 'sc1' : undeclared identifier
c:\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 identifier
c:\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 identifier
c:\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 identifier
c:\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 identifier
c:\documents and settings\user\my documents\visual studio 2010\projects\mywin32cppapp\mywin32cppapp\main.cpp(18): error C2065: 'sc2' : undeclared identifier
c:\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 identifier
c:\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 identifier
c:\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 ==========

Open in new window


Some sort of namespace  problem?  I don't know how I would resolve it.

Now I have the 2 projects together:
Build problem
AndyAinscowFreelance programmer / Consultant

Commented:
This is now a totally different problem.
Please close this question and ask another.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial