How to compile ICE1.4 with ACE?

in Help Center
I want to use some class in ACE(adaptertive communication environment)
,but when I include ace include file in front of ice include file,some compile
error happens,
Error info in VC6.0:
Client.cpp
../../../include\Ice/Application.h(33) : error C2668: 'ace_main_i' : ambiguous call to overloaded function
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(20) : error C2872: 'cout' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(43) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(51) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(71) : error C2872: 'cout' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(72) : error C2872: 'cin' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(184) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(184) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(187) : error C2872: 'cin' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(198) : error C2143: syntax error : missing ';' before 'try'
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(207) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(207) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(219) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(219) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)
Error executing cl.exe.
,but when I include ace include file in front of ice include file,some compile
error happens,
Error info in VC6.0:
Client.cpp
../../../include\Ice/Application.h(33) : error C2668: 'ace_main_i' : ambiguous call to overloaded function
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(20) : error C2872: 'cout' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(43) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(51) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(71) : error C2872: 'cout' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(72) : error C2872: 'cin' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(184) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(184) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(187) : error C2872: 'cin' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(198) : error C2143: syntax error : missing ';' before 'try'
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(207) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(207) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(219) : error C2872: 'cerr' : ambiguous symbol
E:\C++\ICE\Ice-1.4.0\demo\Ice\hello\Client.cpp(219) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)
Error executing cl.exe.
0
Comments
In addition, when build ACE, you should define ACE_HAS_WINSOCK2 to 0 in your config.h file because Ice includes winsock.h instead of winsock2.h.
Regards,
Weida
// MFC applications that include afxwin.h before this header will cause
// windows.h to skip inclusion of winsock.h, so we include it here if
// necessary.
//
# ifndef _WINSOCKAPI_
# include <winsock.h>
# endif
Isn't winsock.h for Winsock 1.1?
# ifndef _WINSOCK2API_
# include <winsock2.h>
# endif
That could make other libraries' lives easier, just like the case with ACE.
simply #include <windows.h> will cause <winsock.h> be included (not MFC project),
and which confict with <winsock2.h>.
If #define WIN32_LEAN_AND_MEAN added before <windows.h> will be better.
What is a bit tricky with ACE is, that it instantiates some singelton (global) objects (like the object manager by replacing the standard int main ( ... ) by an own macro (containing the instantiation code). In general you can get around this by certain compilation options described in the ACE documentation (search for ObjectManager ...), however there might still be some conflicts.
We are using both libraries in combination. The way how to do it is by NOT intermixing ICE and ACE includes. We separated out those components responsible for communications (via ICE), encapsulated them and used the pointer-to-implementation (pimpl) idiom to keep the ice includes (or ace includes) out of our include files. So each compilation unit has either ice includes or ace includes ... both never a mix of them.
This approach works perfectly !