• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

How to port C++ from Unix to Window .Net C++ system?


I need to port a large C++ system on unix (built a long time ago)
into Visual C++ on windows XP (.NET).

There are many subdirectories in that system. It can't not even
find iostream.h in Visual Studio. How  shall I do it properly?

Thanks a lot.

Jennifer Zhou
  • 3
1 Solution
Hi jfz2004,
This is actually a big topic and can be quite complex or very simple depending on your application. But to fix that issue, the easiest way is to simply do
#include <iostream>
using namespace std;

That should stop problems when using stuff from standard library.

jfz2004Author Commented:
Thanks so much. I will try that.

Do you also have some ideas on how to treat subdirectories?
Is it better to make them dlls or just  leave sub-dirs as they are?

Jennifer Zhou
jfz2004Author Commented:

I just tried using namespace std; but the compiler says:
'std' : a namespace with this name does not exist.

Did I miss anything here?


jfz2004Author Commented:
Please ignore my last post. It's my fault. I placed
"using namespace std" before #include <iostream.h>.

But in C# I always put using... at the very begining. Why is
it different here?
In standard C++, the namespace does not exist until you include a file that defines it.  Putting a 'using namespace' statement before all the headers that define the namespace results in an error.  .NET, including managed C++, has a different notion of a reference so you can put "using" statements right at the top of the source file.  A "using" statement in .NET will gice you an error if there is not a reference to the assembly defining the namespace or if the namespace does not exist in the current VS Solution.  The main system assemblies are referenced by default in a new .NET project.  Expand the "References" in Solution Explorer for one of your C# projects to see this.  You are (or should be anyway) doing a standard C++ project, however, so that does not apply.

As for the project directory structure, I'd parallel the original project as a first cut.  If the original project had libraries, make them dll's.  Otherwise, just put all the source into one VS project.  You can create a project folder - not file system folders but VS project folders - for each subdirectory to keep the project organized.  Right click on the project in Solution Explorer and do "Add -> New Folder".

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now