编译过程中遇到的警告或错误

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/pizicai105/article/details/4776289

1、Linking...
LINK : warning LNK4089: all references to "SHELL32.dll" discarded by /OPT:REF
LINK : warning LNK4089: all references to "comdlg32.dll" discarded by /OPT:REF

你程序里一定有没有使用的类,而这个类引用了shell32.dll文件,编译的时候,这个类被编译了,但连接的时候发现没有使用,就显示这样的警告,并无大碍,如果想这个警告不出现,你就把包含这个类的文件,从工作区中删除就可以了。

 

2、Linking...
   Creating library Debug/ITLAN_Chinese_D.lib and object Debug/ITLAN_Chinese_D.exp
ITLAN_Chinese_D.exp : warning LNK4070: /OUT:ITLAN_Chinese.dll directive in .EXP differs from output filename "../Debug/ITLAN_Chinese_D.dll"; ignoring directive

ITLAN_Chinese_D.dll - 0 error(s), 1 warning(s)

我在DLL项目中遇到了,因为要对Debug版和Release版分别指定不同的输出文件名。对Debug版,我指定输出文件为dllD.dll,对Release版指定为dllR.dll。

        解决方法有两个:(1)删掉自动生成的dll.DEF文件,在代码中使用_declspec(dllexport)导出函数;(2)删掉dll.DEF文件中LIBRARY字段后面双引号及其内部的库名即可,也可以将其改掉。如改为:

; dll.def : Declares the module parameters for the DLL.

LIBRARY      "dllD"
DESCRIPTION  'dll Windows Dynamic Link Library'

EXPORTS
    ; Explicit exports can go here

 

3、使用stl的vector或string等,需要#pragma warning( disable : 4786)

 

4、资源文件若以text方式上传到cvs,则其他人取下来后编译时会异常

展开阅读全文

编译过程中遇到的一个错误

08-19

这是我的代码:[code=c]/*-------------------------------------------------rn CHECKER1.C -- Mouse Hit-Test Demo Program NO.1rn 0xff 2013.8rn-------------------------------------------------*/rnrn#include rnrn#define DIVSIONS 5rnrnLRESULT CALLBACK WndProc(HWND, UINT ,WPARAM, LPARAM);rnrnint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)rnrn static TCHAR szAppName[] = TEXT("Checker1");rn HWND hwnd;rn MSG msg;rn WNDCLASS wndclass;rnrn wndclass.style = CS_HREDRAW | CS_VREDRAW;rn wndclass.lpfnWndProc = WndProc;rn wndclass.cbClsExtra = 0;rn wndclass.cbWndExtra = 0;rn wndclass.hInstance = hInstance;rn wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);rn wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);rn wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);rn wndclass.lpszMenuName = NULL;rn wndclass.lpszClassName = szAppName;rnrn if(!RegisterClass(&wndclass))rn rn MessageBox(NULL, TEXT("This program requires Windows NT"), szAppName, MB_ICONERROR);rn return 0;rn rnrn hwnd = CreateWindow(szAppName, TEXT("Mouse Hit-Test Demo"),WS_OVERLAPPEDWINDOW,rn CW_USEDEFAULT, CW_USEDEFAULT,rn CW_USEDEFAULT, CW_USEDEFAULT,rn NULL, NULL, hInstance, NULL);rnrn ShowWindow(hwnd, iCmdShow);rn UpdateWindow(hwnd);rnrn while(GetMessage(&msg, NULL, 0, 0))rn rn TranslateMessage(&msg);rn DispatchMessage(&msg);rn rn return msg.wParam;rnrnrnLRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)rnrn static BOOL fState[DIVSIONS][DIVSIONS];rn static int cxBlock, cyBlock;rn HDC hdc;rn int x,y;rn PAINTSTRUCT ps;rn RECT rect;rnrn switch(message)rn rn case WM_SIZE:rn cxBlock = LOWORD(lParam) / DIVSIONS;rn cyBlock = HIWORD(lParam) / DIVSIONS;rn return 0;rnrn case WM_LBUTTONDOWN:rn x = LOWORD(lParam) / cxBlock;rn y = HIWORD(lParam) / cyBlock;rnrn if(x < DIVSIONS && y < DIVSIONS)rn rn fState[x][y] ^= 1;rn rect.left = x * cxBlock;rn rect.top = y * cyBlock;rn rect.right = (x + 1) * cxBlock;rn rect.bottom= (y + 1) * cyBlock;rnrn InvalidateRect(hwnd, &rect, FALSE);rn rn elsern MessageBeep(0);rn return 0;rnrn case WM_PAINT:rn hdc = BeginPaint(hwnd, &ps);rnrn for(x = 0; x < DIVSIONS; x++)rn for(y = 0; y < DIVSIONS; y++)rn rn Rectangle(hdc, x * cxBlock, y * cyBlock, (x + 1) * cxBlock, (y + 1) * cyBlock);rnrn if(fState[x][y])rn rn MoveToEx(hdc, x * cxBlock, y * cyBlock, NULL);rn LineTo(hdc, (x + 1) * cxBlock, (y + 1) * cyBlock);rn MoveToEx(hdc, x * cxBlock, (y + 1) * cyBlock, NULL);rn LineTo(hdc, (x + 1) * cxBlock, y * cyBlock);rn rn rn EndPaint(hwnd,&ps);rn return 0;rnrn case WM_DESTROY:rn PostQuitMessage(0);rn rn return DefWindowProc(hwnd, message, wParam, lParam);rnrnrn[/code]rn1>LINK : fatal error LNK1327: 运行 rc.exe 期间出错rn百度上也找不到这个LNK1327错误是个什么类型的错误,求解答rn 论坛

奇怪的编译警告提示,运行时奇怪错误

11-27

代码如下rn#includern#includernusing namespace std;rnint main()rnrn const char *p1="love";rn const char *p2="forever";rn size_t size_arr=strlen(p1)+strlen(p2);rn char *result_str=new char[size_arr+1];rn strcpy(result_str,p1);rn strcat(result_str,p2);rn cout<<*result_str<------ 已启动生成: 项目: test, 配置: Debug Win32 ------rn1>正在编译...rn1>test.cpprn1>c:\documents and settings\lican\my documents\visual studio 2005\projects\test\test.cpp\test.cpp(10) : warning C4996: “strcpy”被声明为否决的rn1> e:\vs2005\vc\include\string.h(73) : 参见“strcpy”的声明rn1> 消息:“This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”rn1>c:\documents and settings\lican\my documents\visual studio 2005\projects\test\test.cpp\test.cpp(11) : warning C4996: “strcat”被声明为否决的rn1> e:\vs2005\vc\include\string.h(78) : 参见“strcat”的声明rn1> 消息:“This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”rn1>正在编译资源清单...rn1>正在链接...rn1>正在嵌入清单...rn1>生成日志保存在“file://c:\Documents and Settings\LiCan\My Documents\Visual Studio 2005\Projects\test\test\Debug\BuildLog.htm”rn1>test - 0 个错误,2 个警告rn========== 生成: 1 已成功, 0 已失败, 0 最新, 0 已跳过 ==========rn运行的时候只出现一个l字符,显然不符合预期rn请高手解释是怎么回事rn 论坛

没有更多推荐了,返回首页