pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.29k stars 2.14k forks source link

Problems during compilation of Poco on Windows with MinGW and Cywgin #1071

Closed Sujamm closed 8 years ago

Sujamm commented 8 years ago

Hi,

I have a project in Qt that works perfectly with Poco libs on linux, I needed to test this project on Windows, so I install Poco on Windows (Virtual Machine).

First I use Cygwin to compile it and the installation ended perfectly with no error what so ever, how ever when I try to run my project I got so errors that let me believe that something when wrong during the installation of Poco.

Here are the errors I'm getting

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:55: error: '_RC_DOWN' 
was not declared in this scope
   FP_ROUND_DOWNWARD_IMPL   = _RC_DOWN
C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:56: error: '_RC_UP' 
was not declared in this scope
   FP_ROUND_UPWARD_IMPL     = _RC_UP

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:57: error: '_RC_NEAR' 
was not declared in this scope
    FP_ROUND_TONEAREST_IMPL  = _RC_NEAR

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:58: error: '_RC_CHOP' 
was not declared in this scope
   FP_ROUND_TOWARDZERO_IMPL = _RC_CHOP

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:-1: In static member function 'static bool 
Poco::FPEnvironmentImpl::isInfiniteImpl(float)':

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:97: error: '_finite' 
was not declared in this scope
  return _finite(value) == 0;
C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:-1: In static member function 'static bool 
Poco::FPEnvironmentImpl::isInfiniteImpl(double)':

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:103: error: '_finite' 
was not declared in this scope
  return _finite(value) == 0;

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:-1: In static member function 'static bool 
Poco::FPEnvironmentImpl::isInfiniteImpl(long double)':

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:109: error: '_finite' 
was not declared in this scope
  return _finite(value) == 0;

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:-1: In static member function 'static bool 
Poco::FPEnvironmentImpl::isNaNImpl(float)':

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:115: error: '_isnan' 
was not declared in this scope
  return _isnan(value) != 0;

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:-1: In static member function 'static bool 
Poco::FPEnvironmentImpl::isNaNImpl(double)':

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:121: error: '_isnan' 
was not declared in this scope
    return _isnan(value) != 0;

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:-1: In static member function 'static bool 
Poco::FPEnvironmentImpl::isNaNImpl(long double)':

C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:127: error: '_isnan' 
was not declared in this scope
  return _isnan(value) != 0;

I also compiled with MinGW, same-thing happened the instalation ended perfectly but when I try to run my project I got the same error.

Any ideas on what could be causing this error ??

zosrothko commented 8 years ago

@AliceCH Poco is not validated with MinGW How did you produce and install Poco on Cygwin? Cmake or GNU Make? What steps did you execute to build/install Poco?

Sujamm commented 8 years ago

When I install Cygwin it shows me a list of libs that Cygwin could install during it's installation and Poco was one of those, I simply selected Poco and click next.

And I read in a stackoverflow that Poco could compile with MinGW here it's the link I follow to install with MinGW: http://stackoverflow.com/questions/14637797/compile-poco-with-mingw-on-windows

aleks-f commented 8 years ago

It will compile with MinGW, people come from time to time, contribute patches and disappear. But that build is not actively maintained

Sujamm commented 8 years ago

ok, so what do you suggest I do ?? How can I compile Poco to make sure it works on windows ??

aleks-f commented 8 years ago

There are many ways, the simplest one being (1) opening each Visual Studio individual solution and building it (VS can be obtained free these days, I hear). Then, there are (2) batch and (3) PowerShell (still somewhat experimental) build scripts as well as (4) CMake support. Note that all of these build using Visual Studio on windows, currently we support it back to 2008 but that will go up to 2012 in the next release. Last but not least, it is not a bad idea to read some documentation, too ;)

zosrothko commented 8 years ago

There are 2 targets platforms of Poco under a Window system:

either using Cygwin but the whole application using Poco will be a Linux based application running above Windows within the Cygwin container

either using VisualStudio and native Win32/x64 API and the whole application will be a WIndows aplication

The error you reported: C:\cygwin\usr\include\Poco\FPEnvironment_WIN32.h:55: error: '_RC_DOWN' was not declared in this scope FP_ROUND_DOWNWARD_IMPL = _RC_DOWN

