200分!一个关于编译器设置的问题

qinamao 2003-09-12 09:28:11
编译是出错:
c:\program files\microsoft visual studio\vc98\mfc\include\afxver_.h(130) : fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds

ShowInfo工程的Project Setting---c/c++选项卡----Project Options的内容如下:
/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /Fp"Debug/ShowInfo.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c

该项目是多线程、网络相关。
...全文
84 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
stavck 2003-09-12
  • 打赏
  • 举报
回复
stdafx.h文件贴出来看看
qinamao 2003-09-12
  • 打赏
  • 举报
回复
选择 Multithread DLL 或加上/MD后的编译

Compiling...
StdAfx.cpp
d:\vcpro\peeryouc\stdafx.h(44) : error C2146: syntax error : missing ';' before identifier 'hExitEvent'
d:\vcpro\peeryouc\stdafx.h(44) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

PeerYouC.exe - 2 error(s), 0 warning(s)
lhb_780902 2003-09-12
  • 打赏
  • 举报
回复
同意楼上,也可以选择Debug Multithread DLL。
stavck 2003-09-12
  • 打赏
  • 举报
回复
你就在工程的Project Setting---c/c++选项卡:
CageGory 选择 Code Generation
Use Run-Time library:选择 Multithread DLL
milson 2003-09-12
  • 打赏
  • 举报
回复
加上/MD后的编译错误贴出来看看。
qinamao 2003-09-12
  • 打赏
  • 举报
回复
以上办法都试过了,一筹莫展
qinamao 2003-09-12
  • 打赏
  • 举报
回复
将/MTd 改为 /MD 和加入 /MD都不对
bluestar 2003-09-12
  • 打赏
  • 举报
回复
你就在工程的Project Setting---c/c++选项卡----Project Options中加上/MD
lygfqy 2003-09-12
  • 打赏
  • 举报
回复
应该是要采用多线程的编译才对!
详细的编译选项可以参考www.vckbase.com,论坛精华中的《关于微软C/C++ 编译器选项参考》
一文
abc_rain 2003-09-12
  • 打赏
  • 举报
回复
If you are converting an existing project to an MFC Extension DLL, start with the standard rules for building an application using the _AFXDLL version of MFC. Then follow these steps:


Add /D_AFXEXT to the compiler flags. On the Project Settings dialog, select the C/C++ tab. Then select the Preprocessor category. Add _AFXEXT to the Preprocessor Definitions field, separating each of the items with commas.

Remove the /Gy compiler switch. On the Project Setting dialog, select the C/C++ tab. Then select the C Language category. Ensure that the "Enable Function-Level Linking" checkbox is cleared. This will make it easier to export classes because the linker will not remove unreferenced functions. If the original project is used to build a Regular DLL statically linked to MFC, change the /MT[d] compiler option to /MD[d].

Build an export library with the /DLL option to LINK. This will be set when you create a new target, specifying Win32 Dynamic-Link Library as the target type.
akiko 2003-09-12
  • 打赏
  • 举报
回复
/nologo /MTd 改为
/nologo /MD 试试
ruihuahan 2003-09-12
  • 打赏
  • 举报
回复
C++运行时有多种版本,多线程程序必须使用多线程版的运行时。
/MD连接选项可以选择多线程版,可以在project settings中设置。
stavck 2003-09-12
  • 打赏
  • 举报
回复
最好把这些定义放到peeryouc.h中,或者放到一个单独的文件中如tool.h中。
qinamao 2003-09-12
  • 打赏
  • 举报
回复
stdafx.h :
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#if !defined(AFX_STDAFX_H__C98700B6_077D_4E3D_A621_F78EAF851DCF__INCLUDED_)
#define AFX_STDAFX_H__C98700B6_077D_4E3D_A621_F78EAF851DCF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <afxsock.h> // MFC socket extensions
//#include <Winsock2.h>
#include <process.h>
#include "afxole.h"
#define FULLSCREEN WM_USER+1
typedef unsigned (__stdcall *PTHREAD_START)(void*);

#define BeginThread(pfnStartAddr,pvParam,pdwThreadID)\
((HANDLE)(_beginthreadex((void*)NULL,\
0,\
(PTHREAD_START)(pfnStartAddr),\
(void*)(pvParam),\
0,\
(unsigned*)(pdwThreadID)\
)\
)\
)

#define EndThread(retVal) _endendthreadex((unsigned)retVal)
void Message(char *cmd, char *result);
extern char ADDRESS[16];
extern WSAEVENT hExitEvent; //第44行
typedef struct drag{
int flag;
DWORD wnd;
}DRAG;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__C98700B6_077D_4E3D_A621_F78EAF851DCF__INCLUDED_)
akun 2003-09-12
  • 打赏
  • 举报
回复
选择 Multithread DLL 或加上/MD后的编译

Compiling...
StdAfx.cpp
d:\vcpro\peeryouc\stdafx.h(44) : error C2146: syntax error : missing ';' before identifier 'hExitEvent'
d:\vcpro\peeryouc\stdafx.h(44) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

PeerYouC.exe - 2 error(s), 0 warning(s)

这里应该是代码里面有错...

16,472

社区成员

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

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

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