Search code examples
c++compiler-errorsmingw-w64poco-librariesmsys2

Error: sigjmp_buf does not name a type. When Compiling my project with Poco C++ libraries


I'm working on a C++ project under Windows10_x86_64. I'm using Poco C++ libraries installed using Msys2 for a MinGW64 compiler. All my project's dependencies were installed successfully by using Msys2.

However when I'm trying to compile my project I got next error:

In file included from /mingw64/include/Poco/Thread_POSIX.h:23,
             from /mingw64/include/Poco/Thread.h:35,
             from /mingw64/include/Poco/ThreadPool.h:22,
             from /mingw64/include/Poco/ActiveStarter.h:22,
             from /mingw64/include/Poco/ActiveMethod.h:24,
             from /mingw64/include/Poco/AbstractEvent.h:25,
             from /mingw64/include/Poco/BasicEvent.h:21,
             from /mingw64/include/Poco/Util/AbstractConfiguration.h:25,
             from /mingw64/include/Poco/Util/LoggingConfigurator.h:24,
             from ../../prompt/common/PLogger.h:41,
             from PLogger.cpp:15:
/mingw64/include/Poco/SignalHandler.h:80:2: error: 'sigjmp_buf' does not name a type; did you mean 'jmp_buf'?
   80 |  sigjmp_buf& jumpBuffer();
      |  ^~~~~~~~~~
      |  jmp_buf
/mingw64/include/Poco/SignalHandler.h:99:3: error: 'sigjmp_buf' does not name a type; did you mean 'jmp_buf'?
   99 |   sigjmp_buf buf;
      |   ^~~~~~~~~~
      |   jmp_buf

After reviewing SignalHandler.h I saw that this file includes:

#include <setjmp.h>

And that file includes:

#include <machine/setjmp.h>

which define sigjmp_buf:

/* POSIX sigsetjmp/siglongjmp macros */
#ifdef _JBTYPE
typedef _JBTYPE sigjmp_buf[_JBLEN+1+((sizeof (_JBTYPE) + sizeof (sigset_t) - 1)
                     /sizeof (_JBTYPE))];
#else
typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
#endif

I'm including:

-Ic:/msys64/usr/include for setjmp.h and machine/setjmp.h and

-Ic:/msys64/mingw64/include for Poco headers

into my Makefile, but the errors persists.

I don't understand where's the error. Thanks in advance.


Solution

  • To compile project files I used statements like:

    g++ -o ../../../../target/build/debug/PLogger.o PLogger.cpp -I../../ -std=c++14 -Werror -pedantic -Wall -Wformat -Winline -Wunused -g -D_DEBUG -DPCOM_EXPORTS -fpic -c
    

    And I resolve this error removing: -std=c++14 option. However I got a new error:

    relocation truncated to fit: R_X86_64_PC32 against undefined symbol
    

    WTF?

    As I said before I'm using Msys2 to port this project to MS Windows (my first experience with Msys2). And I started installing every package manually: gcc, gdb, make, boost, poco, etc.

    My final solution (PROBLEM RESOLVED) was uninstall Msys2 deleting all files from my computer. Reinstall it, and then firstly:

    $ pacman -Syu
    $ pacman -Su
    $ pacman -S mingw-w64-x86_64-toolchain    -> instead of install manually gcc
    ...
    $ pacman -S mingw-w64-x86_64-poco
    $ pacman -S git
    

    Now everything is working fine. Thanks @CookieButter for your comment.