Visual C++.Net: Cannot find 'stdlib.h'?

G

Guest

Hi,

I have recently installed Visual Studio .Net 2003 and am trying to compile
and run a simple windows form app (used the VS wizard). When trying to run I
get an error message telling me: "fatal error C1083: Cannot open include
file: 'stdlib.h': No such file or directory". I have browsed to C:\Program
Files\Microsoft Visual Studio .NET 2003\Vc7\include and have found the file
there.

What can be wrong? I have also tried to uninstall and reinstall.

Best regards
PÃ¥l Eilertsen
 
P

Peter van der Goes

Pål Eilertsen said:
Hi,

I have recently installed Visual Studio .Net 2003 and am trying to compile
and run a simple windows form app (used the VS wizard). When trying to run I
get an error message telling me: "fatal error C1083: Cannot open include
file: 'stdlib.h': No such file or directory". I have browsed to C:\Program
Files\Microsoft Visual Studio .NET 2003\Vc7\include and have found the file
there.

What can be wrong? I have also tried to uninstall and reinstall.

Best regards
Pål Eilertsen

Visual Studio .NET 2003 (C++) no longer supports many of the old .h headers
(Visual Studio .NET 2002 did), instead supporting the "new" standard headers
such as cstdlib. Try #include <cstdlib> in your code in place of #include
<stdlib.h>.
Hope this helps.
 
I

Ioannis Vranos

Peter said:
Visual Studio .NET 2003 (C++) no longer supports many of the old .h headers
(Visual Studio .NET 2002 did), instead supporting the "new" standard headers
such as cstdlib. Try #include <cstdlib> in your code in place of #include
<stdlib.h>.
Hope this helps.


Actually, stdlib.h (and all C90 subset header files) are part of C++98,
and stdlib.h compiles with VC++ 2003.
 
G

Guest

I have actually been able to compile now but I had to manually include the
paths to the files under project properties and additional include and lib
paths. So for this project I now can compile. But I am left with having to do
this every time and I don't want to do that. It must be some global variables
that I can change? I also have problems using third party apps that need the
compiler. I am i.e. trying to use CMake and get an error that kernel32.lib
cannot be found. I quess that this is due to the same error, and here there
are no "additional include path" to adjust. So I am stuck.

There must be someone that knows the answer to this!!

PÃ¥l
 
R

Ronald Laeremans [MSFT]

Hi,

Your setup is broken. Can you try to reinstall? These paths are definitely
on the standard paths on correct installs.

Ronald Laeremans
Visual C++ team
 
G

Guest

You know what... I have actually tried to reinstall twice, with no better
result. Isn't there soem variable that I can change?

And if I am to try and reinstall what prcautions do I need to take in order
to get it right? I also have VS 6.0 installed and C++ apps compile nicely
there.

Best regrads
PÃ¥l Eilertsen
 
P

Peter van der Goes

Ioannis Vranos said:
Actually, stdlib.h (and all C90 subset header files) are part of C++98,
and stdlib.h compiles with VC++ 2003.

My bad. I was generalizing from the iostream situation.
 
I

Ioannis Vranos

Peter said:
My bad. I was generalizing from the iostream situation.


Here is what the standard says about the C subset header files:

"D.5 Standard C library headers

For compatibility with the Standard C library, the C++ Standard library
provides the 18 C headers, as shown in Table 100:

Table 100—C Headers
__________________________________________________________________________
<assert.h> <iso646.h> <setjmp.h> <stdio.h> <wchar.h>
<ctype.h> <limits.h> <signal.h> <stdlib.h> <wctype.h>
<errno.h> <locale.h> <stdarg.h> <string.h>
<float.h> <math.h> <stddef.h> <time.h>
__________________________________________________________________________

Every C header, each of which has a name of the form name.h, behaves as
if each name placed in the Standard library namespace by the
corresponding cname header is also placed within the namespace scope
of the namespace std and is followed by an explicit using-declaration
(7.3.3).


[Example: The header <cstdlib> provides its declarations and definitions
within the namespace std.

The header <stdlib.h> makes these available also in the global
namespace, much as in the C Standard.
—end example]"



So for example the stdio.h header file of a C++ implementation, can be
implemented like this:


-- stdio.h example --

#include <cstdio>

using std::printf;
using std::scanf;
// ...

-- end of stdio.h --
 
M

Matt Osborn

We use meta projects (projects of projects) that have entirely different
directory structures. The only common directory structure is that of the
complier and SDK.

It would be so convenient if we could change the %lib% and %include% and
%path% environments as we switch meta projects.

With .NET 2003, we copy versions of "...\Local Settings\Application
Data\Microsoft\VisualStudio\7.1\VCComponents.dat" to accomplish this. it's
too bad we can't save and reuse these through the IDE.
 
R

Ronald Laeremans [MSFT]

Actually you can. If you start up the development environment with the
/useenv switch it will just use the environment of the parent (that you
could set in e.g. a batch file) and it will pick up all these variables from
there.

Ronald

Matt Osborn said:
We use meta projects (projects of projects) that have entirely different
directory structures. The only common directory structure is that of the
complier and SDK.

It would be so convenient if we could change the %lib% and %include% and
%path% environments as we switch meta projects.

With .NET 2003, we copy versions of "...\Local Settings\Application
Data\Microsoft\VisualStudio\7.1\VCComponents.dat" to accomplish this. it's
too bad we can't save and reuse these through the IDE.
 
T

Tarek Madkour [MSFT]

You know what... I have actually tried to reinstall twice, with no
better result. Isn't there soem variable that I can change?

Take a look at the build log and see which files are passed in the
include path to cl.exe. You can set the include paths to use for all
solutions from Tools.Options. Make sure the paths you want are there
(they should have been there if setup was successful).

Thanks,
 
M

Matt Osborn

Great!

I currently run a batch file that sets the environment and then starts Slick
Edit. Slick Edit starts the Visual Studio when I want need it so that
should work great.

Thanks for the tip.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top