Solved

Problem with insert another project to current workspace

Posted on 2001-08-05
20
435 Views
Last Modified: 2013-11-20
Hello, Experts:
   I need your help urgently!

   I download a free project which build a very useful LIB and like to use it in my project A, I had tried the demo program which the author provided how to use that free porject, it runs very well, and I create a new  project B to test again, and the test was sucessful. now I am tryint to use in my project A, but I encountered a problem. my problem is :

----- problem -----
   when I insert the free project to my project B workspace, and set the dependency(my project B is dependent on the the free project), and also link the output LIB and add the free project directory to additional include directories. so I can see those Header files in free project in External dependences list of my project B.

   I did the same thing to my project A,and I ensured the the setting of project A and project B is the same.
 BUT I can not see those Header files inside free project  in External dependences list of my project A. so when I try to use a class defined in that LIB header file, even I had manual inlcude the hearder file in the project A source code, I get the error which tell me I am using a undefined class like this "d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1112) : error C2079: '$S226' uses undefined class '$S226' ... " 

----- problem -----

   what is this problem ? can somebody kindly help me to solve ? My environment is NT4.0, VC++6.0. thank you very much in advance.


-- pigangel
   
0
Comment
Question by:pigangel
  • 9
  • 6
  • 5
20 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6352902
Hi!
check your project settings ('A') it must contain path to the lib header files.
also make shure that these files has no conflict with guard defines.
Guard defines usually looks like this (in the header files)

//start *.h file
#ifndef __MYFILE_H__
#define __MYFILE_H__ 1
// rest of file
// and at the end
#endif //__MYFILE_H__

also you can determine what happens by compile *.cpp file with /P option (sets manually for file (or entire project)in the project  options dialog|compiler tab  in the compiler switches edit box at the page botom).
you get *.i file where preprocessor dumps results.
In this file you can see what include files really included in the build.
0
 

Author Comment

by:pigangel
ID: 6353563
Hi,migel:
  how should I check if the files has confiict with guard defines? I know these guard defines normally are auto-created when create a new class.

-- pigangel
0
 

Author Comment

by:pigangel
ID: 6353619
Hi,
Actually, /P option is already on for the whole project, but I cann't find out *.i files, where can I get it?

-- pigangel
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 12

Expert Comment

by:migel
ID: 6353763
Hi!
to get *.i file you must compile file where you get error.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6354013
This can happen when VC++ erroneously thinks that it does not need to recompile the precompiled header.  If that is the problem, one solution is to clean and rebuild:

Right-click each project (A, B, and the free one) and select "Clean."  Then again right-click each project and choose "Build."

If that doesn't work, you must examine *all* of the settings for the project that works, and compare them to those of the project that fails.  This is possible using the  Project Settings dialog.  

Open that dialog and select "Project A" (the one that works)  Now cycle through each items in the combobox on the C/C++ and Link tabs.  Select the category then click on "Project B" and then back on "Project A" several times.  Any differences will be easy to spot.  

Tip: If you fix something in the Debug build settings, you will also want to fix it in the Release build.

-- Dan
0
 

Author Comment

by:pigangel
ID: 6358099
Hi, Dan:
  I had tried clean and build again, but it doesn't work. I am trying to compare the project setting, will let you know the result. but my question is why VC++ sometime erroneously think that it does not need to recomplile the precompiled header?

--pigangel
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6358567
>>BUT I can not see those Header files inside free project in External dependences list of my project

If you add the .h of the Library then it will not appear in the External Dependencies list.

>>why VC++ sometime erroneously think that it does not
need to recomplile the precompiled header?

I have a theory:  I think that VC++ makes a special case for resource.h -- when modified by the ClassWizard.  Otherwise, many simple tweeks would force a rebuild of nearly every module.  You can see this in action.  If you have two CDialog-based classes (A and B), then add a new edit box (IDD_EDIT1) to dlg A, then when you rebuild the project, dlg B does not get rebuilt -- even though resource.h has clearly been modified.

That does not explain all situations, but it is enough of a clue -- if there is "special case" logic going on in one place, I'd not be surprised to see it taking place (and getting messed up) in other situations.
0
 

