Avatar of AttilaB
AttilaB
 asked on

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.
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.
C++Visual C++.NETProgramming

Avatar of undefined
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.
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AttilaB

ASKER
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
AndyAinscow

This is now a totally different problem.
Please close this question and ask another.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes