Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 31

Thread: Compile problems in VC7.1

  1. #1
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22

    Question Compile problems in VC7.1

    Hello gents,

    I've been trying to port a small ICE app to windows, using vs7.1. But I ran into some problems... the program(s) still compile fine on linux, but I get the following errors in the compile log:
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xutility(341): error C2084: function 'std::_Scalar_ptr_iterator_tag std::_Ptr_cat(const std::_Bool *,std::_Bool *)' already has a body

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xutility(335): error C2084: function 'std::_Scalar_ptr_iterator_tag std::_Ptr_cat(std::_Bool *,std::_Bool *)' already has a body

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\ostream(228): error C2535: 'std::basic_ostream<_Elem,_Traits>::_Myt &std::basic_ostream<_Elem,_Traits>:perator <<(std::_Bool)' : member function already defined or declared

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\ostream(228): error C2535: 'std::basic_ostream<_Elem,_Traits>::_Myt &std::basic_ostream<_Elem,_Traits>:perator <<(std::_Bool)' : member function already defined or declared
    with
    [
    _Elem=char,
    _Traits=std::char_traits<char>
    ]

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\ostream(228): error C2535: 'std::basic_ostream<_Elem,_Traits>::_Myt &std::basic_ostream<_Elem,_Traits>:perator <<(std::_Bool)' : member function already defined or declared
    with
    [
    _Elem=wchar_t,
    _Traits=std::char_traits<wchar_t>
    ]

    c:\Ice-2.0.0\include\Ice\BasicStream.h(146): error C2535: 'void IceInternal::BasicStream::read(BOOL &)' : member function already defined or declared

    c:\Ice-2.0.0\include\Ice\BasicStream.h(147): error C2535: 'void IceInternal::BasicStream::read(std::vector<_Ty,_Ax > &)' : member function already defined or declared
    with
    [
    _Ty=BOOL,
    _Ax=std::allocator<BOOL>
    ]

    c:\Ice-2.0.0\include\Ice\BasicStream.h(144): error C2535: 'void IceInternal::BasicStream::write(BOOL)' : member function already defined or declared

    c:\Ice-2.0.0\include\Ice\BasicStream.h(145): error C2535: 'void IceInternal::BasicStream::write(const std::vector<_Ty,_Ax> &)' : member function already defined or declared
    with
    [
    _Ty=BOOL,
    _Ax=std::allocator<BOOL>
    ]

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xutility(168): error C2766: explicit specialization; 'std::iterator_traits<std::_Bool>' has already been defined

    c:\Ice-2.0.0\include\IceUtil\Mutex.h(141): error C3861: 'TryEnterCriticalSection': identifier not found, even with argument-dependent lookup

    c:\Ice-2.0.0\include\IceUtil\Mutex.h(141): error C3861: 'TryEnterCriticalSection': identifier not found, even with argument-dependent lookup

    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\ostream(604): fatal error C1903: unable to recover from previous error(s); stopping compilation

    e:\Src\swccg\SWCCG\ICE\src\server_main.cpp(28): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data

    e:\Src\swccg\SWCCG\ICE\src\client.cpp(228): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
    I think there's basically two problems here, the duplicate definitions/declarations errors and the 'TryEnterCriticalSection': identifier not found errors.

    The former change when I comment my headers around in my server.cpp file (not main, that's in server_main.cpp) so here they are:
    Code:
    #ifdef WIN32
    	#include "my_global.h"
    	#include <windows.h>
    	#include <wtypes.h>
    #endif
    
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <vector>
    
    using namespace std;
    
    #include "mysql.h"
    #include "message.h"
    #include "server.h"
    
    #include <IceUtil/Mutex.h>
    Any ideas? Tell me if you need more code..

    Thanks in advance,
    Alex

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Alex,

    Welcome to our forums!

    The 'TryEnterCriticalSection' error is quite simple:

    old versions of Windows (before NT 4.0) did not support the system call TryEnterCriticalSection on CriticalSection objects. A default Visual C++ build is compatible with old Windows releases, so it does not provide TryEnterCriticalSection: you need to define _WIN32_WINNT to 0x0400 (or greater) to see this function call.

    In your code, you include windows.h before IceUtil/Config.h, so you get:

    // _WIN32_WINNT not defined, so no TryEnterCriticalSection declaration
    #include <windows.h>

    // In IceUtil/Config.h
    #define _WIN32_WINNT 0x0400
    #include <windows.h> // does nothing

    // In IceUtil/Mutex.h
    # if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400
    // use critical sections and TryEnterCritical section
    #endif

    The solution is to define _WIN32_WINNT to 0x400 before the first inclusion of windows.h. You can do this explicitely, by including any Ice header first in your translation unit, or by adding _WIN32_WINNT=0x400 as a preprocessor definition in your project.

    I don't know for the second error; does it work if you include a Ice header first?

    Cheers,
    Bernard

  3. #3
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22

    Red face

    Yeah, I read that somewhere earlier today, so I changed my server_main.cpp header includes to:
    Code:
    #ifdef WIN32
    	#ifndef _WIN32_WINNT
    		# define _WIN32_WINNT 0x400
    	#endif
    	#include <windows.h>
    	#include <wtypes.h>
    #endif
    
    extern "C" {
    #include <stdlib.h>
    }
    
    #include <Ice/Ice.h>
    #include "SWCCG.h"
    #include <iostream>
    #include <vector>
    #include <time.h>
    
    using namespace std;
    
    #include "server.h"
    #include "auth.h"
    (client_main.cpp is similar)
    (but it still gives me the same errors..)

    But you are talking about including in 'my translation unit' and adding as a preprocessor definition, which is fuzzy to me (and/so I probably did it wrong), could you plz elaborate?

    Thanks again!


    PS. Buildlogs are here and here
    Last edited by pokemoen; 05-24-2005 at 08:45 PM.

  4. #4
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Alex,

    Do you define WIN32?
    If not, I'd recommend to use #ifdef _WIN32, see http://msdn.microsoft.com/library/de...ned_macros.asp.

    Cheers,
    Bernard

  5. #5
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22

    Cool

    Thanks Bernard, I still get "c:\Ice-2.0.0\include\IceUtil\Mutex.h(141): error C3861: 'TryEnterCriticalSection': identifier not found, even with argument-dependent lookup" though

    The rest of the errors have changed slightly while screwing around with it after the first post, so here is an update (pretty much the same I guess..)

    c:\Ice-2.0.0\include\Ice\BasicStream.h(146): error C2535: 'void IceInternal::BasicStream::read(BOOL &)' : member function already defined or declared
    c:\Ice-2.0.0\include\Ice\BasicStream.h(146): error C2535: 'void IceInternal::BasicStream::read(BOOL &)' : member function already defined or declared
    c:\Ice-2.0.0\include\Ice\BasicStream.h(129) : see declaration of 'IceInternal::BasicStream::read'
    c:\Ice-2.0.0\include\Ice\BasicStream.h(147): error C2535: 'void IceInternal::BasicStream::read(std::vector<_Ty,_Ax > &)' : member function already defined or declared
    with
    [
    _Ty=BOOL,
    _Ax=std::allocator<BOOL>
    ]
    c:\Ice-2.0.0\include\Ice\BasicStream.h(147): error C2535: 'void IceInternal::BasicStream::read(std::vector<_Ty,_Ax > &)' : member function already defined or declared
    with
    [
    _Ty=BOOL,
    _Ax=std::allocator<BOOL>
    ]
    c:\Ice-2.0.0\include\Ice\BasicStream.h(137) : see declaration of 'IceInternal::BasicStream::read'
    c:\Ice-2.0.0\include\Ice\BasicStream.h(144): error C2535: 'void IceInternal::BasicStream::write(BOOL)' : member function already defined or declared
    c:\Ice-2.0.0\include\Ice\BasicStream.h(144): error C2535: 'void IceInternal::BasicStream::write(BOOL)' : member function already defined or declared
    c:\Ice-2.0.0\include\Ice\BasicStream.h(145): error C2535: 'void IceInternal::BasicStream::write(const std::vector<_Ty,_Ax> &)' : member function already defined or declared
    with
    [
    _Ty=BOOL,
    _Ax=std::allocator<BOOL>
    ]
    c:\Ice-2.0.0\include\Ice\BasicStream.h(145): error C2535: 'void IceInternal::BasicStream::write(const std::vector<_Ty,_Ax> &)' : member function already defined or declared
    with
    [
    _Ty=BOOL,
    _Ax=std::allocator<BOOL>
    ]
    c:\Ice-2.0.0\include\Ice\BasicStream.h(128) : see declaration of 'IceInternal::BasicStream::write'
    c:\Ice-2.0.0\include\IceUtil\Mutex.h(141): error C3861: 'TryEnterCriticalSection': identifier not found, even with argument-dependent lookup
    Do you think they are related?

    Thanks. Alex.

    Note: I've also tried Ice 2.1.1, same errors.
    Last edited by pokemoen; 05-25-2005 at 04:51 AM.

  6. #6
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    It sounds like you've got some conflicts with the header files. Did you try to include <Ice/Ice.h> first? Something like the following:

    Code:
    #include <Ice/Ice.h>
    #include "SWCCG.h"
    #include <iostream>
    #include <vector>
    #include <time.h>
    
    using namespace std;
    
    #include "server.h"
    #include "auth.h"
    I suspect your problem is coming from the inclusion of "wtypes.h" and some macros which aren't defined. In the wtypes.h file there's the following for instance:

    Code:
    #if !defined(_WIN32) && !defined(_MPPC_)
    // The following code if for Win16 only
    ...
    typedef long BOOL
    ...
    It sounds like for some reasons _WIN32 wouldn't be defined... (but it's supposed to always be defined for Win32 applications).

    Did you try to compile the Ice demos to see if this works?

    Btw, you should also enable "Run-Time Type Info" for your project (from the build log you provided /GR is missing). You can enable this in the project settings -> C/C++ -> Language options.

    Benoit.

  7. #7
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22
    wtypes and windows.h weren't part of the original code (which compiled with the same errors), I added them later, because it fixed some errors I had once in another project... Removing those includes doesn't make a difference. Putting the ICE includes at the top doesn't either :/

    I'll try to compile the demo app(s).

    Thanks for the RTTI tip

  8. #8
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22
    The hello and MFC demo-app compile fine

  9. #9
    DeepDiver's Avatar
    DeepDiver is offline Registered User
    Name: Thomas Mueller
    Organization: Freelance Software Developer
    Project: Project depend on Customers
    Join Date
    Nov 2004
    Location
    Munich, Bavaria, Germany
    Posts
    105
    try to add the define to the project settings
    by doing so you make sure the define is set for all files in your project.

    project settings -> C/C++ -> preprocessor

    add _WIN32_WINNT=0x0500 to the preprocessor definitions

    cu tom

  10. #10
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22
    Thanks DeepDriver, that took care of the 'TryEnterCriticalSection'-error!
    Now for the read() and write() declared/defined errors...?
    I don't have them in my own code, except for __write and __read duplicates (with underscores) in my slice2cpp generated files... but those don't conflict, right?

  11. #11
    DeepDiver's Avatar
    DeepDiver is offline Registered User
    Name: Thomas Mueller
    Organization: Freelance Software Developer
    Project: Project depend on Customers
    Join Date
    Nov 2004
    Location
    Munich, Bavaria, Germany
    Posts
    105
    can we see the build logs again??


    what i can see from the old build logs:
    these errors only occur on compilation of client.cpp and server.cpp.

    can you post the includes of these files?
    Last edited by DeepDiver; 05-25-2005 at 07:43 AM.

  12. #12
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22
    Not so nice for later reference, but I replaced the buildlogs here and here with newer ones.

    Headers used in the above buildlogs:
    client.cpp:
    Code:
    #include <string>
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    
    using namespace std;
    
    #ifdef _WIN32
    	#include "my_global.h"
    #endif
    
    #include "mysql.h"
    #include "client.h"
    #include "client_help.h"
    server.cpp:
    Code:
    #include <IceUtil/Mutex.h>
    
    //#ifdef _WIN32
    //	#include "my_global.h"
    //	#include <windows.h>
    //	#include <wtypes.h>
    //#endif
    
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <vector>
    
    using namespace std;
    
    #include "mysql.h"
    #include "message.h"
    #include "server.h"

  13. #13
    DeepDiver's Avatar
    DeepDiver is offline Registered User
    Name: Thomas Mueller
    Organization: Freelance Software Developer
    Project: Project depend on Customers
    Join Date
    Nov 2004
    Location
    Munich, Bavaria, Germany
    Posts
    105
    from the build log
    Code:
    c:\Ice-2.0.0\include\Ice\BasicStream.h(144) : error C2535: 'void IceInternal::BasicStream::write(BOOL)' : member function already defined or declared
            c:\Ice-2.0.0\include\Ice\BasicStream.h(124) : see declaration of 'IceInternal::BasicStream::write'
    if you have a look at the header/lines you find:
    line 124: void write(bool v)
    line 144: void write(Ice::Int);

    this means somewhere in your headers BOOL is defined to the same native type as Ice::Int

    can you show us "my_globals.h"

  14. #14
    pokemoen is offline Registered User
    Name: Alex Man
    Organization: None
    Project: SWCCG
    Join Date
    May 2005
    Posts
    22
    It's a mysql headerfile that needs to be included (in windows) before mysql.h is included.

    http://www.jpipes.com/mysqldox/html/...8h-source.html
    That link is pretty much the version (file) I have..

    Lines of interest (maybe?):
    Code:
    00836 typedef char            my_bool; /* Small bool */
    00837 #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
    00838 typedef char            bool;   /* Ordinary boolean values 0 1 */
    00839 #endif

  15. #15
    DeepDiver's Avatar
    DeepDiver is offline Registered User
    Name: Thomas Mueller
    Organization: Freelance Software Developer
    Project: Project depend on Customers
    Join Date
    Nov 2004
    Location
    Munich, Bavaria, Germany
    Posts
    105
    try to re-arrange the includes in client.cpp

    first ice includes - last mysql includes
    should look like:
    Code:
    #include <string>
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    
    using namespace std;
    
    #include "client.h"
    #include "client_help.h"
    
    
    #ifdef _WIN32
    	#include "my_global.h"
    #endif
    
    #include "mysql.h"

Page 1 of 3 1 2 3 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problems to compile Ice-3.3.0
    By peter in forum Help Center
    Replies: 3
    Last Post: 01-21-2009, 10:51 AM
  2. No problem in Vc7.0 client and Vc7.0 Server
    By zhoubin in forum Help Center
    Replies: 0
    Last Post: 11-24-2006, 02:27 AM
  3. problems when compile Ice2.0.0 in redhat 9
    By libaoli in forum Help Center
    Replies: 8
    Last Post: 01-09-2005, 07:40 AM
  4. VC7.1 compile ICE1.5.1 error
    By code in forum Help Center
    Replies: 1
    Last Post: 09-10-2004, 06:59 AM
  5. Compile error, slice2cpp, VC7
    By Kaos in forum Help Center
    Replies: 2
    Last Post: 05-06-2004, 11:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •