我的程序出错:
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
===
下面是源程序:
// MyConsole.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <afx.h>//using namespace std;int main(int argc, char* argv[])
{
char* pBuffer = new char[0x1000];
......
return 0;
}
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
===
下面是源程序:
// MyConsole.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <afx.h>//using namespace std;int main(int argc, char* argv[])
{
char* pBuffer = new char[0x1000];
......
return 0;
}
project -》 settings -》C/C++ -》Code Gerenation
试试!
#include "stdafx.h"
#include <afx.h>//using namespace std;int main(int argc, char* argv[])
{
char* pBuffer = new char[0x1000];
CFile file("mydoc.doc", 1);
return 0;
}
我的是Debug Single-Threaded有什么问题么?
怎么改?
{
char* pBuffer = (char *)malloc(0x1000);
CFile file("mydoc.doc", 1);
return 0;
}
#include <afx.h>上述包含文件中去掉 #include <afx.h>
运行裤的问题
换成char* pBuffer = (char *)malloc(0x1000);
出现如下错误:
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/MyConsole.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
可以么?
一样的错误
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
把你的运行环境描述一下
在Project->Setting->General->Microsoft Foundation Classes中选择使用MFC
========
正解