• Advertisement
Sign in to follow this  

Problems building my first project after installing vc++ 2005 express

This topic is 3837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone I'm having problems building my first project after installing vc++ 2005 express. Below is a step-by-step guide to exactly what I've done, seperated into sections. I've seen similar problems in old posts but still don't really understand it. I am a complete beginner so please try to keep instructions as detailed as possible and don't assume I know anything. ________________________________________________________________________________ Go to VC++ 2005 express download page- http://msdn.microsoft.com/vstudio/express/downloads/default.aspx Step 1- Make sure you're ready Met system requirements and didn't have any previous versions of the software Step 2- Download and Install Selected English language, downloaded setup program, ran it, went through procedure installing Graphical IDE as an optional feature but not any other products, downloaded and installed Step 3- Download Additional Components Downloaded setup program for Service Pack 1, ran it, downloaded and installed ________________________________________________________________________________ Go to Microsoft Platform SDK download page- http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ Step 1 Done (see above) Step 2 Link takes me here Validated system- http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en- Downloaded PSDK-x86.exe- http://www.microsoft.com/downloads/details.aspx?FamilyID=0baf2b35-c656-4969-ace8-e4c0c0716adb&displaylang=en&Hash=EQ9UxSU%2bhNrmgXwSfaseFKzS9fsvhrc%2fviWyHJDEAPxBKnfXwN%2fcdZEUD0fv%2f0Sfx06jdKdw0iA2aSGaBVzgyQ%3d%3d Ran it, went through procedure doing typical install and installed Step 3 Open vc++ 2005 express Go tools> options, expand projects and solutions, select vc++ directories Choose show directoris for executable files, click folder button, copy and paste c:\Program Files\...\Bin (if it's not already there) Choose show directories for include files, click folder button, copy and paste c:\Program Files\...\Include (if it's not already there) Choose showe directoried for library files, click folder button, copy and paste c:\Program Files\...\Lib (if it's not already there) Click OK Step 4 Locate file, open it with notepad and insert text as required, that bit now reads: AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib" Saved and closed file Step 5 Locate file, open it with notepad and insert text as required, that bit now reads: SUPPORT_ATL.disabled = true; support_atl_title.disabled = true; SUPPORT_MFC.disabled = true; support_mfc_title.disabled = true; // WIN_APP.disabled = true; // WIN_APP_LABEL.disabled = true; // DLL_APP.disabled = true; // DLL_APP_LABEL.disabled = true; Saved and closed file ________________________________________________________________________________ In vc++ 2005 express, go file> new> project, expand win 32, click win console application, enter name 'test' and click OK Click application settings, select windows application, leave empty project unchecked (not sure if this matters) and click finish See the of this message to see how the screen looks at this point Press F5, it comes up 'This project is out of date: test- debug win32. Would you like to build it? Output box at the same time looks like this: ------ Build started: Project: test, Configuration: Debug Win32 ------ Compiling... stdafx.cpp c:\documents and settings\chris moore\my documents\visual studio 2005\projects\test\test\stdafx.h(28) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\test\test\Debug\BuildLog.htm" test - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Click yes, it comes up 'There were build errors. Would you like to continue and run the last successful build? Click yes, it comes up 'Unable to start program c:\documents and settings\chris moore\my documents\visual studio 2005\projects\test\debug\test.exe. The system could not find the file specified. Click OK What have I done wrong? What do I need to do please? Any help would be much appreciated. Kind regards, Chris Moore ________________________________________________________________________________ See below for how the screen looked after creation of new project // test.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "test.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name // Forward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_TEST, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TEST)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage are only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TEST)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TEST); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Message handler for about box. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: return (INT_PTR)TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; }

Share this post


Link to post
Share on other sites
Advertisement
You need to download and install the Windows Platform SDK
http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB

Next time...please use the [ source] [/ source] tags. Thanks.

Share this post


Link to post
Share on other sites
The fact that the IDE can't find "windows.h" suggests that you did something in Step 3 (involving the paths to the include files) incorrectly. Reverify that step.

Quote:

You need to download and install the Windows Platform SDK
http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB

Next time...please use the [ source] [/ source] tags. Thanks.

It appears that he has already downloaded and (attempted) to install the PSDK, as the instruction he says he's followed are those for acquiring and installing the SDK.

Share this post


Link to post
Share on other sites
Hi, thank you for your replies.

I checked the paths and found \'s missing after Program Files in include and library directories. I tried to create a new project, test 2. I still got the error messages 'There were build errors. Would you like to continue and run the last successful build?

But, when I click yes it seems to build OK. The output from the build is:

Compiling resources...
Compiling manifest to resources...
Linking...
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\Test 2\Test 2\Debug\BuildLog.htm"
Test 2 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

