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

Ted Ralphs ted at lehigh.edu
Thu Apr 17 11:15:02 EDT 2008


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


-- 
Dr. Ted Ralphs
Associate Professor
Industrial and Systems Engineering
Lehigh University
(610)758-4784
ted 'at' lehigh 'dot' edu
coral.ie.lehigh.edu/~ted



More information about the Coin-discuss mailing list