問題1.: fatal error C1083: 無法開啟包含檔案:“iostream.h”: No such file or directory
解決辦法:
將 #include "iostream.h" //(vc++6.0)
替換為: //(vc++7.0 /vc++.net)
#include "IOSTREAM" // 包含流的舊式標頭檔 //使用舊的iostream標頭檔不要加.h
using namespace std; //另需添加部分PLCHandler.obj : error LNK2001: unresolved external symbol "public: bool __thiscall PLCDB90::read(long,long,long * const)" (?read@PLCDB90@@QAE_NJJQAJ@Z)
PLCHandler.obj : error LNK2001: unresolved external symbol "public: bool __thiscall PLCDB80::read(long,long,long * const)" (?read@PLCDB80@@QAE_NJJQAJ@Z)
bin/PlcOperation.exe : fatal error LNK1120: 2 unresolved externals
在plcdb90.cpp檔案中沒有對其實現
PLCDB90::read(long,long,long * const)
2*****************
問題:
--------------------Configuration: DataTrans - Win32 Debug--------------------
Compiling
DataTrans.cpp
D:\VC60Projects\DataTrans\DataTrans.cpp(22) : error C2065: 'cout' : undeclared identifier
D:\VC60Projects\DataTrans\DataTrans.cpp(22) : error C2297: '<<' : illegal, right operand has type 'char [4]'
D:\VC60Projects\DataTrans\DataTrans.cpp(22) : error C2065: 'endl' : undeclared identifier
D:\VC60Projects\DataTrans\DataTrans.cpp(23) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
PLCHandler.cpp
DataHelper.cpp
Generating Code
Error executing cl.exe.
DataTrans.exe - 3 error(s), 1 warning(s)
//****************************************************
解決:
在project setting裡面的 c/c++ 選項卡
在combo裡面找到 precompiled header
選擇 no precompiled header 即可
3***********************
bool bflag型
bool 應大寫為 BOOL
4***********************
c1.h,c2.h 標頭檔的互相包含
c1.h中寫上#include "c2.h",class c2;
c2.h中同樣如此.
5*******************************
d:\shengwuproject\0911\dbcallback.cpp(15) : error C2371: 'public: static class PLC * cTestCallBack::pLCDB902' : redefinition; different basic types
d:\shengwuproject\0911\dbcallback.h(34) : see declaration of 'public: static class PLC * cTestCallBack::pLCDB902'
PLC *cTestCallBack::pLCDB902; //靜態變數聲明
前面聲明的類型plc和後面的*cTestCallBack::pLCDB902變數類型plcdb90不一樣.
6=============================
已經包含了#include <process.h>標頭檔,編譯時間仍然說'_beginthread' undeclared identifier
解決:
根據下列步驟進行設定.
project->settings->c/c++:
Category:Code Generation
Use run-time library:
debug version:
Debug Multithread DLL
release version:
Multithread DLL
7==============================
問題:
PLCDB90.obj : error LNK2001: unresolved external symbol "class ATL::CComModule _Module" (?_Module@@3VCComModule@ATL@@A)
bin/PlcOperation.exe : fatal error LNK1120: 1 unresolved externals
解決:
添加ATL標頭檔
使用ATL前必須包含以下標頭檔:atlbase.h和atlcom.h,並且定義_Module變數[2]。把以下代碼加到stdafx.h是最方便的:
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
在cpp檔案中要對_Module進行定義。如下:
CcomModule _Module;
在添加了這兩行之後,我們就可以使用ATL的功能了。而不必建立ATL的項目。
當然,如果項目是通過ATL項目嚮導產生的就不必再次添加標頭檔了。
http://www.jr163.org/cup2/18/18781.htm
8===================================
問題:
在MFC(介面)下調用PLC com組件,能響應Com回調dataChange事件,在控制台程式則不能.
原因:
因為COM利用訊息機制來實現STA,因此STA套間裡的線程必須實現訊息迴圈,否則COM將不能實現STA的要求。
解決:
在程式中加入:
#include <windows.h>
// Main message loop:
MSG msg;
while/if(GetMessage(&msg, NULL, 0, 0))
{
// TranslateMessage(&msg);
DispatchMessage(&msg);
}
http://blog.csdn.net/lop5712/archive/2004/04/05/21360.aspx
未完侍續.