The outout from the debug is:

'Test 2.exe': Loaded 'C:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\Test 2\debug\Test 2.exe', Symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcr80d.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\Program Files\Common Files\Symantec Shared\AntiSpam\asOEHook.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\msvcr71.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\Program Files\Common Files\Symantec Shared\CCL40.DLL', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\msvcp71.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', No symbols loaded.
'Test 2.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'Test 2.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
'Test 2.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime', No symbols loaded.
The program '[144] Test 2.exe: Native' has exited with code 0 (0x0).

Is everything OK now? Why would I still be getting the first error message?
Stormtrooper, I'm not sure what you mean by please use the [ source] [/ source] tags. How would my first message have looked if I'd used them

Thanks again guys, not sure how tose paths went wrong.

Regards,
Chris Moore.

Share this post


Link to post
Share on other sites
The source tags are forum tags that surround your code in a white scrollable
box:


Long segments of code in here.

Notice how your code is both color coded and properly...

....formatted.

These boxes also have scrollbars for long posts.





Alternatively, you can also use "code" tags for short code:

Notice how your code is...

...formatted.


When you get the message "'There were build errors. Would you like to continue and run the last successful build?", DONT click yes. Clicking yes does not
recompile your project (It uses an already built version of your project).

Looking at your output, your project is not being compilied, only its resources
are.

Instead, when you get the message, click NO. There are compilier errors,
and you should fix them. If you need help, post the output using the SOURCE
tag above. (You can edit my post to see it in action.)

Share this post


Link to post
Share on other sites
Hi, thank you for your reply.

When I created a new project, test 5, I think I got a slightly different result than last time. I still get 'This project is out of date: Test 5- Debug Win32. Would you like to build it?' I click yes.

In the output from build, I get



------ Build started: Project: Test 5, Configuration: Debug Win32 ------
Compiling...
stdafx.cpp
Compiling...
Test 5.cpp
Compiling resources...
Compiling manifest to resources...
Linking...
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\Test 5\Test 5\Debug\BuildLog.htm"
Test 5 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========




Hopefully that worked!

In the output from debug, I get



'Test 5.exe': Loaded 'C:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\Test 5\debug\Test 5.exe', Symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcr80d.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\Program Files\Common Files\Symantec Shared\AntiSpam\asOEHook.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\msvcr71.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\Program Files\Common Files\Symantec Shared\CCL40.DLL', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\msvcp71.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', No symbols loaded.
'Test 5.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'Test 5.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
'Test 5.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime', No symbols loaded.




Hopefully that worked!

When I go to close it, it appears to be still debugging.

Should I also say what's in the main box?

If I create a new project and when it comes up 'This project is out of date: Test 5- Debug Win32. Would you like to build it?' I choose no, I again get the error message 'Unable to start program c:\documents and settings\chris moore\my documents\visual studio 2005\projects\test\debug\test6.exe.'

Thanks again guys, hopefully I can get this sorted soon.

Regards,
Chris.

Share this post


Link to post
Share on other sites
Well, from your last post it appears that your program compiled correctly. I'm not sure how you know it 'still appears to be debuggin' after you close the program. This is a windows program, and if you don't do things correctly the program Can continue to run even when you 'close it' . So, to stop debugging enter the debug menu and select the 'stop debugging' option, or 'halt' or something that will stop the program. Actually, to be really sure the program is still running check out the list of processes running (CTRL+ALT+DELETE) and look for your program in the list. If not found, your program is definately running. Kill all of the process instances that are open, if any. If no process is open, then the program closed.

If the program was still running then your code is wrong. No one will look at your code without you putting it into a source box. Which is easy, just click 'edit' on your original post and surround the code with the source tags.

Share this post


Link to post
Share on other sites
Hi, thank you for your reply.

What I meant by the still debugging thing is that when I went to close it and start a new project to see what happened if I clicked no, it asked me if I wanted to stop debugging.

By my program running in the processes list, do you mean 'test5.exe'? If so, this isn't there so that means it's running.

I get all the sme readings in the output boxes as my last post, except under the last line of the build output I get (after stopping debugging):



The program '[2128] Test 8.exe: Native' has exited with code 0 (0x0).





Is everything OK with it?

Regards,
Chris.

[Edited by - chockydavid1983 on July 18, 2007 10:10:48 AM]

Share this post


Link to post
Share on other sites
I've also tried another thing which won't work and may help in diagnosing my problem: Creating a new, empty project

File->New->Project.
Click Win32, click on Win32 Console Application. Enter name and click OK
Click on Application Settings, select Console application and empty project

Project->Add new item
Click Code, click on C++ File (.cpp ), enter name 'main'
Add the following code to the blank .CPP file:



