Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
This doesn't work!

C++
#include <iostream>
using namespace std;        // not fond of STDs but never mind

int main()
{
    cout << "What are you upto bebe";
}


Please help!!

Error message here http://i.imgur.com/gvfsURZ.png[^]

Text version:
C:\Users\me\Desktop\console>cl hello.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

hello.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337) : wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled. S
pecify /EHsc
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:hello.exe
hello.obj
LINK : fatal error LNK1104: cannot open file 'libcpmt.lib'

C:\Users\me\Desktop\console>
Posted
Updated 17-Mar-15 5:23am
v5
Comments
PIEBALDconsult 17-Mar-15 10:55am    
In what way does it not work?
[no name] 17-Mar-15 10:56am    
it doesn't compile
PIEBALDconsult 17-Mar-15 11:02am    
Then please use Improve question to add the error message to your question.
[no name] 17-Mar-15 11:12am    
I've added it
Sergey Alexandrovich Kryukov 17-Mar-15 11:17am    
As a bitmap? ::Facepalm:: :-)
—SA

The error message is a linker error telling you that a specific library can't be found.

Because you are compiling on the command line, you must set some general environment variables. This can be done by calling the vcvars32.bat script which should have been generated by your VS setup and stored in the VC\bin directory.
 
Share this answer
 
Comments
[no name] 17-Mar-15 11:32am    
I ran that script, still doesn't work :/
[no name] 17-Mar-15 11:33am    
C# compiles just fine though.
Jochen Arndt 17-Mar-15 11:40am    
On the command line type 'set' and check the value behind 'LIB='.

The libcpmt.lib file must be located in one of the directories (usually the VC/lib directory).
When you try to compile this you get
Quote:
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1>

Funnily enough if you follow the advice the problem goes away
C++
#include "StdAfx.h"
#include <iostream>
using namespace std;        // not fond of STDs but never mind

int main()
{
    cout << "What are you upto bebe";
}


EDIT - contents of stdafx.h
XML
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here
 
Share this answer
 
v2
Comments
[no name] 17-Mar-15 11:16am    
what's StdAfx.h? Is that a standard library as well?
CHill60 17-Mar-15 11:25am    
Yes it's a standard header - I've included the content in the solution
PIEBALDconsult 17-Mar-15 11:20am    
But how do you know what compiler is being used?
CHill60 17-Mar-15 11:23am    
It's got vs2013 in the image
PIEBALDconsult 17-Mar-15 11:26am    
Oh, right, I didn't look at the image.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900