编译环境:win xp+visual studio 2005
工程:windows Console project
我加入了如下预处理指令:
#pragma comment(lib,"msvcrt.lib")
#pragma comment(lib,"libcmt.lib")#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#include <windows.h>
#include <stddef.h>
#include "process.h"对编译选项进行了设置:
project setting -> c/c++ -> Code Generator -> use run-time library -> Multi-threaded DLL (/MD)竟然报错了:
------ Rebuild All started: Project: ThreadLook, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'ThreadLook', configuration 'Debug|Win32'
Compiling...
stdafx.cpp
Compiling...
ThreadLook.cppCompiling manifest to resources...
Linking...
LINK : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
ThreadLook.obj : error LNK2019: unresolved external symbol "unsigned int __stdcall ThreadRun(void *)" (?ThreadRun@@YGIPAX@Z) referenced in function _wmain
C:\Documents and Settings\p80148th\My Documents\Visual Studio 2005\Projects\ThreadLook\Debug\ThreadLook.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\p80148th\My Documents\Visual Studio 2005\Projects\ThreadLook\ThreadLook\Debug\BuildLog.htm" 

解决方案 »

  1.   

    #pragma comment(lib,"msvcrt.lib")
    #pragma comment(lib,"libcmt.lib")
    ??
    楼主有没有弄清楚,这两个库是干吗的?同时包含?
      

  2.   

    你的这个 ThreadRun 线程函数没有包含到项目中或缺少给函数的LIB。
      

  3.   

    刚才看了一下msdn,多少有点眉目.我把那行#pragma comment(lib,"libcmt.lib")注释掉,添加了 ThreadRun 定义体.编译成功了,输出信息如下:
    ------ Rebuild All started: Project: ThreadLook, Configuration: Debug Win32 ------
    Deleting intermediate and output files for project 'ThreadLook', configuration 'Debug|Win32'
    Compiling...
    stdafx.cpp
    Compiling...
    ThreadLook.cpp
    Compiling manifest to resources...
    Linking...
    LINK : C:\Documents and Settings\p80148th\My Documents\Visual Studio 2005\Projects\ThreadLook\Debug\ThreadLook.exe not found or not built by the last incremental link; performing full link
    Embedding manifest...
    Build log was saved at "file://c:\Documents and Settings\p80148th\My Documents\Visual Studio 2005\Projects\ThreadLook\ThreadLook\Debug\BuildLog.htm"
    有什么问题吗?