在Win32 Consle Application如何使用MFC類 ,unresolved external symbol __beginthreadex

 
Win32 Consle Application使用MFC的一些類如CString時編譯時相信會很經常遇到一些連接錯誤:
1.       unresolved external symbol __beginthreadex
2.       unresolved external symbol __endthreadex
但是不用MFC類又讓人不甘心,放着好好的類庫不用實在太可惜了。其實是可以用的,只是我們的設置有問題。
下面我將具體設置描述一下,和大家共同分享我的經驗。
一.新建一個Win32 Consle Application工程:GetCurrentTime。
二.打開“Project”菜單——〉“Setting”菜單項——〉General選項卡
在Microsoft Fountion Classes:中選擇:Use MFC in Static Library.
 

三.再在C/C++選項卡中的在Category中選擇Code Generation,
再在Use run-time library中選擇Debug Multithreaded或者multithreaded
其中,
Single-Threaded單線程靜態鏈接庫(release版本)
Multithreaded多線程靜態鏈接庫(release版本)
multithreaded DLL多線程動態鏈接庫(release版本)
Debug Single-Threaded單線程靜態鏈接庫(debug版本)
Debug Multithreaded多線程靜態鏈接庫(debug版本)
Debug Multithreaded DLL多線程動態鏈接庫(debug版本)

選擇Debug Multithreaded(如果你在Win32 Debug環境下)

之後敲入你的代碼:

#include "stdafx.h"

#include <afx.h>  // 注意要加上你所用的類的頭文件

#include <stdio.h>

 

int main(int argc, char* argv[])

{

       CTime time;

       time = CTime::GetCurrentTime();

       CString str = time.Format("%H:%M:%S");

    printf("當前時間爲%s/n",(LPCTSTR)str);

       return 0;

}

 

在編譯時往往提示設置有改動,是否繼續,選擇“是”

四.大功告成。

運行結果:

 

 

 
































































































發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章