//*************************************************************
// print string by Frank Luna
//*************************************************************
#include <iostream>
#include <string>
int main()
{
std::string firstName = “" ;
std::cout << “Enter your first name and press Enter : “;
std::cin >> firstName;
std::cout << endl;
std::cout << “ Hello, “ << firstName << std::endl << std::endl;
}




Build->Compile

I get the following in the output from build box:



------ Build started: Project: GI project, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(8) : error C2065: '“"' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: '“Enter' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'your'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: 'your' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'first'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: 'first' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'name'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: 'name' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'and'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: 'and' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'press'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: 'press' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'Enter'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(9) : error C2065: '“' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(11) : error C2065: 'endl' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(12) : error C2146: syntax error : missing ';' before identifier 'Hello'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(12) : error C2065: 'Hello' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\GI project\GI project\Debug\BuildLog.htm"
GI project - 17 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




Thanks for all your help so far, does anyone know what else could be wrong please?

Regards,
Chris.

Share this post


Link to post
Share on other sites
All those double quotes need replacing, they are being ignored by the compiler. Standard " should solve the problem the slanted “ is causing.

Share this post


Link to post
Share on other sites
Hi, thank you for your reply.

I replaced what you suggested and went build> compile and I get:



------ Build started: Project: GI project, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project\gi project\main.cpp(11) : error C2065: 'endl' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\GI project\GI project\Debug\BuildLog.htm"
GI project - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




Regards,
Chris.

Share this post


Link to post
Share on other sites
Hi, thank you for your reply.

I'm not quite sure what you mean- I tried replacing everywhere it has endl with std::endl like std::cout.

From the build output, I got:



------ Build started: Project: GI project 2, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2059: syntax error : 'extern '
c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2143: syntax error : missing ';' before '{'
c:\program files\microsoft visual studio 8\vc\include\sal.h(226) : error C2447: '{' : missing function header (old-style formal list?)
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(11) : error C2065: 'endl' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(11) : error C2146: syntax error : missing ';' before identifier 'like'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(11) : error C2065: 'like' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(11) : error C2143: syntax error : missing ';' before 'std::cout'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(12) : error C2146: syntax error : missing ';' before identifier 'like'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(12) : error C2143: syntax error : missing ';' before 'std::cout'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(12) : error C2146: syntax error : missing ';' before identifier 'like'
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 2\gi project 2\main.cpp(12) : error C2143: syntax error : missing ';' before 'std::cout'
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\GI project 2\GI project 2\Debug\BuildLog.htm"
GI project 2 - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




After I realised I guess you meant just insert that text somewhere, if so, where please?

Regards,
Chris.

Share this post


Link to post
Share on other sites
All you need to do is add an std:: infront of the endl on the 11th line.

So that line should be:


std::cout << std::endl;



If it doesnt compile, i'll take a look later tonight if someone else cannot help fix any more errors.

Share this post


Link to post
Share on other sites
Hi, thank you for your reply.

I just tried the following text, put together from a couple of sources:



//*************************************************************
// print string by Frank Luna
//*************************************************************
#include <iostream>
#include <string>
int main()
{
std::string firstName = "" ;
std::cout << "Enter your first name and press Enter : ";
std::cin >> firstName;
std::cout << std::endl;
std::cout << " Hello, " << firstName << std::endl << std::endl;
}




The build output was:



------ Build started: Project: GI project 2, Configuration: Debug Win32 ------
Compiling...
main.cpp
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\GI project 2\GI project 2\Debug\BuildLog.htm"
GI project 2 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========




It seems it worked!

Thanks for all your help, no doubt I'll have more questions soon! I think I may be getting the hang of it (slightly!), thanks again!

Regards,
Chris Moore.

Share this post


Link to post
Share on other sites
Hi everyone