shows that you are using/compiling your application using the Cygwin distribution but targeted to a Windows platform which cannot work. (C:\cygwin shows the Cygwin distribution of Poco, while FPEnvironment_WIN32.h shows the target compilation platform Windows, which results from defining the constants #elif defined(_WIN32) || defined(_WIN64) #define POCO_OS_FAMILY_WINDOWS 1

Have a look into C:\cygwin\usr\include\Poco\Platform.h

Sujamm commented 8 years ago

Ok, I understand the error now, and yes that's what I'm doing @zosrothko, so I'm going to try to compile with VS. Thanks

Sujamm commented 8 years ago

Hi, so I try to build Poco in the Command Prompt of Visual Studio. I run this command line to build it: buildwin.cmd 100 build static_mt both x64 samples tests msbuild

But I'm getting an error with the WinTestRunner_x64_vs100.vcxproj

1>obj64\debug_static_mt\WinTestRunner.res : fatal error LNK1123: failure d
   uring conversion to COFF: file invalid or corrupt [C:\Users\admin\Downlo
   ads\poco-1.6.1\CppUnit\WinTestRunner\WinTestRunner_x64_vs100.vcxproj]
 1>Compilación del proyecto terminada "C:\Users\admin\Downloads\poco-1.6.1\
   CppUnit\WinTestRunner\WinTestRunner_x64_vs100.vcxproj" (build destinos)
   -- ERROR.

ERROR al compilar.

   "C:\Users\admin\Downloads\poco-1.6.1\CppUnit\WinTestRunner\WinTestRunner
   _x64_vs100.vcxproj" (build destino) (1) ->
   (Lib destino) ->
     obj64\debug_static_mt\WinTestRunner.res : fatal error LNK1123: failure
    during conversion to COFF: file invalid or corrupt [C:\Users\admin\Down
   loads\poco-1.6.1\CppUnit\WinTestRunner\WinTestRunner_x64_vs100.vcxproj]

Again not idea why I'm getting this error, I try removing CppUnit and CppUnit\WinTestRunner from the components file but I kept getting the same error.

aleks-f commented 8 years ago

Check your environment: VS2012 RC installation breaks VS2010 C++ projects

Sujamm commented 8 years ago

Ok I'm going to check that, one quick question, Poco could be build in Visual Studio 2015 ?? or what it's the newest version of VS that supports poco ??

obiltschnig commented 8 years ago

2015 is fine, although all versions back to 2008 work.

Sujamm commented 8 years ago

I was seen which file to run in VS 2015 to compile poco, I was thinking about using the buildwin.cmd and pass the parameters, because I don't seem to find the one for VS 2015, so it will be something like this

buildwin.cmd 140 build static_mt both Win32 samples tests msbuild

it's this the correct way to do it for VS 2015 ?? Because I try to compile it in VS 2010 but it didn't work with Qt creator and c++14 when I added the libs. So I'm not sure if it was something I did in the compilation.

zosrothko commented 8 years ago

You can also install poco-1.6.1 with the VS2013 msi installer located here https://github.com/pocoproject/distro/releases/download/Poco-1.6.1/VS2013.Poco.1.6.1.x86.msi

Sujamm commented 8 years ago

No matter how I compile poco I'm still getting the same error when I try to run my qt project.

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:55: 
error: '_RC_DOWN' was not declared in this scope
   FP_ROUND_DOWNWARD_IMPL   = _RC_DOWN,

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:56: 
error: '_RC_UP' was not declared in this scope
   FP_ROUND_UPWARD_IMPL     = _RC_UP

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:57:
 error: '_RC_NEAR'  was not declared in this scope
    FP_ROUND_TONEAREST_IMPL  = _RC_NEAR

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:58: 
error: '_RC_CHOP' was not declared in this scope
   FP_ROUND_TOWARDZERO_IMPL = _RC_CHOP

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:-1: 
In static member function 'static bool 
Poco::FPEnvironmentImpl::isInfiniteImpl(float)':

 C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h97: 
error: '_finite' was not declared in this scope
   return _finite(value) == 0;

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:-1: 
In static member function 'static bool 
Poco::FPEnvironmentImpl::isInfiniteImpl(double)':

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:103:
error: '_finite' was not declared in this scope
  return _finite(value) == 0;

 C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:-1:
 In static member function 'static bool 
 Poco::FPEnvironmentImpl::isInfiniteImpl(long double)':

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:109: 
error: '_finite' was not declared in this scope
  return _finite(value) == 0;

 C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:-1: 
 In static member function 'static bool 
 Poco::FPEnvironmentImpl::isNaNImpl(float)':

 C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h115: 
 error: '_isnan'  was not declared in this scope
    return _isnan(value) != 0;

 C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:-1: 
 In static member function 'static bool 
 Poco::FPEnvironmentImpl::isNaNImpl(double)':

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h121: 
error: '_isnan' was not declared in this scope
    return _isnan(value) != 0;

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:-1: 
In static member function 'static bool 
Poco::FPEnvironmentImpl::isNaNImpl(long double)':

C:\poco-1.6.1\include\Poco\FPEnvironment_WIN32.h:127: 
error: '_isnan' was not declared in this scope
  return _isnan(value) != 0;

I compile poco with VS2015 and got this error, then I try with the .msi that @zosrothko suggested and got the same error. It's there a problem with qt creator and poco (for windows)??

aleks-f commented 8 years ago

Those are all defined/declared in <float.h> and poco obviously has no problem finding them. This is probably a question for QT forum, but I'd suggest to make sure that your build environment sees C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt\? That's where that header is.

ongbe commented 8 years ago

the same question

$ gcc -v Using built-in specs. COLLECT_GCC=F:\tc\msys2\mingw32\bin\gcc.exe COLLECT_LTO_WRAPPER=F:/tc/msys2/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/lto-wrapper.exe Target: i686-w64-mingw32 Configured with: ../gcc-5.2.0/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --with-gxx-include-dir=/mingw32/include/c++/5.2.0 --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='Rev4, Built by MSYS2 project' --with-bugurl=http://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2 Thread model: posix gcc version 5.2.0 (Rev4, Built by MSYS2 project)

DaJunkie commented 8 years ago

I solved this issue, using this UNdefinition: -U__STRICT_ANSI__ This hurts a lot.

zosrothko commented 8 years ago

@DaJunkie What do you mean by "This hurts a lot."?

DaJunkie commented 8 years ago

@zosrothko I do not want to do things like that. It feels wrong. It is against my sense for aesthetics. Not meant offending.

I would be lucky if you could find some better solution. iirc I did not need to do that in Poco 1.4.6p4.

And I just read this: "Written in efficient, modern, 100% ANSI/ISO Standard C++." I think this not anymore correct.

TotteKarlsson commented 8 years ago

I'm having the same error trying to compile Poco 1.7.4 using Borlands CLANG compiler. Any pointers how to get past this error? I tried the undef mentioned above but that did not work.

bigfatbrowncat commented 7 years ago

Thank you, @DaJunkie. -U__STRICT_ANSI__ works like a charm. I have to say that the compilation works without this undefinition on old C++ standard. The problem appears after you specify -std=c++11.

It looks like the standard library became more strict after enabling C++11 standard.