Author Comment

by:pigangel
ID: 6359101
Hi,Dan:
  The project setting is same, so I am getting more and more confused.
  even I did like following:
  1) Add the free.lib with the proper path eg. ..\free\debug\free.lb to project setting->Link->Input->Object/library modles.
  2) Add the free library directory eg ..\free to project setting->C++->Preprocessor->Additional include directories.

  I still get the same error, it seems the my project will never see the header file and never like to free lib. what happened in my project!

Hi, migel:
  sorry,I had misunderstood the /P option you mentioned! can you please tell me how to set this option manually? thanks.



-- pigangel
0
 
LVL 12

Expert Comment

by:migel
ID: 6359135
Hi!
press ALT+F7 on the project
select C/C++ tab look at page bottom and in the "Project option" set caret at the strings end and type /P
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6360725
>>my project will never see the header file

Right-click on the project and choose Add Files to Project.  Then drill-down and locate the .H file (c:\somedir\free\free.h)

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6375328
hi pigangel,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 

Author Comment

by:pigangel
ID: 6388148
Hello, Dan:
  I am sorry I had tried to solve another problem (please see my new posted question) after I showed my project to my client).
  I will try your latest suggestion tonight and will tell you the result.
  thank you!

-- pigangel
0
 

Author Comment

by:pigangel
ID: 6403106
Hi Dan. I tried to add those header files into my project,and I still got the same error, I totally have no idea about my project!

--pigangel
0
 
LVL 12

Expert Comment

by:migel
ID: 6403189
Hi!
can you send me your workspace Or tell me what free lib you use to emulate your problem on my compute?
my Email is: migel.geo@yahoo.com
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6403209
Look at the project that works and look at a file that uses the line

#include "free.h"

Now look just above that #include line.  There may be other #include files that you are forgeting to put into your broken project.  

Also compare the file named stdafx.h for both projects.

-- Dan
0
 

Author Comment

by:pigangel
ID: 6403222
Hi, migel:
  I tried the /P option and built the project again,
Actually in my class BackupDlg.cpp file, I included the header file of the free project which build a free LIB ( not DLL ), I look into the BackupDlg.i file, and I found that the include header file was included in project-build like following( am I right?):

--
#line 8 "d:\\src2\\backupdlg.cpp"
#line 1 "d:\\free\\free.h"
...
---

if the header file is included like this but my project still can't see it, do you think this is becasue  that the header file has conflict with guard defines? are there any ways for me to check if it has conflict with guard defines or not. please kindly give me any hints. thanks a lot.

-- pigangel  

0
 
LVL 12

Expert Comment

by:migel
ID: 6403393
Hi!
in the *.i file you must see all declarations existing in the d:\\free\\free.h
that is something like this:
#line 1 ":\\free\\free.h"

class FreeClass //and so on
{
};
...
//..rest of file
...

#line 9 "d:\\src2\\backupdlg.cpp"
if you see empty space the you have guards conflict
search where this quard can be defined in the all project files.
0
 

Author Comment

by:pigangel
ID: 6409257
Hello, migel & Dan:
  thank you very much for all your support! it's right like Dan had said, need to check the header files eg stdafx.h ...  and migel helped me to find out the place!!
  migel can you please tell me why I should include <afxtmpl.h>, for me I only know if I use some template e.g CList, I need to include it... by the way what is IMHO means?
  Thanks again, I will accept migel's as answer.


-- pigangel with (^_^)
0
 
LVL 12

Accepted Solution

by:
migel earned 250 total points
ID: 6409468
Hi!
IMHO = In my humble opinion.

you need include since ZipArchive lib used template classs:

#include <afxtempl.h>
typedef CStringArray CZipStringArray;
struct CZipFindFast;
typedef CArray<CZipFindFast, CZipFindFast> CZipFindFastArray; //in the ZipCollections

since you have include this file out of stdafx.h MS compiler doesn`t proprly find this definition in the PCH (precompiled header) file and generates error.
0
 

Author Comment

by:pigangel
ID: 6412107
Thank you very much!

-- pigangel
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 78
List out all word 7 293
dog bark java program 15 95
has22 challenge 11 95
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question