|
Hi, I am using Visual Studio 2005, I build new win32 console application project and I tried to compile this simple code
<br />
#include "stdafx.h"<br />
#include <iostream><br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
using namespace std;<br />
char question[] = "Please, enter your first name: ";<br />
char greeting[] = "Hello, ";<br />
char yourname [80];<br />
cout << question;<br />
cin >> yourname;<br />
cout << greeting << yourname << "!";<br />
return 0;<br />
}
But I get error of
error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > &__cdecl std::operator<<<char,struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (__imp_??$?6DU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z) referenced in function _wmain
But when I comment out the line
it compile successfully.
I think there is library file missing, but don't know which one. I googled out so many website and still can't find out the solutions, any ideas how to solve this ?
Thanks.
-- modified at 1:33 Sunday 6th May, 2007
|
|
|
|
|
esia wrote: I think there is library file missing, but don't know which one.
Which ones are you linking with?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for your reply, I didn't link any library file, but when I read from this solved post where they include the path to msvcprt.lib, http://www.tek-tips.com/viewthread.cfm?qid=1354561&page=1
But when I did that, I still get the same error. Any ideas how ?
|
|
|
|
|
The following are the default libraries for a Visual Studio 2005 C++ Win32 Console application: kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks for your reply, but what you trying to explain to me ?
|
|
|
|
|
Are you using the /nodefaultlib compiler switch?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
George L. Jackson wrote: The following are the default libraries for a Visual Studio 2005 C++ Win32 Console application: kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib.
But the relevant one is going to be one of:
libcmt.lib
msvcrt.lib
libcmtd.lib
msvcrtd.lib
msvcmrt.lib
msvcurt.lib
These are governed by the /nodefaultlib and /Mx compiler switches.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
On VC++ 6.0 I need these to get that to compile and run...
#include <iostream>
#include <tchar.h>
// Not sure if that helps since I don't have Visual C++ 2005
|
|
|
|
|
bob16972 wrote: On VC++ 6.0 I need these to get that to compile and run...
#include <iostream>
#include <tchar.h>
// Not sure if that helps...
Especially since it's a linker error.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Fair enough. I was just hoping they had been tinkering to get errors to go away and they were posting the latest error which may have been after changing project settings around etc...
I didn't realize the include for iostream was there since they didn't check the "ignore HTML tags in this message" box. I saw your other post and took a look at the html source and there it is.
I was hoping that maybe by starting a new project and copying and pasting the code with the includes would fix it if they had messed with the project settings before posting the latest errors.
I would assume VC++ 2005 would give the correct basis for a crt project but maybe I'm mistaken. This thread may help spark some ideas for the original poster...
ideas and shots in the dark[^]
|
|
|
|
|
Include
#include <iostream> .
Regards,
Paresh.
|
|
|
|
|
Paresh Chitte wrote: #include <iostream>
It already is being included. Furthermore, it's a linker error, not a compiler error.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Sorry for the late of reply, actually I did include #include <iostream>, I forgot to convert the tag to the literal string, so the browser always treat the opening tag as html code. Ok but my problem has been solved when I changed the setting, Project > properties > C/C++ > Runtime Library > Multi-threaded Debug DLL (/MDd) . Does anybody knows why is it so ? I am using Visual Studio 2005 professional,
|
|
|
|
|
Hi I need to manage a progressBar into MyThread class(CWinThread derived) using a timer but I can use the ON_WM_TIMER Event message.
How can I do it? Using the SetTimer function but how?
Thanks
|
|
|
|
|
CDRAIN wrote: How can I do it? Using the SetTimer function but how?
They hide that information in the Documentation[^]
led mike
|
|
|
|
|
Sorry, I made an error on the description of my problem:
I can't use the ON_WM_TIMER message because my class MyThread isn't derived from the CWnd but from the CWinThread.
How can I do this?
|
|
|
|
|
CDRAIN wrote: Hi I need to manage a progressBar into MyThread class(CWinThread derived)...
Does the progress bar belong to a different thread than the one you are creating?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, the progress bar belong to the MainThread of my Application, and I need to manage it from my thread.
|
|
|
|
|
CDRAIN wrote: Yes, the progress bar belong to the MainThread of my Application, and I need to manage it from my thread.
Which is a sure-fire recipe for disaster.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CDRAIN wrote: the progress bar belong to the MainThread of my Application, and I need to manage it from my thread.
in your first post you said
CDRAIN wrote: I need to manage a progressBar into MyThread class
I have no idea what to believe at this point. If your progress bar is in the main thread you DO NOT need to manage it from the worker thread. Instead you do something like this:
Progress Information Object
CWnd in main thread (Progress Bar or Window) has a reference to the Progress Information Object
CWinThread worker thread has a reference to the Progress Information Object and continuously updates the object to reflect the work in progress.
ProgressBar or Window sets a timer and on the timer event reads the progress information from the shared Progress Information Object and updates the ProgressBar state.
led mike
|
|
|
|
|
I developed a log parser in plain C in VS 2005. The essential for the parser is to take in buffer as much data for the processing as possible. I read file as a binary by using low level function “_read”. I discovered that the optimal size of the buffer is 100 kb. I need actually buffer approximately of 500kb. However when I increase the buffer’s size the processing time increases. It happens according to profile because the reading time increases. I would expect that reading larger portion of data should reduce reading time, but got opposite results. I assume it can depend on some compiler settings, but couldn’t find anything. I would appreciate any help in this matter.
Yefim
|
|
|
|
|
Hmm I don't know what I'm missing but reading 5 times as many bytes could take 5 times as long...
Are you accessing the file sequentially or randomly?
What flags are you specifying in the _open() call?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark thanks for fast respond.
I’m accessing this file sequently and here is the opening and reading part
iFin = _open(szSourceFile, _O_BINARY|_O_RDONLY);
szBufRead = 100000;
iGet=_read(iFin,szBufRead,iReadData);
Thanks again Yefim
|
|
|
|
|
Try _O_BINARY|_O_RDONLY|_O_SEQUENTIAL.
Internally, the CRT uses the Windows CreateFile() API to open the file when you call _open().
_O_SEQUENTIAL causes the FILE_FLAG_SEQUENTIAL_SCAN flag to be added to the dwFlagsAndAttributes
parameter passed to ::CreateFile(). Whether the system actually uses this flag, I don't know
That's the only place I can see to possibly optimize buffering, aside from disabling all system
buffering and handling it yourself.
Are you sure it's not just a matter of reading 5 times as many bytes at a time from a relatively
slow device?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|