请看VC的连接错误

peter9606 2004-05-09 04:45:25
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/laborary.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

一个很简单的程序 编译通过了

是不是我的VC有问题?

下面是程序的代码 很简单的

#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <Afx.h>

class Book {

private :

char m_name[50] ;
char m_author[50] ;
char m_publisher[50] ;
float m_price ;

public :

//Constructors
Book(){
cout << "A new book has been created ." << endl ;
}

Book(char name[], char author[], char publisher[], float price){

Book() ;

strcpy(m_name,name) ;
strcpy(m_author,author) ;
strcpy(m_publisher,publisher) ;
m_price = price ;
}

//Save the information to the file which is specified by the fileName .
void saveBook(char fileName[]){

cout << m_name << "\t" << m_author << "\t" << m_publisher << "\t" << m_price << endl ;
FILE *fp ;
if((fp = fopen(fileName,"a")) == NULL){
cout << "Can't open the file : " << fileName << endl ;
return ;
}
fprintf(fp ,"\n%s,\t,%s,\t,%s,\t,%f,\n",m_name,m_author,m_publisher,m_price) ;
fclose(fp) ;
}

//Set functions
void setName(char* name){
strcpy(m_name,name) ;
}

void setAuthor(char* author){
strcpy(m_author,author) ;
}

void setPublisher(char* publisher){
strcpy(m_publisher,publisher) ;
}

void setPrice(float price){
m_price = price ;
}

//Get functions
char* getName(){
return m_name ;
}

char* getAuthor(){
return m_author ;
}

char* getPublisher(){
return m_publisher ;
}

float getPrice(){
return m_price ;
}


} ;

void main(){

Book book("C ++ Primer " , "Stroustru" , "China-pub" , 128.00) ;
book.saveBook("d:\\hfj.txt") ;


}


...全文
63 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
peter9606 2004-05-09
  • 打赏
  • 举报
回复
更多的错误呀~~

我用的是VS2003,Project Setting -> C/C++ -> Code Generation -> Runtime Library 中选择Multi thread Dll。别的版本应该差不多,具体记不起来了。
despird 2004-05-09
  • 打赏
  • 举报
回复
如果你工程建立用的是WIN32 CONSOLE:把#include <Afx.h>这句注释掉
如果你工程建立用的是WINDOWS APPLICATION:porject->setting中general页中选择“using mfc in a shared dll”
peter9606 2004-05-09
  • 打赏
  • 举报
回复
好象不行呀

就是afx.h这个东西的问题
dreamy 2004-05-09
  • 打赏
  • 举报
回复
我用的是VS2003,Project Setting -> C/C++ -> Code Generation -> Runtime Library 中选择Multi thread Dll。别的版本应该差不多,具体记不起来了。
modena 2004-05-09
  • 打赏
  • 举报
回复
project | settings | c/c++
最下面的框里+上
/MT /D "_X86_" /c
despird 2004-05-09
  • 打赏
  • 举报
回复
把#include <Afx.h>这句注释掉,因为你不用MFC。
peter9606 2004-05-09
  • 打赏
  • 举报
回复
请问怎么设置?
QunKangLi 2004-05-09
  • 打赏
  • 举报
回复
使用多线程库,还不行的话加上:#include <process.h>
dreamy 2004-05-09
  • 打赏
  • 举报
回复
MSDN说:
Libraries:
Multithreaded versions of the C run-time libraries only.
To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries.

modena 2004-05-09
  • 打赏
  • 举报
回复
compile with: /MT /D "_X86_" /c
peter9606 2004-05-09
  • 打赏
  • 举报
回复
难道没有人帮忙么?

自己顶一下

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