Building wxWidgets Program with MSYS2 + CMake
-
- Earned a small fee
- Posts: 17
- Joined: Mon May 27, 2019 7:37 pm
Building wxWidgets Program with MSYS2 + CMake
I am trying to build a wxWidgets program I made in Linux on Windows 10 using MSYS2 and CMake.
Compilers used are gcc version 9, g++ version 9 of MinGW 64-bit.
I managed to configure the build successfully with this command.
cmake .. -G "MSYS Makefiles" -DwxWidgets_CONFIG_EXECUTABLE=/mingw64/bin/wx-config
Unfortunately, after running make, I get several undefined errors involving cmath functions and wxCRT functions.
I also get an error of WinSock.h being included. The program uses wxWidgets and Boost ASIO.
Any ideas on how to fix this?
Compilers used are gcc version 9, g++ version 9 of MinGW 64-bit.
I managed to configure the build successfully with this command.
cmake .. -G "MSYS Makefiles" -DwxWidgets_CONFIG_EXECUTABLE=/mingw64/bin/wx-config
Unfortunately, after running make, I get several undefined errors involving cmath functions and wxCRT functions.
I also get an error of WinSock.h being included. The program uses wxWidgets and Boost ASIO.
Any ideas on how to fix this?
Re: Building wxWidgets Program with MSYS2 + CMake
Did you get the error when building wxWidgets or your application?
Please post the exact error messages.
Please post the exact error messages.
Use the source, Luke!
-
- Earned a small fee
- Posts: 17
- Joined: Mon May 27, 2019 7:37 pm
Re: Building wxWidgets Program with MSYS2 + CMake
I get the error when building my application.
wxWidgets version is 3.0.4.
wxWidgets version is 3.0.4.
Re: Building wxWidgets Program with MSYS2 + CMake
Please post the exact error messages.
Use the source, Luke!
-
- Earned a small fee
- Posts: 17
- Joined: Mon May 27, 2019 7:37 pm
Re: Building wxWidgets Program with MSYS2 + CMake
Sorry. I read your post too quickly and missed that part.
Warnings
Errors
Winsock error
wxcrt errors
CMath errors
wxWidgets filefn error
Boost ASIO error
Warnings
Code: Select all
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock.h:36,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:92,
from C:/msys64/mingw64/include/wx-3.0/wx/msw/wrapwin.h:65,
from C:/msys64/mingw64/include/wx-3.0/wx/msw/init.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/init.h:58,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:23,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/psdk_inc/_fd_types.h:100:2: warning: #warning "fd_set and associated macros have been defined in sys/types. This can cause runtime problems with W32 sockets" [-Wcpp]
Code: Select all
In file included from C:/msys64/mingw64/include/boost/asio/detail/socket_types.hpp:33,
from C:/msys64/mingw64/include/boost/asio/detail/win_tss_ptr.hpp:23,
from C:/msys64/mingw64/include/boost/asio/detail/tss_ptr.hpp:25,
from C:/msys64/mingw64/include/boost/asio/detail/call_stack.hpp:20,
from C:/msys64/mingw64/include/boost/asio/detail/thread_context.hpp:20,
from C:/msys64/mingw64/include/boost/asio/detail/recycling_allocator.hpp:20,
from C:/msys64/mingw64/include/boost/asio/detail/handler_alloc_helpers.hpp:21,
from C:/msys64/mingw64/include/boost/asio/detail/executor_op.hpp:20,
from C:/msys64/mingw64/include/boost/asio/impl/system_executor.hpp:18,
from C:/msys64/mingw64/include/boost/asio/system_executor.hpp:129,
from C:/msys64/mingw64/include/boost/asio/associated_executor.hpp:21,
from C:/msys64/mingw64/include/boost/asio.hpp:21,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/SimpleSerial.h:12,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/external-orientation-device-serial.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/listener-external.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:54,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
15 | #warning Please include winsock2.h before windows.h
Winsock error
Code: Select all
In file included from C:/msys64/mingw64/include/boost/asio/detail/win_tss_ptr.hpp:23,
from C:/msys64/mingw64/include/boost/asio/detail/tss_ptr.hpp:25,
from C:/msys64/mingw64/include/boost/asio/detail/call_stack.hpp:20,
from C:/msys64/mingw64/include/boost/asio/detail/thread_context.hpp:20,
from C:/msys64/mingw64/include/boost/asio/detail/recycling_allocator.hpp:20,
from C:/msys64/mingw64/include/boost/asio/detail/handler_alloc_helpers.hpp:21,
from C:/msys64/mingw64/include/boost/asio/detail/executor_op.hpp:20,
from C:/msys64/mingw64/include/boost/asio/impl/system_executor.hpp:18,
from C:/msys64/mingw64/include/boost/asio/system_executor.hpp:129,
from C:/msys64/mingw64/include/boost/asio/associated_executor.hpp:21,
from C:/msys64/mingw64/include/boost/asio.hpp:21,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/SimpleSerial.h:12,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/external-orientation-device-serial.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/listener-external.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:54,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/boost/asio/detail/socket_types.hpp:24:4: error: #error WinSock.h has already been included
24 | # error WinSock.h has already been included
Code: Select all
In file included from C:/msys64/mingw64/include/wx-3.0/wx/wxcrtbase.h:37,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:45,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/wctype.h:22:13: error: conflicting declaration 'typedef int wctype_t'
22 | typedef int wctype_t;
| ^~~~~~~~
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:10,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h:7,
from C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.2.0/include/stddef.h:1,
from C:/msys64/mingw64/include/wx-3.0/wx/defs.h:728,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:4,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h:112:24: note: previous declaration as 'typedef short unsigned int wctype_t'
112 | typedef unsigned short wctype_t;
| ^~~~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/string.h:45,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/wx-3.0/wx/wxcrtbase.h: In function 'char* wxStrdup(const char*)':
C:/msys64/mingw64/include/wx-3.0/wx/wxcrtbase.h:687:47: error: '_strdup' was not declared in this scope; did you mean 'strdup'?
687 | inline char* wxStrdup(const char *s) { return wxCRT_StrdupA(s); }
| ^~~~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/wxcrtbase.h: In function 'wchar_t* wxStrdup(const wchar_t*)':
C:/msys64/mingw64/include/wx-3.0/wx/wxcrtbase.h:688:53: error: '_wcsdup' was not declared in this scope; did you mean 'wcsdup'?
688 | inline wchar_t* wxStrdup(const wchar_t *s) { return wxCRT_StrdupW(s); }
| ^~~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/c++/9.2.0/x86_64-w64-mingw32/bits/gthr.h:148,
from C:/msys64/mingw64/include/c++/9.2.0/ext/atomicity.h:35,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:39,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/c++/9.2.0/x86_64-w64-mingw32/bits/gthr-default.h: In function 'int __gthread_yield()':
C:/msys64/mingw64/include/c++/9.2.0/x86_64-w64-mingw32/bits/gthr-default.h:693:10: error: 'sched_yield' was not declared in this scope
693 | return __gthrw_(sched_yield) ();
| ^~~~~~~~
In file included from C:/msys64/mingw64/include/c++/9.2.0/cstdlib:75,
from C:/msys64/mingw64/include/c++/9.2.0/ext/string_conversions.h:41,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:6493,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h: At global scope:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:63:5: error: conflicting declaration 'typedef struct _div_t div_t'
63 | } div_t;
| ^~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/string.h:42,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/stdlib.h:39:3: note: previous declaration as 'typedef struct div_t div_t'
39 | } div_t;
| ^~~~~
In file included from C:/msys64/mingw64/include/c++/9.2.0/cstdlib:75,
from C:/msys64/mingw64/include/c++/9.2.0/ext/string_conversions.h:41,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:6493,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:68:5: error: conflicting declaration 'typedef struct _ldiv_t ldiv_t'
68 | } ldiv_t;
| ^~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/string.h:42,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/stdlib.h:45:3: note: previous declaration as 'typedef struct ldiv_t ldiv_t'
45 | } ldiv_t;
| ^~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/chartype.h:106,
from C:/msys64/mingw64/include/wx-3.0/wx/debug.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/defs.h:734,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:4,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:411:23: error: expected ',' or '...' before numeric constant
411 | int __cdecl abs(int _X);
| ^~
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:412:26: error: expected ',' or '...' before numeric constant
412 | long __cdecl labs(long _X);
| ^~
In file included from C:/msys64/mingw64/include/c++/9.2.0/cstdlib:75,
from C:/msys64/mingw64/include/c++/9.2.0/ext/string_conversions.h:41,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:6493,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:713:15: error: conflicting declaration of C function 'int putenv(const char*)'
713 | int __cdecl putenv(const char *_EnvString) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/string.h:42,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/stdlib.h:205:5: note: previous declaration 'int putenv(char*)'
205 | int putenv (char *__string);
| ^~~~~~
In file included from C:/msys64/mingw64/include/c++/9.2.0/cstdlib:75,
from C:/msys64/mingw64/include/c++/9.2.0/ext/string_conversions.h:41,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:6493,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:727:61: error: conflicting declaration 'typedef struct lldiv_t lldiv_t'
727 | typedef struct { __MINGW_EXTENSION long long quot, rem; } lldiv_t;
| ^~~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/string.h:42,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/stdlib.h:52:3: note: previous declaration as 'typedef struct lldiv_t lldiv_t'
52 | } lldiv_t;
| ^~~~~~~
In file included from C:/msys64/usr/include/errno.h:9,
from C:/msys64/mingw64/include/c++/9.2.0/cerrno:42,
from C:/msys64/mingw64/include/c++/9.2.0/ext/string_conversions.h:44,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:6493,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/sys/errno.h:20:36: error: conflicting declaration 'const char* const _sys_errlist []'
20 | extern __IMPORT const char * const _sys_errlist[];
| ^~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/c++/9.2.0/cstdlib:75,
from C:/msys64/mingw64/include/c++/9.2.0/ext/string_conversions.h:41,
from C:/msys64/mingw64/include/c++/9.2.0/bits/basic_string.h:6493,
from C:/msys64/mingw64/include/c++/9.2.0/string:55,
from C:/msys64/mingw64/include/wx-3.0/wx/stringimpl.h:66,
from C:/msys64/mingw64/include/wx-3.0/wx/unichar.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/strvararg.h:22,
from C:/msys64/mingw64/include/wx-3.0/wx/string.h:46,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:173:38: note: previous declaration as 'char* _sys_errlist [1]'
173 | extern __declspec(dllimport) char *_sys_errlist[1];
| ^~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/string.h:45,
from C:/msys64/mingw64/include/wx-3.0/wx/memory.h:15,
from C:/msys64/mingw64/include/wx-3.0/wx/object.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:16,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h: In function 'FILE* wxFopen(const wxString&, const wxString&)':
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h:754:14: error: '_wfopen' was not declared in this scope; did you mean '_tfopen'?
754 | { return wxCRT_Fopen(path.fn_str(), mode.fn_str()); }
| ^~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h: In function 'FILE* wxFreopen(const wxString&, const wxString&, FILE*)':
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h:756:14: error: '_wfreopen' was not declared in this scope; did you mean '_tfreopen'?
756 | { return wxCRT_Freopen(path.fn_str(), mode.fn_str(), stream); }
| ^~~~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h: In function 'int wxRemove(const wxString&)':
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h:758:14: error: '_wremove' was not declared in this scope; did you mean '_tremove'?
758 | { return wxCRT_Remove(path.fn_str()); }
| ^~~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h: In function 'int wxRename(const wxString&, const wxString&)':
C:/msys64/mingw64/include/wx-3.0/wx/wxcrt.h:760:14: error: '_wrename' was not declared in this scope; did you mean '_trename'?
760 | { return wxCRT_Rename(oldpath.fn_str(), newpath.fn_str()); }
| ^~~~~~~~~~~~
Code: Select all
In file included from C:/msys64/mingw64/include/wx-3.0/wx/math.h:72,
from C:/msys64/mingw64/include/wx-3.0/wx/gdicmn.h:23,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:20,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/c++/9.2.0/cmath: At global scope:
C:/msys64/mingw64/include/c++/9.2.0/cmath:1071:11: error: '::acoshl' has not been declared
1071 | using ::acoshl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1075:11: error: '::asinhl' has not been declared
1075 | using ::asinhl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1079:11: error: '::atanhl' has not been declared
1079 | using ::atanhl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1083:11: error: '::cbrtl' has not been declared
1083 | using ::cbrtl;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1087:11: error: '::copysignl' has not been declared
1087 | using ::copysignl;
| ^~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1091:11: error: '::erfl' has not been declared
1091 | using ::erfl;
| ^~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1095:11: error: '::erfcl' has not been declared
1095 | using ::erfcl;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1099:11: error: '::exp2l' has not been declared
1099 | using ::exp2l;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1103:11: error: '::expm1l' has not been declared
1103 | using ::expm1l;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1107:11: error: '::fdiml' has not been declared
1107 | using ::fdiml;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1111:11: error: '::fmal' has not been declared
1111 | using ::fmal;
| ^~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1115:11: error: '::fmaxl' has not been declared
1115 | using ::fmaxl;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1119:11: error: '::fminl' has not been declared
1119 | using ::fminl;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1127:11: error: '::ilogbl' has not been declared
1127 | using ::ilogbl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1131:11: error: '::lgammal' has not been declared
1131 | using ::lgammal;
| ^~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1136:11: error: '::llrintl' has not been declared
1136 | using ::llrintl;
| ^~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1140:11: error: '::llroundl' has not been declared
1140 | using ::llroundl;
| ^~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1145:11: error: '::log1pl' has not been declared
1145 | using ::log1pl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1149:11: error: '::log2l' has not been declared
1149 | using ::log2l;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1153:11: error: '::logbl' has not been declared
1153 | using ::logbl;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1157:11: error: '::lrintl' has not been declared
1157 | using ::lrintl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1161:11: error: '::lroundl' has not been declared
1161 | using ::lroundl;
| ^~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1165:11: error: '::nanl' has not been declared
1165 | using ::nanl;
| ^~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1169:11: error: '::nearbyintl' has not been declared
1169 | using ::nearbyintl;
| ^~~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1173:11: error: '::nextafterl' has not been declared
1173 | using ::nextafterl;
| ^~~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1175:11: error: '::nexttoward' has not been declared
1175 | using ::nexttoward;
| ^~~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1176:11: error: '::nexttowardf' has not been declared
1176 | using ::nexttowardf;
| ^~~~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1177:11: error: '::nexttowardl' has not been declared
1177 | using ::nexttowardl;
| ^~~~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1181:11: error: '::remainderl' has not been declared
1181 | using ::remainderl;
| ^~~~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1185:11: error: '::remquol' has not been declared
1185 | using ::remquol;
| ^~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1189:11: error: '::rintl' has not been declared
1189 | using ::rintl;
| ^~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1193:11: error: '::roundl' has not been declared
1193 | using ::roundl;
| ^~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1197:11: error: '::scalblnl' has not been declared
1197 | using ::scalblnl;
| ^~~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1201:11: error: '::scalbnl' has not been declared
1201 | using ::scalbnl;
| ^~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1205:11: error: '::tgammal' has not been declared
1205 | using ::tgammal;
| ^~~~~~~
C:/msys64/mingw64/include/c++/9.2.0/cmath:1209:11: error: '::truncl' has not been declared
1209 | using ::truncl;
Code: Select all
In file included from C:/msys64/usr/include/sys/fcntl.h:3,
from C:/msys64/usr/include/fcntl.h:12,
from C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:73,
from C:/msys64/mingw64/include/wx-3.0/wx/utils.h:20,
from C:/msys64/mingw64/include/wx-3.0/wx/cursor.h:69,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:21,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/sys/_default_fcntl.h:186:8: error: redefinition of 'struct flock'
186 | struct flock {
| ^~~~~
In file included from C:/msys64/usr/include/sys/types.h:226,
from C:/msys64/mingw64/include/wx-3.0/wx/defs.h:936,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:4,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/usr/include/machine/types.h:46:8: note: previous definition of 'struct flock'
46 | struct flock {
| ^~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/utils.h:20,
from C:/msys64/mingw64/include/wx-3.0/wx/cursor.h:69,
from C:/msys64/mingw64/include/wx-3.0/wx/event.h:21,
from C:/msys64/mingw64/include/wx-3.0/wx/app.h:19,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxAccess(const wxString&, mode_t)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:528:14: error: '_waccess' was not declared in this scope; did you mean '_taccess'?
528 | { return wxCRT_Access(path.fn_str(), mode); }
| ^~~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxChmod(const wxString&, mode_t)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:530:14: error: '_wchmod' was not declared in this scope; did you mean '_tchmod'?
530 | { return wxCRT_Chmod(path.fn_str(), mode); }
| ^~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxOpen(const wxString&, int, mode_t)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:532:14: error: '_wopen' was not declared in this scope; did you mean 'fwopen'?
532 | { return wxCRT_Open(path.fn_str(), flags, mode); }
| ^~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxStat(const wxString&, _stati64*)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:537:14: error: '_wstati64' was not declared in this scope; did you mean '_stati64'?
537 | { return wxCRT_Stat(path.fn_str(), buf); }
| ^~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxLstat(const wxString&, _stati64*)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:539:14: error: '_wstati64' was not declared in this scope; did you mean '_stati64'?
539 | { return wxCRT_Lstat(path.fn_str(), buf); }
| ^~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxRmDir(const wxString&)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:541:14: error: '_wrmdir' was not declared in this scope; did you mean '_trmdir'?
541 | { return wxCRT_RmDir(path.fn_str()); }
| ^~~~~~~~~~~
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h: In function 'int wxMkDir(const wxString&, mode_t)':
C:/msys64/mingw64/include/wx-3.0/wx/filefn.h:545:14: error: '_wmkdir' was not declared in this scope; did you mean '_tmkdir'?
545 | { return wxCRT_MkDir(path.fn_str()); }
| ^~~~~~~~~~~
In file included from C:/msys64/mingw64/include/wx-3.0/wx/chartype.h:106,
from C:/msys64/mingw64/include/wx-3.0/wx/debug.h:19,
from C:/msys64/mingw64/include/wx-3.0/wx/defs.h:734,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:4,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/x86_64-w64-mingw32/include/float.h: At global scope:
C:/msys64/mingw64/x86_64-w64-mingw32/include/float.h:287:57: error: expected ',' or '...' before numeric constant
287 | _CRTIMP double __cdecl __MINGW_NOTHROW _chgsign (double _X);
Code: Select all
In file included from C:/msys64/mingw64/include/boost/asio/detail/win_static_mutex.hpp:71,
from C:/msys64/mingw64/include/boost/asio/detail/static_mutex.hpp:23,
from C:/msys64/mingw64/include/boost/asio/detail/win_global.hpp:19,
from C:/msys64/mingw64/include/boost/asio/detail/global.hpp:23,
from C:/msys64/mingw64/include/boost/asio/impl/system_executor.hpp:19,
from C:/msys64/mingw64/include/boost/asio/system_executor.hpp:129,
from C:/msys64/mingw64/include/boost/asio/associated_executor.hpp:21,
from C:/msys64/mingw64/include/boost/asio.hpp:21,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/SimpleSerial.h:12,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/external-orientation-device-serial.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/listener-external.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:54,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/boost/asio/detail/impl/win_static_mutex.ipp: In member function 'int boost::asio::detail::win_static_mutex::do_init()':
C:/msys64/mingw64/include/boost/asio/detail/impl/win_static_mutex.ipp:48:3: error: '_snwprintf' was not declared in this scope; did you mean '_sntprintf'?
48 | _snwprintf(
| ^~~~~~~~~~
| _sntprintf
In file included from C:/msys64/mingw64/include/boost/asio/detail/win_thread.hpp:142,
from C:/msys64/mingw64/include/boost/asio/detail/thread.hpp:28,
from C:/msys64/mingw64/include/boost/asio/detail/scheduler.hpp:28,
from C:/msys64/mingw64/include/boost/asio/system_context.hpp:19,
from C:/msys64/mingw64/include/boost/asio/impl/system_executor.hpp:22,
from C:/msys64/mingw64/include/boost/asio/system_executor.hpp:129,
from C:/msys64/mingw64/include/boost/asio/associated_executor.hpp:21,
from C:/msys64/mingw64/include/boost/asio.hpp:21,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/SimpleSerial.h:12,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/external-orientation-device-serial.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/listener-external.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:54,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/boost/asio/detail/impl/win_thread.ipp: In member function 'void boost::asio::detail::win_thread::start_thread(boost::asio::detail::win_thread::func_base*, unsigned int)':
C:/msys64/mingw64/include/boost/asio/detail/impl/win_thread.ipp:90:40: error: '::_beginthreadex' has not been declared
90 | thread_ = reinterpret_cast<HANDLE>(::_beginthreadex(0,
| ^~~~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/boost/asio/detail/fd_set_adapter.hpp:23,
from C:/msys64/mingw64/include/boost/asio/detail/select_reactor.hpp:27,
from C:/msys64/mingw64/include/boost/asio/detail/win_iocp_socket_service.hpp:35,
from C:/msys64/mingw64/include/boost/asio/basic_socket.hpp:34,
from C:/msys64/mingw64/include/boost/asio/basic_datagram_socket.hpp:20,
from C:/msys64/mingw64/include/boost/asio.hpp:24,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/SimpleSerial.h:12,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/external-orientation-device-serial.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/listener-external.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:54,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/boost/asio/detail/win_fd_set_adapter.hpp: In member function 'bool boost::asio::detail::win_fd_set_adapter::is_set(boost::asio::detail::socket_type) const':
C:/msys64/mingw64/include/boost/asio/detail/win_fd_set_adapter.hpp:83:14: error: '__WSAFDIsSet' was not declared in this scope
83 | return !!__WSAFDIsSet(descriptor,
| ^~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/c++/9.2.0/future:39,
from C:/msys64/mingw64/include/boost/asio/detail/future.hpp:20,
from C:/msys64/mingw64/include/boost/asio/packaged_task.hpp:19,
from C:/msys64/mingw64/include/boost/asio.hpp:104,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/SimpleSerial.h:12,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/external-orientation-device-serial.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/listener-external.h:5,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/include/osgViewerWX.h:54,
from C:/msys64/home/camac/source_builds/binaural-audio-editor/src/osgViewerWX.cpp:1:
C:/msys64/mingw64/include/c++/9.2.0/thread: In function 'void std::this_thread::sleep_for(const std::chrono::duration<_Rep1, _Period1>&)':
C:/msys64/mingw64/include/c++/9.2.0/thread:378:11: error: '::nanosleep' has not been declared
378 | while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
Re: Building wxWidgets Program with MSYS2 + CMake
What headers are included by your application?
If you include "windows.h" you need to replace that with the wx header file that wraps that include.
It is called something like "wx/wrapwin.h".
Edit: Looks like this is not the cause of the error.
Can you post a small program that has this error?
Tim S.
If you include "windows.h" you need to replace that with the wx header file that wraps that include.
It is called something like "wx/wrapwin.h".
Edit: Looks like this is not the cause of the error.
Can you post a small program that has this error?
Tim S.
-
- Earned a small fee
- Posts: 17
- Joined: Mon May 27, 2019 7:37 pm
Re: Building wxWidgets Program with MSYS2 + CMake
The headers are in main.h and SimpleSerial.h .
Here is a small program that uses the same headers and gives the same errors.
main.h
main.cpp
SimpleSerial.h
CMakeLists.txt
Here is a small program that uses the same headers and gives the same errors.
main.h
Code: Select all
#ifndef _OSGVIEWERWX_H_
#define _OSGVIEWERWX_H_
#include "wx/defs.h"
#include "wx/app.h"
#include "wx/cursor.h"
#include "wx/glcanvas.h" //to work with openscenegraph opengl
#include <osgViewer/Viewer>
#include <string>
#include <wx/filedlg.h> //for file dialog
#include <wx/listctrl.h> //for popup menu
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/image.h>
#include <wx/menu.h>
#include <wx/thread.h> //for wxIsMainThread function
#include <osgViewer/ViewerEventHandlers>
#include <osgDB/ReadFile>
#include <osg/ShapeDrawable>
#include <osg/Geode>
#include <osg/PositionAttitudeTransform>
#include <osg/Group>
#include <osgGA/OrbitManipulator>
#include <osgGA/TrackballManipulator>
#include <iostream>
#include <memory> //for unique_ptr use
#include <sstream> //for string stream
#include "SimpleSerial.h"
class GraphicsWindowWX;
class OSGCanvas : public wxGLCanvas
{
public:
OSGCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("Test Editor Canvas"),
int *attributes = 0);
virtual ~OSGCanvas();
void SetGraphicsWindow(osgViewer::GraphicsWindow *gw) { _graphics_window = gw; }
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnEraseBackground(wxEraseEvent& event);
//where camera viewer gets manipulated by mouse movements
void OnChar(wxKeyEvent &event);
void OnKeyUp(wxKeyEvent &event);
void OnKeyDown(wxKeyEvent& event);
void OnMouseEnter(wxMouseEvent &event);
void OnMouseDown(wxMouseEvent &event);
void OnMouseUp(wxMouseEvent &event);
void OnMouseMotion(wxMouseEvent &event);
void OnMouseWheel(wxMouseEvent &event);
void UseCursor(bool value);
void SetContextCurrent();
void SetReferenceToFunctionToRunKeydown(std::function < void(int&)> thisFunction);
private:
DECLARE_EVENT_TABLE()
osg::ref_ptr<osgViewer::GraphicsWindow> _graphics_window;
wxCursor _oldCursor;
wxGLContext _context;
std::function < void(int&) > functionToRunKeyDown;
};
class GraphicsWindowWX : public osgViewer::GraphicsWindow
{
public:
GraphicsWindowWX(OSGCanvas *canvas);
~GraphicsWindowWX();
void init();
//
// GraphicsWindow interface
//
void grabFocus();
void grabFocusIfPointerInWindow();
void useCursor(bool cursorOn);
bool makeCurrentImplementation();
void swapBuffersImplementation();
// not implemented yet...just use dummy implementation to get working.
virtual bool valid() const { return true; }
virtual bool realizeImplementation() { return true; }
virtual bool isRealizedImplementation() const { return _canvas->IsShownOnScreen(); }
virtual void closeImplementation() {}
virtual bool releaseContextImplementation() { return true; }
private:
// XXX need to set _canvas to NULL when the canvas is deleted by
// its parent. for this, need to add event handler in OSGCanvas
OSGCanvas* _canvas;
};
class MainFrame : public wxFrame
{
public:
MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
//for connecting mainframe to wxOsgApp
void SetViewer(osgViewer::Viewer *viewer);
void SetRootNode(osg::Group* root);
// Mainframe menu operations
void OnOpen(wxCommandEvent& WXUNUSED(event));
void OnIdle(wxIdleEvent& event);
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnListRightClick(wxListEvent &evt);
void OnPopupClick(wxCommandEvent &evt);
void OnKeyDown(wxKeyEvent& event); //where camera viewer gets manipulated
private:
osg::ref_ptr<osgViewer::Viewer> _viewer;
osg::ref_ptr<osg::Group> _rootNode;
DECLARE_EVENT_TABLE()
};
/* Define a new application type */
//the main of the application
class wxOsgApp : public wxApp
{
public:
bool OnInit();
void KeyDownLogic(int& thisKey);
private:
osg::ref_ptr<osg::Group> rootNode; //geometry node to hold ShapeDrawable objects
osg::ref_ptr<osgGA::TrackballManipulator> cameraManipulator; //pointer to camera manipulator
};
#endif // _WXSIMPLEVIEWERWX_H_
Code: Select all
#include "main.h"
// `Main program' equivalent, creating windows and returning main app frame
bool wxOsgApp::OnInit()
{
/*
if (argc<2)
{
std::cout << wxString(argv[0]).mb_str() <<": requires filename argument." << std::endl;
return false;
}
*/
//initialize graphical stuff
int width = 800;
int height = 600;
// Create the main frame window
MainFrame *frame = new MainFrame(NULL, wxT("Test"),
wxDefaultPosition, wxSize(width, height));
// create osg canvas
// - initialize
int attributes[7];
attributes[0] = int(WX_GL_DOUBLEBUFFER);
attributes[1] = WX_GL_RGBA;
attributes[2] = WX_GL_DEPTH_SIZE;
attributes[3] = 8;
attributes[4] = WX_GL_STENCIL_SIZE;
attributes[5] = 8;
attributes[6] = 0;
OSGCanvas *canvas = new OSGCanvas(frame, wxID_ANY, wxDefaultPosition,
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
//set function KeyDownLogic to be called every time key pressed event happens in OSGCanvas
using std::placeholders::_1;
std::function<void(int&)> func = std::bind( &wxOsgApp::KeyDownLogic, this, _1 );
canvas->SetReferenceToFunctionToRunKeydown(func);
GraphicsWindowWX* gw = new GraphicsWindowWX(canvas);
canvas->SetGraphicsWindow(gw);
osgViewer::Viewer *viewer = new osgViewer::Viewer;
viewer->getCamera()->setGraphicsContext(gw);
viewer->getCamera()->setViewport(0,0,width,height);
// set the draw and read buffers up for a double buffered window with rendering going to back buffer
viewer->getCamera()->setDrawBuffer(GL_BACK);
viewer->getCamera()->setReadBuffer(GL_BACK);
//viewer->addEventHandler(new osgViewer::StatsHandler);
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
//init geommetry node which is a leaf node of scenegraph
//containing geometry information
rootNode = new osg::Group;
frame->SetRootNode(rootNode);
//initialize viewer
viewer->setSceneData(rootNode.get());
//Initialize and set camera manipulator
cameraManipulator = new osgGA::TrackballManipulator();
viewer->setCameraManipulator(cameraManipulator);
//Set camera to look at listener 10 units above origin and behind origin
osg::Vec3d eye( 0.0, 10.0, 10.0 ); //The position of your camera -can be used to set its height position.
osg::Vec3d center( 0.0, 0.0, 0.0 ); // The point your camera is looking at - set this to the center of the observed object.
// The up-vector of your camera -
//this controls how your viewport will be rotated about its center
//and should be equal to [0, 1, 0] OpenAL Soft coordinate system
osg::Vec3d up( 0.0, 1.0, 0.0 );
cameraManipulator->setTransformation(eye,center,up);
frame->SetViewer(viewer);
/* Show the frame */
frame->Show(true);
return true;
}
void wxOsgApp::KeyDownLogic(int& thisKey)
{
//std::cout << "KeyDown Logic called in wxOsgApp.\n";
}
IMPLEMENT_APP(wxOsgApp)
//Event table for main frame specific events
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_IDLE (MainFrame::OnIdle)
EVT_MENU (wxID_EXIT, MainFrame::OnExit)
EVT_MENU (wxID_ABOUT, MainFrame::OnAbout)
EVT_MENU (wxID_OPEN, MainFrame::OnOpen)
//EVT_KEY_DOWN (MainFrame::OnKeyDown)
END_EVENT_TABLE()
/* My frame constructor */
MainFrame::MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
const wxSize& size,long style)
: wxFrame(frame, wxID_ANY, title, pos, size, style)
{
//create file menu item
wxMenu *menuFile = new wxMenu;
menuFile->Append(wxID_EXIT);
//create help menu item
wxMenu *menuHelp = new wxMenu;
menuHelp->Append(wxID_ABOUT);
//create and set menu bar with items file and help
wxMenuBar *menuBar = new wxMenuBar;
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( "Welcome to Test!" );
}
void MainFrame::SetViewer(osgViewer::Viewer *viewer){_viewer = viewer;}
void MainFrame::SetRootNode(osg::Group *root){_rootNode = root;}
void MainFrame::OnIdle(wxIdleEvent &event)
{
if (!_viewer->isRealized())
return;
_viewer->frame();
event.RequestMore();
//std::cout << "App is Idle." << std::endl;
}
void MainFrame::OnExit(wxCommandEvent& event)
{
Close( true ); //close window
}
void MainFrame::OnAbout(wxCommandEvent& event)
{
//show message box with ok icon,
//window title:About Binaural Audio Editor
//message:
wxMessageBox( "Version 0.0 of Binaural Audio Editor. \n This program is for producing and editing binaural audio from mono or stereo samples of audio.",
"About Binaural Audio Editor", wxOK | wxICON_INFORMATION );
}
void MainFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
{
wxFileDialog fileDlg(this, _("Choose the WAV file"), wxEmptyString, wxEmptyString, _("WAV file|*.wav|All files|*.*"));
if (fileDlg.ShowModal() == wxID_OK)
{
wxString path = fileDlg.GetPath();
//use this path in your app
}
}
void MainFrame::OnPopupClick(wxCommandEvent& evt)
{
//void *data=static_cast<wxMenu *>( evt.GetEventObject() )->GetClientData();
//switch(evt.GetId())
//{
// case ID_SOMETHING:{break;}
// case ID_SOMETHING_ELSE:{break;}
//}
}
void MainFrame::OnListRightClick(wxListEvent& evt)
{
void *data = reinterpret_cast<void *>(evt.GetItem().GetData());
wxMenu menu;
menu.SetClientData( data );
menu.Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPopupClick), NULL, this);
PopupMenu(&menu);
}
void MainFrame::OnKeyDown(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
std::cout << "KeyDown:" << key << std::endl;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////// ///////////////////////////////////////////////////////////////////
///////////////////////OSGCanvas///////////////////////////////////////////////////////////////////
/////////////////////// ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//OSGCanvas event table for openscenegraph specific events
BEGIN_EVENT_TABLE(OSGCanvas, wxGLCanvas)
EVT_SIZE (OSGCanvas::OnSize)
EVT_PAINT (OSGCanvas::OnPaint)
EVT_ERASE_BACKGROUND (OSGCanvas::OnEraseBackground)
EVT_CHAR (OSGCanvas::OnChar)
EVT_KEY_UP (OSGCanvas::OnKeyUp)
EVT_KEY_DOWN (OSGCanvas::OnKeyDown)
EVT_ENTER_WINDOW (OSGCanvas::OnMouseEnter)
EVT_LEFT_DOWN (OSGCanvas::OnMouseDown)
EVT_MIDDLE_DOWN (OSGCanvas::OnMouseDown)
EVT_RIGHT_DOWN (OSGCanvas::OnMouseDown)
EVT_LEFT_UP (OSGCanvas::OnMouseUp)
EVT_MIDDLE_UP (OSGCanvas::OnMouseUp)
EVT_RIGHT_UP (OSGCanvas::OnMouseUp)
EVT_MOTION (OSGCanvas::OnMouseMotion)
EVT_MOUSEWHEEL (OSGCanvas::OnMouseWheel)
END_EVENT_TABLE()
OSGCanvas::OSGCanvas(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attributes)
: wxGLCanvas(parent, id, attributes, pos, size, style|wxFULL_REPAINT_ON_RESIZE, name)
,_context(this)
{
// default cursor to standard
_oldCursor = *wxSTANDARD_CURSOR;
}
OSGCanvas::~OSGCanvas()
{
}
void OSGCanvas::SetContextCurrent(){_context.SetCurrent(*this);}
void OSGCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
/* must always be here */
wxPaintDC dc(this);
}
void OSGCanvas::OnSize(wxSizeEvent& event)
{
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int width, height;
GetClientSize(&width, &height);
if (_graphics_window.valid())
{
// update the window dimensions, in case the window has been resized.
_graphics_window->getEventQueue()->windowResize(0, 0, width, height);
_graphics_window->resized(0,0,width,height);
}
}
void OSGCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
/* Do nothing, to avoid flashing on MSW */
}
void OSGCanvas::OnChar(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
//if (_graphics_window.valid())
// _graphics_window->getEventQueue()->keyPress(key);
// If this key event is not processed here, we should call
// event.Skip() to allow processing to continue.
}
void OSGCanvas::OnKeyUp(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
if (_graphics_window.valid())
_graphics_window->getEventQueue()->keyRelease(key);
// If this key event is not processed here, we should call
// event.Skip() to allow processing to continue.
}
void OSGCanvas::OnKeyDown(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
//std::cout << "keydown in OSGCanvas, key:" << key << std::endl;
//call function to run after key pressed down
functionToRunKeyDown(key);
if (_graphics_window.valid())
_graphics_window->getEventQueue()->keyRelease(key);
// If this key event is not processed here, we should call event.skip to allow processing to continue
event.Skip();
}
void OSGCanvas::OnMouseEnter(wxMouseEvent & /*event*/)
{
// Set focus to ourselves, so keyboard events get directed to us
SetFocus();
}
void OSGCanvas::OnMouseDown(wxMouseEvent &event)
{
if (_graphics_window.valid())
{
_graphics_window->getEventQueue()->mouseButtonPress(event.GetX(), event.GetY(),
event.GetButton());
}
}
void OSGCanvas::OnMouseUp(wxMouseEvent &event)
{
if (_graphics_window.valid())
{
_graphics_window->getEventQueue()->mouseButtonRelease(event.GetX(), event.GetY(),
event.GetButton());
}
}
void OSGCanvas::OnMouseMotion(wxMouseEvent &event)
{
if (_graphics_window.valid())
_graphics_window->getEventQueue()->mouseMotion(event.GetX(), event.GetY());
}
void OSGCanvas::OnMouseWheel(wxMouseEvent &event)
{
int delta = event.GetWheelRotation() / event.GetWheelDelta() * event.GetLinesPerAction();
if (_graphics_window.valid()) {
_graphics_window->getEventQueue()->mouseScroll(
delta>0 ?
osgGA::GUIEventAdapter::SCROLL_UP :
osgGA::GUIEventAdapter::SCROLL_DOWN);
}
}
void OSGCanvas::UseCursor(bool value)
{
if (value)
{
// show the old cursor
SetCursor(_oldCursor);
}
else
{
// remember the old cursor
_oldCursor = GetCursor();
// hide the cursor
// - can't find a way to do this neatly, so create a 1x1, transparent image
wxImage image(1,1);
image.SetMask(true);
image.SetMaskColour(0, 0, 0);
wxCursor cursor(image);
SetCursor(cursor);
// On wxGTK, only works as of version 2.7.0
// (http://trac.wxwidgets.org/ticket/2946)
// SetCursor( wxStockCursor( wxCURSOR_BLANK ) );
}
}
void OSGCanvas::SetReferenceToFunctionToRunKeydown(std::function <void(int&)> thisFunction)
{
functionToRunKeyDown = thisFunction;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////// /////////////////////////////////////////////////////////////
///////////////////////GraphicsWindowX///////////////////////////////////////////////////////////////////
/////////////////////// ////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
GraphicsWindowWX::GraphicsWindowWX(OSGCanvas *canvas)
{
_canvas = canvas;
_traits = new GraphicsContext::Traits;
wxPoint pos = _canvas->GetPosition();
wxSize size = _canvas->GetSize();
_traits->x = pos.x;
_traits->y = pos.y;
_traits->width = size.x;
_traits->height = size.y;
init();
}
GraphicsWindowWX::~GraphicsWindowWX()
{
}
void GraphicsWindowWX::init()
{
if (valid())
{
setState( new osg::State );
getState()->setGraphicsContext(this);
if (_traits.valid() && _traits->sharedContext.valid())
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
}
}
}
void GraphicsWindowWX::grabFocus()
{
// focus the canvas
_canvas->SetFocus();
}
void GraphicsWindowWX::grabFocusIfPointerInWindow()
{
// focus this window, if the pointer is in the window
wxPoint pos = wxGetMousePosition();
if (wxFindWindowAtPoint(pos) == _canvas)
_canvas->SetFocus();
}
void GraphicsWindowWX::useCursor(bool cursorOn)
{
_canvas->UseCursor(cursorOn);
}
bool GraphicsWindowWX::makeCurrentImplementation()
{
_canvas->SetContextCurrent();
return true;
}
void GraphicsWindowWX::swapBuffersImplementation()
{
_canvas->SwapBuffers();
}
Code: Select all
/*
* File: SimpleSerial.h
* Author: Terraneo Federico
* Distributed under the Boost Software License, Version 1.0.
*
* Created on September 10, 2009, 12:12 PM
*/
#ifndef _SIMPLESERIAL_H
#define _SIMPLESERIAL_H
#include <boost/asio.hpp>
class SimpleSerial
{
public:
/**
* Constructor.
* \param port device name, example "/dev/ttyUSB0" or "COM4"
* \param baud_rate communication speed, example 9600 or 115200
* \throws boost::system::system_error if cannot open the
* serial device
*/
SimpleSerial(std::string port, unsigned int baud_rate)
: io(), serial(io,port)
{
serial.set_option(boost::asio::serial_port_base::baud_rate(baud_rate));
}
/**
* Write a string to the serial device.
* \param s string to write
* \throws boost::system::system_error on failure
*/
void writeString(std::string s)
{
boost::asio::write(serial,boost::asio::buffer(s.c_str(),s.size()));
}
/**
* Blocks until a line is received from the serial device.
* Eventual '\n' or '\r\n' characters at the end of the string are removed.
* \return a string containing the received line
* \throws boost::system::system_error on failure
*/
std::string readLine()
{
//Reading data char by char, code is optimized for simplicity, not speed
char c;
std::string result;
for(;;)
{
boost::asio::read(serial,boost::asio::buffer(&c,1));
switch(c)
{
case '\r':
break;
case '\n':
return result;
default:
result+=c;
}
}
}
private:
boost::asio::io_service io;
boost::asio::serial_port serial;
};
#endif /* _SIMPLESERIAL_H */
Code: Select all
cmake_minimum_required(VERSION 3.1.1)
set (CMAKE_CXX_STANDARD 11)
set(PROJECT_NAME test)
project (${PROJECT_NAME} LANGUAGES C CXX)
#For vcpkg use, CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/Users/camac.TATARETAS/source_builds/vcpkg-master/vcpkg-master/scripts/buildsystems/vcpkg.cmake"
#-DCMAKE_BUILD_TYPE=Release
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Wall -fPIE")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall -fPIE")
#wxWidget specific stuff
SET(wxWidgets_USE_LIBS)
FIND_PACKAGE(wxWidgets COMPONENTS core base gl REQUIRED)
if(wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
endif()
#OpenSceneGraph speicific stuff
FIND_PACKAGE (OpenSceneGraph REQUIRED COMPONENTS osgUtil osgDB osgText osgGA osgFX osgSim osgViewer )
#for serial data stuff
set(BOOST_LIBS date_time system)
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
find_package(Threads REQUIRED)
#FreeBSD and linux specific include and libs
#Note: for FreeBSD, use cmake .. -DwxWidgets_CONFIG_EXECUTABLE=/usr/local/bin/wxgtk3u-3.1-config
#For the shared library:
set ( PROJECT_LINK_LIBS ${wxWidgets_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES} openal.so sndfile.so ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
#where to find library files .so
link_directories( /usr/lib /usr/local/lib )
set ( PROJECT_INCLUDE_DIR ${wxWidgets_INCLUDE_DIRS} ${OPENSCENEGRAPH_INCLUDE_DIRS} )
#for where to find header files for source and library
include_directories(/usr/include /usr/local/include ./include ./src/timeline-track-editor/include ${PROJECT_INCLUDE_DIR})
set(SOURCES src/main.cpp)
#get_cmake_property(_variableNames VARIABLES)
#list (SORT _variableNames)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
#make executable sphere from simple-sphere.cpp
add_executable(${PROJECT_NAME} ${SOURCES})
#link libraries
target_link_libraries(${PROJECT_NAME} ${PROJECT_LINK_LIBS})
Re: Building wxWidgets Program with MSYS2 + CMake
Try sorting the includes so that all wx headers are included first, then all others. wx/wx.h or wx/wxprec.h should always be the first wx header. Including wx/defs.h should not be necessary.
Use the source, Luke!
Re: Building wxWidgets Program with MSYS2 + CMake
Including "wx/wxprec.h" inside of a header is a bad idea.
Including "wx/wx.h" inside of a header is *not* a good idea unless the header is being used to generate a pre-compiled header.
It is better to include them inside of an cpp file.
Edit: But, the above is not a likely cause of your build issue.
Edit2: What msys2 OpenSceneGraph packages are needed?
Tim S.
Including "wx/wx.h" inside of a header is *not* a good idea unless the header is being used to generate a pre-compiled header.
It is better to include them inside of an cpp file.
Edit: But, the above is not a likely cause of your build issue.
Edit2: What msys2 OpenSceneGraph packages are needed?
Tim S.
Re: Building wxWidgets Program with MSYS2 + CMake
main.cpp include section
It builds using the above for me; I did not use the cmake file to do the build.
Code::Blocks build log
Tim S.
Code: Select all
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include <winsock2.h>
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "main.h"
#include "SimpleSerial.h"
Code::Blocks build log
Code: Select all
-------------- Build: Debug in wxBoost (compiler: GNU GCC Compiler)---------------
x86_64-w64-mingw32-g++.exe -Wall -fexceptions -D__WXMSW__ -DWXUSINGDLL -DNOPCH -DwxUSE_UNICODE -g -IC:/msys64/mingw64/lib/wx/include/msw-unicode-3.0 -IC:/msys64/mingw64/include/wx-3.0 -c C:/Users/stahta01/devel/open_source_code/no_version_control/test/wxBoost/main.cpp -o obj/Debug/main.o
C:/Users/stahta01/devel/open_source_code/no_version_control/test/wxBoost/main.cpp: In member function 'void OSGCanvas::OnChar(wxKeyEvent&)':
C:/Users/stahta01/devel/open_source_code/no_version_control/test/wxBoost/main.cpp:295:9: warning: unused variable 'key' [-Wunused-variable]
295 | int key = event.GetUnicodeKey();
| ^~~
x86_64-w64-mingw32-g++.exe -o bin/Debug/wxBoost.exe obj/Debug/main.o -losgViewer.dll -losg.dll -losgGA.dll -lwx_mswu_gl-3.0.dll -lwx_mswu_core-3.0.dll -lwx_baseu-3.0.dll -lws2_32
-
- Earned a small fee
- Posts: 17
- Joined: Mon May 27, 2019 7:37 pm
Re: Building wxWidgets Program with MSYS2 + CMake
Thank you both for the help!
I was able to build the small program with Codeblocks without problems.
I did need to move the wx/wx.h and wx/precomp.h header files to main.cpp, include winsock before wx, and add -lws2_32 to link winsock for boost asio use.
I will try to get this to work with CMake. I think I just need to make sure the Makefile from CMake is doing the same thing as CodeBlocks Makefile.
If I can't get this to work with CMake, I'll just use CodeBlocks instead.
I was able to build the small program with Codeblocks without problems.
I did need to move the wx/wx.h and wx/precomp.h header files to main.cpp, include winsock before wx, and add -lws2_32 to link winsock for boost asio use.
I will try to get this to work with CMake. I think I just need to make sure the Makefile from CMake is doing the same thing as CodeBlocks Makefile.
If I can't get this to work with CMake, I'll just use CodeBlocks instead.