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

來源:互聯網
上載者:User

 

Win32 Consle Application使用MFC的一些類如CString時編譯時間相信會很經常遇到一些串連錯誤:1.       unresolved external symbol __beginthreadex2.       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;

}

 

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

四.大功告成。

運行結果:

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.