Home Help Center

How to compile ICE1.4 with ACE?

weiweiweiwei Member
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.

Comments

  • weidaweida Member
    See http://www.zeroc.com/vbulletin/showthread.php?s=&threadid=605 .

    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
  • weidaweida Member
    There is a bug in ACE when ACE_HAS_WINSOCK2 is defined to 0. In OS_NS_sys_socket.inl, the SD_SEND at line 105 should be changed to ACE_SHUTDOWN_WRITE, and SOCK.h be included at the begining of the file.
  • yomiyomi Member ✭✭
    Is it possible to use winsock2 in Ice now?
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Ice uses Winsock 2 since the very first release.
  • weidaweida Member
    I don't understand. There is some code in IceUtil\Config.h like this:

    // 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?
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Ice links with ws2_32.lib, which is for the Winsock 2 DLL.
  • weidaweida Member
    So could the above code be changed to the following code?

    # ifndef _WINSOCK2API_
    # include <winsock2.h>
    # endif

    That could make other libraries' lives easier, just like the case with ACE.
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Yes, you can simply include winsock2.h. I just tested it.
  • yomiyomi Member ✭✭
    In IceUtil/config.h,
    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.
  • dagobertdagobert Member
    weiwei wrote:
    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:
    .

    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 !
Sign In or Register to comment.