[Coin-discuss] problems with cross-compiling CoinUtils for Windows

Kish Shen kish.shen at crosscoreop.com
Thu Apr 17 19:40:43 EDT 2008


I don't have any documentation on mingw32msvc, except what could be found on the web.
We use it to build our own system these days, as well as third party libraries (such as the 
COIN libraries). This allow us to use the standard Unix tools such as configure to build 
the binaries for Windows as well.

I believe mingw32msvc is designed to allow you to compile C/C++ programs designed to compile
with MSVC without using MSCV. It thus provide an interface to as many of the MS libraries
as possible --  the binaries generated should run on any Windows box, without additional 
libraries. 

For our own code, we use _WIN32 symbol to select our Windows specific code, as _WIN32 is 
defined for both MSVC and mingw32msvc.  Note that __MINGW32__ is also defined for 
mingw32msvc, so this may not be a good test to determine MinGW CYGWIN compiler 
you mention.

I am not too familiar with all the variations of Unix-like packages for Windows -- what exactly is
the MinGW CYGWIN you are referring to?  I have Cygwin installed on my XP laptop, but this 
seems to provide much more Unix compatibility than MinGW. I don't do any program
development directly on it, but I just checked the gcc I have there, and neither
__MINGW32__ nor _WIN32 are defined for it.

Cheers,

Kish
 
On Thursday 17 April 2008 16:15, Ted Ralphs wrote:
> Laci is correct---definition of the symbol __MSVCRT__ is supposed to
> indicate whether or not the compiler uses the msvcrt.dll library, so
> detecting the definition of this symbol is not the proper way to detect
> what compiler is actually being called or whether that compiler
> understands system calls like gettimeofday(). In particular, the MinGW
> CYGWIN compiler does use msvcrt.dll and thereby defines __MSVCRT__, but
> understands CYGWIN system calls like gettimeofday() rather than the
> MSVC++ calls, so your fix would break compilation with that compiler.
> The correct approach would be to detect whatever symbol is defined by
> the mingw32msvc compiler to indicate its use, e.g., the MinGW CYGWIN
> compiler defines __MINGW32__ and the MSVC++ compile defines _MSC_VER. I
> did some Googling and couldn't find much about the mingw32msvc compiler,
> but it should define some symbol which allows it to be differentiated
> from the MinGW CYGWIN compiler. Can you give us some more information
> about the compiler, so we can implement a proper fix? Is there a Web
> site or documentation anywhere?
> 
> Cheers,
> 
> Ted
> 
> Laszlo Ladanyi wrote:
> > I seem to remember that the __MSVCRT__ was taken off because that caused 
> > problems with some combination of cygwin/msys/gcc/cl, but I may be wrong. If 
> > someone has access to these, could you test that Kish's change does not break 
> > things?
> > 
> > Thanks,
> > --Laci
> > 
> > On Wed, 16 Apr 2008, Kish Shen wrote:
> > 
> >> Hi,
> >>
> >> I cross-compile the COIN libraries for MS Windows using mingw32msvc on a (x86) Linux box.
> >> For recent trunk branch of Cbc, I get a compiler error that gettimeofday() is not defined
> >> when compiling CoinTime.cpp in CoinUtils. The problem seems to be in CoinTime.hpp -- the
> >> wrong definition of CoinGetTimeOfDay() is selected for compiling  -- there is a #if macro
> >> that is currently defined as:
> >>
> >> #if defined(_MSC_VER)
> >>
> >> (line 30 in my copy of CoinTime.hpp)
> >>
> >> which does not seem to catch the cross-compiling case. I modified this back to:
> >>
> >> #if defined(_MSC_VER) || defined(__MSVCRT__)
> >>
> >> which was what was there in older versions of the file that compiled without error.
> >>
> >> With this change, I was able to compile Cbc. Is this the correct fix for the problem?
> >>
> >> Cheers,
> >>
> >> Kish
> >> _______________________________________________
> >> Coin-discuss mailing list
> >> Coin-discuss at list.coin-or.org
> >> http://list.coin-or.org/mailman/listinfo/coin-discuss
> >>
> > _______________________________________________
> > Coin-discuss mailing list
> > Coin-discuss at list.coin-or.org
> > http://list.coin-or.org/mailman/listinfo/coin-discuss
> 
> 



More information about the Coin-discuss mailing list