Giter Site home page Giter Site logo

build fails on VS2015 about libpqxx HOT 16 CLOSED

jtv avatar jtv commented on July 17, 2024
build fails on VS2015

from libpqxx.

Comments (16)

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024 1

@pembeci

svn co svn://pqxx.org/libpqxx/trunk

revision 1945 just happens to be the latest revision of trunk (basically the same idea as a git commit sha hash)

you can find the link through the website http://pqxx.org/development/libpqxx/wiki/DownloadPage

from libpqxx.

jtv avatar jtv commented on July 17, 2024

Yes, it does sound related to that StackOverflow issue. Basically, it looks like the compiler is compiling a pre-C++11 version of the language. The current master of libpqxx requires C++11.

What's weird about this is that, as far as I know, Visual Studio 2015 should support C++11 by default. What happens if you compile with the /std:c++14 option?

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

looks like the same result, unfortunately

I suspect that MSVC may be broken and or non-standardized for some things in C++11 and onward, which would not surprise me

VS2015 does appear to generally support much of C++11/C++14 by default such as auto etc, but maybe doesn't support other things

C:\libpqxx>nmake -f win32\vc-libpqxx.mak ALL

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

A subdirectory or file ObjStaticDebug already exists.
        cl.exe /nologo /W3 /EHsc /FD /GR /c /std:c++14  /I "include" /I C:\PROGRA~1\POSTGR~1\9.5\include /I C:\PROGRA~1\POSTGR~1\9.5\interfaces\libpq  /D "WIN32" /D "_MBCS" /D "_WINDOWS" /D "PQXX_INTERNAL" /MDd /Gm /ZI /Od /D "_LIB" /D "_DEBUG" /RTC1 /Fo"ObjStaticDebug\\" /Fd"ObjStaticDebug\\" src/binarystring.cxx
binarystring.cxx
c:\libpqxx\include\pqxx\result.hxx(222): warning C4800: 'const pqxx::internal::pq::PGresult *': forcing value to bool 'true' or 'false' (performance warning)
c:\libpqxx\include\pqxx\row.hxx(292): error C2886: 'field': symbol cannot be used in a member using-declaration
c:\libpqxx\include\pqxx\row.hxx(209): note: see declaration of 'field'
c:\libpqxx\include\pqxx\row.hxx(293): error C2886: 'field': symbol cannot be used in a member using-declaration
c:\libpqxx\include\pqxx\row.hxx(209): note: see declaration of 'field'
c:\libpqxx\include\pqxx\result_iterator.hxx(134): error C2886: 'row': symbol cannot be used in a member using-declaration
c:\libpqxx\include\pqxx\result_iterator.hxx(42): note: see declaration of 'row'
c:\libpqxx\include\pqxx\result_iterator.hxx(135): error C2886: 'row': symbol cannot be used in a member using-declaration
c:\libpqxx\include\pqxx\result_iterator.hxx(42): note: see declaration of 'row'
c:\libpqxx\src\binarystring.cxx(57): error C2653: 'internal': is not a class or namespace name
c:\libpqxx\src\binarystring.cxx(57): error C2062: type 'unsigned char' unexpected
c:\libpqxx\src\binarystring.cxx(58): error C2065: 'A': undeclared identifier
c:\libpqxx\src\binarystring.cxx(58): error C2228: left of '.get' must have class/struct/union
c:\libpqxx\src\binarystring.cxx(58): note: type is 'unknown-type'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe"' : return code '0x2'
Stop.

from libpqxx.

jtv avatar jtv commented on July 17, 2024

I thought Microsoft had become a model citizen in C++ Standard land, and was ahead on the curve on these things. So this would surprise me! Is there perhaps some update to VS2015 that you need?

One thing you could try — if you're willing to invest the time — is replace these "using" declarations with classic typedefs. My guess is that you'd run into some other C++11 problem, and that might tell you more about what the problem is. Or perhaps I did something nonstandard with "using".

I would very much like to avoid going back to lots of ifdefs and old-style code to deal with older compilers. I think I'll try a few compile runs with different compilers and settings, to see if maybe I'm accidentally using a compiler extension on my own system.

from libpqxx.

jtv avatar jtv commented on July 17, 2024

Nope, no errors or warnings on g++ or clang, with loads of warning options enabled, and with a strictly standard interpretation of C++11. So VS2015 does look as if it's probably the problem here.

from libpqxx.

pembeci avatar pembeci commented on July 17, 2024

I am getting the same errors with VS2015 freshly installed. I also tried the /std:c++latest flag but same errors. @rocksolidwebdesign, where can I find the "svn trunk rev 1945" you mentioned which correctly builds? What shall I lose if build and use that older version? Thanks.

Support Table For C++11/14/17 Features in Visual C++ (so many changes in C++, so this is over my head but may be helpful):
https://msdn.microsoft.com/en-us/library/hh567368.aspx

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

if I have time I will try to develop a fix for VS2015

@jtv if you can provide some suggestions and direction for me to follow, then that would expedite the process because I may not have time to truly read and understand all the code (not enough time in the next 6 months or more, anyway), but I think if I understand what needs to happen, I can probably write a patch

from libpqxx.

jtv avatar jtv commented on July 17, 2024

@rocksolidwebdesign when you see a declaration like:

using X = Y;

...try replacing it with...

typedef Y X;

That may not cover all cases, but it may help get us to a point where we can see whether the compiler understands C++11 at all. Another thing worth trying might be to compile a minimal C++11 test programme, and see where the compiler objects.

But, based on those feature overviews, I would expect these using declarations to compile. Weird, weird, weird.

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

@jtv ok thanks, I'll try that

I know for certain that VS2015 compiles a large amount (most) of C++14 as I have been working with C++14 features in VS2015 for a while now. I'll try moving to typedefs and report the results.

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

@jtv ok I have fixed the earlier errors with using but now I get an error on this line:

https://github.com/rocksolidwebdesign/libpqxx/blob/master/src/binarystring.cxx#L57

which comes from this statement:

  std::unique_ptr<unsigned char> A(
	PQunescapeBytea(const_cast<unsigned char *>(escaped), &unescaped_len),
	freepqmem_templated<unsigned char>); // THIS IS LINE 57
C:\libpqxx>nmake /f win32\vc-libpqxx.mak STATICDEBUG

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl.exe /nologo /W3 /EHsc /FD /GR /c /std:c++14  /I "include" /I C:\PROGRA~1\POSTGR~1\9.5\include /I C:\PROGRA~1\POSTGR~1\9.5\include  /D "WIN32" /D "_MBCS" /D "_WINDOWS" /D "PQXX_INTERNAL" /MDd /Gm /ZI /Od /D "_LIB" /D "_DEBUG" /RTC1 /Fo"ObjStaticDebug\\" /Fd"ObjStaticDebug\\" src/binarystring.cxx
binarystring.cxx
c:\libpqxx\include\pqxx\result.hxx(222): warning C4800: 'const pqxx::internal::pq::PGresult *': forcing value to bool 'true' or 'false' (performance warning)
c:\libpqxx\src\binarystring.cxx(57): error C2664: 'std::unique_ptr<unsigned char,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': cannot convert argument 2 from 'void (__cdecl *)(P *) noexcept' to 'const std::default_delete<_Ty> &'
        with
        [
            _Ty=unsigned char
        ]
c:\libpqxx\src\binarystring.cxx(57): note: Reason: cannot convert from 'overloaded-function' to 'const std::default_delete<_Ty>'
        with
        [
            _Ty=unsigned char
        ]
c:\libpqxx\src\binarystring.cxx(57): note: No constructor could take the source type, or constructor overload resolution was ambiguous
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe"' : return code '0x2'
Stop.

NOTE: I applied a change removing the explicit internal:: prefix from line 57 as this was causing a different issue and throughout connection_base.cxx these free* functions are referenced without the namespace prefix because there is a using namespace pqxx::internal; statement at the top of the file

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

@jtv good to go!

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

@pembeci can you give this a try and confirm whether you can build on VS2015 now?

from libpqxx.

pembeci avatar pembeci commented on July 17, 2024

Sorry for responding late. Busy days. Thanks @rocksolidwebdesign and @jtv. I'll try within a day or two and let you know.

from libpqxx.

pembeci avatar pembeci commented on July 17, 2024

Yes, your fix compiled well. I didn't test it using in a real VS project but I can see at least the static library:

        link.exe -lib /nologo  "ObjStaticDebug\binarystring.obj"  "ObjStaticDebug\connection.obj"  "ObjStaticDebug\connection_base.obj"  "ObjStaticDebug\cursor.obj"  "ObjStaticDebug\dbtransaction.obj"  "ObjStaticDebug\errorhandler.obj"  "ObjStaticDebug\except.obj"  "ObjStaticDebug\field.obj"  "ObjStaticDebug\largeobject.obj"  "ObjStaticDebug\nontransaction.obj"  "ObjStaticDebug\notification.obj"  "ObjStaticDebug\pipeline.obj"  "ObjStaticDebug\prepared_statement.obj"  "ObjStaticDebug\result.obj"  "ObjStaticDebug\robusttransaction.obj"  "ObjStaticDebug\row.obj"  "ObjStaticDebug\statement_parameters.obj"  "ObjStaticDebug\strconv.obj"  "ObjStaticDebug\subtransaction.obj"  "ObjStaticDebug\tablereader.obj"  "ObjStaticDebug\tablestream.obj"  "ObjStaticDebug\tablewriter.obj"  "ObjStaticDebug\transaction.obj"  "ObjStaticDebug\transaction_base.obj"  "ObjStaticDebug\util.obj"   /out:"lib\libpqxx_staticD.lib"
-------------------------------------------------------------
Copying libpq.dll to lib.

IMPORTANT: you MUST copy this libpq.dll into the directory
... deleted ....
with the program.
-------------------------------------------------------------
        copy ""C:\Program Files\PostgreSQL\10"\lib\libpq.dll" "lib"
The system cannot find the file specified.
NMAKE : fatal error U1077: 'copy' : return code '0x1'
Stop.

D:\libpqxx_new>dir lib
 Volume in drive D is LENOVO
 Volume Serial Number is BABC-90CE

 Directory of D:\libpqxx_new\lib

10/26/2017  04:16 PM    <DIR>          .
10/26/2017  04:16 PM    <DIR>          ..
10/26/2017  04:07 PM                11 .cvsignore
10/26/2017  04:16 PM        15,847,474 libpqxx_staticD.lib

Thanks a lot.

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

@jtv can we merge this as resolved and open new issues for any other outstanding windows related items?

the ALL build with nmake is succeeding for me with on my frozen branch, but it looks like there are some new windows related issues with some recent commits which are unrelated to these fixes, the fixes contained in this PR appear to be good

nmake /f win32\vc-libpqxx.mak ALL

works fine for me on vs2015-fixes-freeze which I cut off of this branch before rebasing on to the latest commits from master

from libpqxx.

rocksolidwebdesign avatar rocksolidwebdesign commented on July 17, 2024

closing as SOLVED

from libpqxx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.