I'm getting some errors and I'm not sure what they mean (It's a console application, empty project and I added a c++ file(.cpp) called main. Here is my source code:



//=======================================================
// Print string.cpp by Frank Luna
//=======================================================

#include <iostream>
#include <string>

using namespace std;

int main ()
{
String ;firstName = "";

cout << "Enter your first name and press enter : ";

cin >> firstName;

cout << endl;

cout << Hello, " << firstName << endl << endl;
;}




Here is my output:



------ Build started: Project: GI project 5, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 5\gi project 5\main.cpp(12) : error C2065: 'String' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 5\gi project 5\main.cpp(12) : error C2065: 'firstName' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 5\gi project 5\main.cpp(20) : error C2065: 'Hello' : undeclared identifier
c:\documents and settings\chris moore\my documents\visual studio 2005\projects\gi project 5\gi project 5\main.cpp(20) : error C2001: newline in constant
Build log was saved at "file://c:\Documents and Settings\Chris Moore\My Documents\Visual Studio 2005\Projects\GI project 5\GI project 5\Debug\BuildLog.htm"
GI project 5 - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




Also, from another project (It's a console application, empty project and I added a c++ file(.cpp) called main. Here is my source code:
, here is my source code:



#include <iostream>
using namespace std;
int main ()
{
int myVar;
cout << myVar << endl;
}




It compiles and builds solution OK but when I go to start without debugging, I get the following error message:
'This project is out of date: GI Project 4- Debug Win32. Would you like to build it?'

I click yes and I get the following error message:
'There were build errors. Would you like to continue and run the last succesful build?'

I click yes and I get the following error message:

'Debug error!

Program: ...
Module: ...sual studio 2005\Projects\GI project 4\debug\GI project 4.exe

Run-Time Check Failure #3- The variable 'myVar' is being used without being initialized.

(Press Retry to debug the application)'

I press retry and I get the following error message:

'GI project 4.exe has encountered a problem and needs to close. We are sorry for the inconvenience.'

Is this what I should be getting or have I done something wrong. I think this exercise may be designed to show this happens.

Share this post


Link to post
Share on other sites
Quote:
Original post by chockydavid1983
Hi everyone

I'm getting some errors and I'm not sure what they mean (It's a console application, empty project and I added a c++ file(.cpp) called main. Here is my source code:

*** Source Snippet Removed ***

Here is my output:

*** Source Snippet Removed ***

Ok your problem here is that after string there is an ; which shouldnt be there. You also have the s in string capitalized and it should be all lower case.
The penultimate line lacks a double quote before Hello, which is the cause of the other error.


Quote:
Also, from another project (It's a console application, empty project and I added a c++ file(.cpp) called main. Here is my source code:
, here is my source code:

*** Source Snippet Removed ***


You need to assign a value to the integer myVar.

Share this post


Link to post
Share on other sites
Hi, thank you for your reply, what you suggested fixed all my errors for th first one and confirmed roughly what I was thinking for the second.

Could I just clarify what fixed what and why please? Hopefully this will allow me to be able to fix my own errors of this type in future.

Does the ';' that shouldn't be there make 'firstName' an identifier (is this always the case?) and hence an undeclared identifier as well?

I understand the lower case 's' thing.

Why does the lack of a '"' make Hello an undeclared identifier?

How was 'error C2001: newline in constant' solved?

Thanks,
Chris.

Share this post


Link to post
Share on other sites
Quote:
Original post by chockydavid1983
Does the ';' that shouldn't be there make 'firstName' an identifier (is this always the case?) and hence an undeclared identifier as well?

Yes, removing that ; makes firstName an identifier (a instance of the string class).

Quote:
Why does the lack of a '"' make Hello an undeclared identifier?
How was 'error C2001: newline in constant' solved?


The code is executing like this:
cout - the computer knows to output into the console.

Hello - the compiler looks for an identifier by the name Hello, cannot find it and "error C2065: 'Hello' : undeclared identifier" is given out.

, - now this, is normally used to seperate definitions of variables so it may be considering doing the cout << Hello then following by making a variable of some form however this may be incorrect.

" - this is the point where it truely breaks, because of the single quote, it appears to the compiler that you want the string " << firstName << endl << endl" printed to the screen, but it cannot find the other quote and thus causes an error.

The solution to C2001 isnt really something a person of my ability can explain, i will give it a go however this may be completely wrong.
My thoughs are that it was caused by the endl's that were inside an incomplete string, if you used escape sequences it might not have given the error.

Share this post


Link to post
Share on other sites
The "Newline in constant" error is just that: You have a newline in
a constant expression.

All strings are inside quotes (""). This tells the compilier that this
is a string constant. A string constant is a series of characters, ending
in a "end of string" character, which, in C and C++, is 0. So:

"Hello" is translated to 'H' 'e' 'l' 'l' 'o' '/0'

Single quotes (') are used to denot a constant, such as a character.

In the case of your error, is indeed caused by your cout statement.

Here is an example. This will produce the error:

cout << "Hello,
world!";

This will work, however:

cout << "Hello, \ // The '\' tells the compilier the constant is a multiline constant.
world!";


In your code, you had:

|--> String constant starts here--------End of line, newline in string constant
cout << Hello, " << firstName << endl << endl;



Instead, you want:

|String | < String ends, so rest of expression comes next
cout << "Hello, " << firstName << endl << endl;


Remember that All Expressions in C and C++ end in semicolen (;).
So a single expression is not complete (And can be appended to using
operators (Like <<, as long as its overloaded), Or the comma operator (,).


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement