Menu

#114 compilation error vss api, vss.h (vswriter.h vsbackup.h)

v1.0 (example)
closed
nobody
None
5
2016-07-12
2016-06-24
stephane
No

Hi,
I have a little project with a main.cpp that uses vssapi and there is an #include vss.h in the main.cpp.I use mingw64, x86_64,4.8.1.I have two compilation errors :
error:'VSS_RESTORE_TYPE doe"s not name a type in vswriter.h,682
error:'VSS_RESTORE_TYPE has not been declared in vsbackup.h,126
VSS_RESTORE TYPE is declared and defined as typedef enum in vss.h
should I put another compilation option ? or include another vss or COM header ? this project(slight modified) is been well compiled with vs2013, but I need to build with mingw to include later vss in another project.
I compile like this : g++ -D_UNICODE -I"c:\mingw64\x86_64-w64-mingw32\include" -lvssapi -lole32 -loleaut32 main.cpp -o vssessai.exe -municode

Discussion

  • stephane

    stephane - 2016-06-24

    Hi again, I have these include in the main.cpp :

    #include <windows.h>
    #include <tchar.h>
    #include <string.h>
    #include <cstdio>
    #include <comdef.h>
    #include <oleauto.h>
    #include <vss.h>
    
     

    Last edit: stephane 2016-06-24
  • stephane

    stephane - 2016-07-08

    Hi,
    I use now mingw-w64 4.8.4 ,mingw build,sjlj posix because the 4.8.1 and 4.8.2 don't contain the headers of the stl.I have still the issues to compile my main.cpp to test vss (plus another issues with comutil.h).
    I don't understand why the vss and com win32 headers of mingw-w64 are not been compiled
    is there any option of g++ to put when building COM project(because vss is COM technology)?

     
  • stephane

    stephane - 2016-07-08

    the version compiled with vs2013 runs well,I have now tested it and it can copy an open outlook file.but we use mingw-w64 for our projects and I want to compile it with mingw-w64
    has anyone a good idea?

     
  • stephane

    stephane - 2016-07-08

    I attach here the mingw-w64 version of my source file main.cpp

     
  • Jonathan Yong

    Jonathan Yong - 2016-07-09

    Set -D_WIN32_WINNT to at least 0x600.

     
  • stephane

    stephane - 2016-07-11

    Thank you very much Jonathan.it solves the error with VSS_RESTORE_TYPE but I have still an error on comutil.h (with 4.8.1 and 4.8.4).do you have any other idea?

     
  • stephane

    stephane - 2016-07-11

    HI , I have still an error on comutil.h, 242, declaration of olechar *_bstr_t::detach() has a different exception specifier.
    I have added some headers and libraries to my main.cpp and linking options, but I have still the problem with comutil.h

     
  • stephane

    stephane - 2016-07-11

    I have tried to remove the _com_error and the #include <comdef.h> but I have still errors:undefined reference to _imp_conitialize and _imp_conitializesecurity and _imp_sysallocstring and to GUIG_NULL.I have linked with libole32.

     

    Last edit: stephane 2016-07-11
  • Jonathan Yong

    Jonathan Yong - 2016-07-11

    Put your link library AFTER your object. Symbol definition are scanned left to right, so use:
    g++ -Dxxxx main.cpp -lole32 -lxxxx

     
  • stephane

    stephane - 2016-07-11

    ok thank you Jonathan.now the program has been successfully compiled.but it does nothing .(the version compiled with vs2013 runs well and is ok)so I must go on to find why this version is not ok.

     
  • stephane

    stephane - 2016-07-11

    here attached the version that was compiled, but does nothing for mingw-w64 (I have tried too with "\" instead of '/' for the pathnames in the program).I have another version for vs that runs well.

     
  • stephane

    stephane - 2016-07-11

    which pathname take the win32 function of mingw-w64 ? with two '\' or with '/' ?

     
  • Jonathan Yong

    Jonathan Yong - 2016-07-11

    There is no "of mingw-w64", there is only win32 API, so "\".

     
  • stephane

    stephane - 2016-07-12

    ok thanks Jonathan. I have put INFINITE as parameter in the ivssasync::wait() function calls (because it's the default value).but the program doesn't still function.

     
  • stephane

    stephane - 2016-07-12

    there was an error in the program.I have corrected it.it looks nicer but it is still wrong.I attach it...the VS version is OK but not this mingw-w64 version.

     
  • stephane

    stephane - 2016-07-12

    OK it fails with Initializeforbackup. with vs it compiles and runs with initializeforbackup() (empty parameter) but with mingw it doesn't compile without a bstr.what should I put as parameter of initializeforbackup.an empty BSTR ?

     
  • Kai Tietz

    Kai Tietz - 2016-07-12

    Information to be found on https://msdn.microsoft.com/en-us/library/windows/desktop/aa382684(v=vs.85).aspx is not really helpful. I guess that this method has an default initialization of an empty BSTR. But this is just a guess (a good one)

     
  • stephane

    stephane - 2016-07-12

    ok my problem is solved now : with mingw-64 I must do :
    BSTR id=NULL;
    hr = ab->InitializeForBackup(id);
    (with vs2013 :hr = ab->InitializeForBackup();)
    and now the program is ok and runs well.thanks jonathan and kai for your help

     mingw-w64 (mingw build, is my preferred compiler under windows!!!!!!)
    
     
  • Kai Tietz

    Kai Tietz - 2016-07-12

    well, by looking through social networks, it seems to be that default parameter is NULL

     
  • stephane

    stephane - 2016-07-12

    yes, I have a question about vss and mingw-64.is it possible to use vss to backup virtual machine with mingw-w64 under windows XP too.because jonathan told me to put _WIN32_WINNT at least 0x600 (windows vista) .I need vss for windows 7 and later but for xp too.

     
  • Kai Tietz

    Kai Tietz - 2016-07-12

    Well, as long as the DCOM interfaces, which you are creating, are present on your XP box, I don't see a reason why it shouldn't work. But I am not sure if they are by default

     
  • stephane

    stephane - 2016-07-12

    i will use vss perhaps to backup opened used files(that is ok) and to backup virtual machines.I will use it for windows 7 and later but for xp too if it is possible. I am not sure if it is possible to use it for xp.

     
  • stephane

    stephane - 2016-07-12

    ok thanks Kai for your response Kai. my original problem in this ticket is solved, you can close this ticket

     
  • Kai Tietz

    Kai Tietz - 2016-07-12
    • status: open --> closed
     
  • Kai Tietz

    Kai Tietz - 2016-07-12

    Thanks, done.

     

Log in to post a comment.