C运行时库和标准C++库
先理解運行時庫,就是 C run-time library,是 C 而非 C++ 語言世界的概念:取這個名字就是因為你的 C 程序運行時需要這些庫中的函數.VC提供的 C run-time library分為動態運行時庫和靜態運行時庫:
動態運行時庫:
???????msvcrt.dll(or MSVCRTD.DLL for debug build),對應的Import library文件是MSVCRT.LIB(MSVCRTD.LIB for debug build)
靜態運行時庫(release版)對應的主要文件是:
?????LIBC.LIB :Single thread static library, retail version
???? LIBCD.lib:debug single-threaded ,static library
???? LIBCMT.LIB (Multithread static library, retail version)
???? libcmtd.lib:debug Multithread static library
?C++ 世界里,有另外一個概念:Standard C++ Library,它包括了上面所說的 C run-time library 和 STL。包含 C run-time library 的原因很明顯,C++ 是 C 的超集,沒有理由再重新來一個 C++ run-time library. VC針對C++ 加入的Standard C++ Library主要包括:LIBCP.LIB, LIBCPMT.LIB和 MSVCPRT.LIB,與c run-time library比較,文件名稱中多了個p
動態運行時庫:
???????msvcprt.dll(or MSVCPRTD.DLL for debug build),對應的Import library文件是MSVCPRT.LIB(MSVCPRTD.LIB for debug build)
靜態運行時庫(release版)對應的主要文件是:
?????LIBCP.LIB :Single thread static library, retail version
???? LIBCPD.lib:debug single-threaded ,static library
???? LIBCPMT.LIB (Multithread static library, retail version)
???? libcpmtd.lib:debug Multithread static library
?編譯時到底哪個C run-time library聯入你的程序取決于編譯選項可在project->settings->C++->Code ? Generation的Use ? Runtime ? Library下選擇C run-time library 。 動態鏈接需要相應的動態庫支持才能運行(MSVCRTD.DLL 或MSVCRT.DLL ),注意與MFC的動態鏈接不同。
使用第三方的庫容易造成LNK2005錯誤――重復定義錯誤,一般是第三方庫的鏈接方式與現工程不一致造成的,如第三方庫采用靜態鏈接,而現工程采用動態鏈接,或者第三方庫用單線程,而現工程采用多線程都會引發此錯誤。
總結
以上是生活随笔為你收集整理的C运行时库和标准C++库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UNIX 终端IO
- 下一篇: C/C++运行时库 解释