Building using a subdirectory

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Konben
In need of some credit
In need of some credit
Posts: 2
Joined: Mon May 16, 2022 11:40 am

Building using a subdirectory

Post by Konben »

Hello,

I'm trying to add wxwidgets to my cmake system using a subdirectory similar to the last section here: https://docs.wxwidgets.org/trunk/overview_cmake.html.

My project has the following structure:
.
├── CMakeLists.txt
├── include
│ ├── gui
│ │ └── ui.hpp
│ ├── main.hpp
│ └── processor
│ └── toy_processor.hpp
├── libs
│ └── wxWidgets-3.1.6
├── README.md
└── src
├── gui
│ ├── CMakeLists.txt
│ └── ui.cpp
├── main.cpp
└── processor
├── CMakeLists.txt
└── toy_processor.cpp

and CMakeList.txt looks like this:

Code: Select all

cmake_minimum_required(VERSION 3.10)

project(ToyV2)

add_subdirectory(libs/wxWidgets-3.1.6/)
include_directories(include/ libs/wxWidgets-3.1.6/include/)
add_subdirectory(src/gui/)
add_subdirectory(src/processor/)

add_executable(ToyV2 src/main.cpp)
target_link_libraries(ToyV2 wx::net wx::core wx::base)
target_link_libraries(ToyV2 gui)
target_link_libraries(ToyV2 processor)
I've also added a setup.h to wxWidgets-3.1.6/include, (I just copied setup.h.in).
But every time you try to include some wx header in my project you get errors like this:

Code: Select all

[ 57%] Building CXX object src/gui/CMakeFiles/gui.dir/ui.cpp.o
In file included from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/defs.h:933,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/event.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/window.h:18,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/nonownedwnd.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/toplevel.h:20,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/frame.h:18,
                 from /home/benedict/projects/toy-processor-2/include/gui/ui.hpp:14,
                 from /home/benedict/projects/toy-processor-2/src/gui/ui.cpp:1:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/types.h:161:30: error: expected constructor, destructor, or type conversion before ‘(’ token
  161 |         wxCOMPILE_TIME_ASSERT( sizeof(int) == 4, IntMustBeExactly4Bytes);
      |                              ^
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/types.h:162:30: error: expected constructor, destructor, or type conversion before ‘(’ token
  162 |         wxCOMPILE_TIME_ASSERT( sizeof(size_t) == 4, SizeTMustBeExactly4Bytes);
      |                              ^
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/types.h:163:30: error: expected constructor, destructor, or type conversion before ‘(’ token
  163 |         wxCOMPILE_TIME_ASSERT( sizeof(void *) == 4, PtrMustBeExactly4Bytes);
      |                              ^
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/types.h:180:34: error: expected constructor, destructor, or type conversion before ‘(’ token
  180 |             wxCOMPILE_TIME_ASSERT( sizeof(wchar_t) == 2,
      |                                  ^
In file included from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/string.h:31,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/memory.h:15,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/object.h:19,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/event.h:16,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/window.h:18,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/nonownedwnd.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/toplevel.h:20,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/frame.h:18,
                 from /home/benedict/projects/toy-processor-2/include/gui/ui.hpp:14,
                 from /home/benedict/projects/toy-processor-2/src/gui/ui.cpp:1:
/usr/include/stdio.h:77:19: error: conflicting declaration ‘typedef __ssize_t ssize_t’
   77 | typedef __ssize_t ssize_t;
      |                   ^~~~~~~
In file included from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/defs.h:933,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/event.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/window.h:18,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/nonownedwnd.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/toplevel.h:20,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/frame.h:18,
                 from /home/benedict/projects/toy-processor-2/include/gui/ui.hpp:14,
                 from /home/benedict/projects/toy-processor-2/src/gui/ui.cpp:1:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/types.h:332:25: note: previous declaration as ‘typedef wxInt32 ssize_t’
  332 |         typedef wxInt32 ssize_t;
      |                         ^~~~~~~
In file included from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/string.h:36,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/memory.h:15,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/object.h:19,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/event.h:16,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/window.h:18,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/nonownedwnd.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/toplevel.h:20,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/frame.h:18,
                 from /home/benedict/projects/toy-processor-2/include/gui/ui.hpp:14,
                 from /home/benedict/projects/toy-processor-2/src/gui/ui.cpp:1:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcpy(wchar_t*, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:111:26: error: ‘wcscpy’ was not declared in this scope
  111 | #define wxCRT_StrcpyW    wcscpy
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:215:14: note: in expansion of macro ‘wxCRT_StrcpyW’
  215 |     { return wxCRT_StrcpyW(dest, src); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcpy(wchar_t*, const wxString&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:111:26: error: ‘wcscpy’ was not declared in this scope
  111 | #define wxCRT_StrcpyW    wcscpy
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:225:14: note: in expansion of macro ‘wxCRT_StrcpyW’
  225 |     { return wxCRT_StrcpyW(dest, src.wc_str()); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcpy(wchar_t*, const wxCStrData&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:111:26: error: ‘wcscpy’ was not declared in this scope
  111 | #define wxCRT_StrcpyW    wcscpy
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:227:14: note: in expansion of macro ‘wxCRT_StrcpyW’
  227 |     { return wxCRT_StrcpyW(dest, src.AsWCharBuf()); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcpy(wchar_t*, const wxScopedWCharBuffer&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:111:26: error: ‘wcscpy’ was not declared in this scope
  111 | #define wxCRT_StrcpyW    wcscpy
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:229:14: note: in expansion of macro ‘wxCRT_StrcpyW’
  229 |     { return wxCRT_StrcpyW(dest, src.data()); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcpy(wchar_t*, const char*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:111:26: error: ‘wcscpy’ was not declared in this scope
  111 | #define wxCRT_StrcpyW    wcscpy
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:234:14: note: in expansion of macro ‘wxCRT_StrcpyW’
  234 |     { return wxCRT_StrcpyW(dest, wxConvLibc.cMB2WC(src)); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncpy(wchar_t*, const wchar_t*, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:115:26: error: ‘wcsncpy’ was not declared in this scope
  115 | #define wxCRT_StrncpyW   wcsncpy
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:240:14: note: in expansion of macro ‘wxCRT_StrncpyW’
  240 |     { return wxCRT_StrncpyW(dest, src, n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncpy(wchar_t*, const wxString&, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:115:26: error: ‘wcsncpy’ was not declared in this scope
  115 | #define wxCRT_StrncpyW   wcsncpy
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:250:14: note: in expansion of macro ‘wxCRT_StrncpyW’
  250 |     { return wxCRT_StrncpyW(dest, src.wc_str(), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncpy(wchar_t*, const wxCStrData&, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:115:26: error: ‘wcsncpy’ was not declared in this scope
  115 | #define wxCRT_StrncpyW   wcsncpy
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:252:14: note: in expansion of macro ‘wxCRT_StrncpyW’
  252 |     { return wxCRT_StrncpyW(dest, src.AsWCharBuf(), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncpy(wchar_t*, const wxScopedWCharBuffer&, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:115:26: error: ‘wcsncpy’ was not declared in this scope
  115 | #define wxCRT_StrncpyW   wcsncpy
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:254:14: note: in expansion of macro ‘wxCRT_StrncpyW’
  254 |     { return wxCRT_StrncpyW(dest, src.data(), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncpy(wchar_t*, const char*, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:115:26: error: ‘wcsncpy’ was not declared in this scope
  115 | #define wxCRT_StrncpyW   wcsncpy
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:259:14: note: in expansion of macro ‘wxCRT_StrncpyW’
  259 |     { return wxCRT_StrncpyW(dest, wxConvLibc.cMB2WC(src), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcat(wchar_t*, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:108:26: error: ‘wcscat’ was not declared in this scope
  108 | #define wxCRT_StrcatW    wcscat
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:295:14: note: in expansion of macro ‘wxCRT_StrcatW’
  295 |     { return wxCRT_StrcatW(dest, src); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcat(wchar_t*, const wxString&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:108:26: error: ‘wcscat’ was not declared in this scope
  108 | #define wxCRT_StrcatW    wcscat
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:305:14: note: in expansion of macro ‘wxCRT_StrcatW’
  305 |     { return wxCRT_StrcatW(dest, src.wc_str()); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcat(wchar_t*, const wxCStrData&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:108:26: error: ‘wcscat’ was not declared in this scope
  108 | #define wxCRT_StrcatW    wcscat
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:307:14: note: in expansion of macro ‘wxCRT_StrcatW’
  307 |     { return wxCRT_StrcatW(dest, src.AsWCharBuf()); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcat(wchar_t*, const wxScopedWCharBuffer&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:108:26: error: ‘wcscat’ was not declared in this scope
  108 | #define wxCRT_StrcatW    wcscat
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:309:14: note: in expansion of macro ‘wxCRT_StrcatW’
  309 |     { return wxCRT_StrcatW(dest, src.data()); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrcat(wchar_t*, const char*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:108:26: error: ‘wcscat’ was not declared in this scope
  108 | #define wxCRT_StrcatW    wcscat
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:314:14: note: in expansion of macro ‘wxCRT_StrcatW’
  314 |     { return wxCRT_StrcatW(dest, wxConvLibc.cMB2WC(src)); }
      |              ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncat(wchar_t*, const wchar_t*, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:113:26: error: ‘wcsncat’ was not declared in this scope
  113 | #define wxCRT_StrncatW   wcsncat
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:320:14: note: in expansion of macro ‘wxCRT_StrncatW’
  320 |     { return wxCRT_StrncatW(dest, src, n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncat(wchar_t*, const wxString&, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:113:26: error: ‘wcsncat’ was not declared in this scope
  113 | #define wxCRT_StrncatW   wcsncat
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:330:14: note: in expansion of macro ‘wxCRT_StrncatW’
  330 |     { return wxCRT_StrncatW(dest, src.wc_str(), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncat(wchar_t*, const wxCStrData&, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:113:26: error: ‘wcsncat’ was not declared in this scope
  113 | #define wxCRT_StrncatW   wcsncat
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:332:14: note: in expansion of macro ‘wxCRT_StrncatW’
  332 |     { return wxCRT_StrncatW(dest, src.AsWCharBuf(), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncat(wchar_t*, const wxScopedWCharBuffer&, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:113:26: error: ‘wcsncat’ was not declared in this scope
  113 | #define wxCRT_StrncatW   wcsncat
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:334:14: note: in expansion of macro ‘wxCRT_StrncatW’
  334 |     { return wxCRT_StrncatW(dest, src.data(), n); }
      |              ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘wchar_t* wxStrncat(wchar_t*, const char*, size_t)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:113:26: error: ‘wcsncat’ was not declared in this scope
  113 | #define wxCRT_StrncatW   wcsncat
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:339:14: note: in expansion of macro ‘wxCRT_StrncatW’
  339 |     { return wxCRT_StrncatW(dest, wxConvLibc.cMB2WC(src), n); }
      |              ^~~~~~~~~~~~~~
In file included from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/hashmap.h:15,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/clntdata.h:16,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/event.h:17,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/window.h:18,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/nonownedwnd.h:14,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/toplevel.h:20,
                 from /home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/frame.h:18,
                 from /home/benedict/projects/toy-processor-2/include/gui/ui.hpp:14,
                 from /home/benedict/projects/toy-processor-2/src/gui/ui.cpp:1:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcmp(const wchar_t*, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:110:26: error: ‘wcscmp’ was not declared in this scope
  110 | #define wxCRT_StrcmpW    wcscmp
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:41: note: in expansion of macro ‘wxCRT_StrcmpW’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      |                                         ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcmp(const wchar_t*, const wxScopedWCharBuffer&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:110:26: error: ‘wcscmp’ was not declared in this scope
  110 | #define wxCRT_StrcmpW    wcscmp
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:41: note: in expansion of macro ‘wxCRT_StrcmpW’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      |                                         ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcmp(const wxScopedWCharBuffer&, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:110:26: error: ‘wcscmp’ was not declared in this scope
  110 | #define wxCRT_StrcmpW    wcscmp
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:41: note: in expansion of macro ‘wxCRT_StrcmpW’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      |                                         ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcmp(const wxScopedWCharBuffer&, const wxScopedWCharBuffer&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:110:26: error: ‘wcscmp’ was not declared in this scope
  110 | #define wxCRT_StrcmpW    wcscmp
      |                          ^~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:543:41: note: in expansion of macro ‘wxCRT_StrcmpW’
  543 | WX_STRCMP_FUNC(wxStrcmp, wxCRT_StrcmpA, wxCRT_StrcmpW, wxStrcmp_String)
      |                                         ^~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcoll(const wchar_t*, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:124:26: error: ‘wcscoll’ was not declared in this scope
  124 | #define wxCRT_StrcollW   wcscoll
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:43: note: in expansion of macro ‘wxCRT_StrcollW’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      |                                           ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcoll(const wchar_t*, const wxScopedWCharBuffer&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:124:26: error: ‘wcscoll’ was not declared in this scope
  124 | #define wxCRT_StrcollW   wcscoll
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:43: note: in expansion of macro ‘wxCRT_StrcollW’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      |                                           ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcoll(const wxScopedWCharBuffer&, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:124:26: error: ‘wcscoll’ was not declared in this scope
  124 | #define wxCRT_StrcollW   wcscoll
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:43: note: in expansion of macro ‘wxCRT_StrcollW’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      |                                           ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘int wxStrcoll(const wxScopedWCharBuffer&, const wxScopedWCharBuffer&)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:124:26: error: ‘wcscoll’ was not declared in this scope
  124 | #define wxCRT_StrcollW   wcscoll
      |                          ^~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:344:36: note: in definition of macro ‘WX_STR_CALL’
  344 | #define WX_STR_CALL(func, a1, a2)  func(a1, a2)
      |                                    ^~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:462:5: note: in expansion of macro ‘WX_STR_FUNC_NO_INVERT’
  462 |     WX_STR_FUNC_NO_INVERT(int, name, crtA, crtW, forString)                   \
      |     ^~~~~~~~~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:1: note: in expansion of macro ‘WX_STRCMP_FUNC’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      | ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h:554:43: note: in expansion of macro ‘wxCRT_StrcollW’
  554 | WX_STRCMP_FUNC(wxStrcoll, wxCRT_StrcollA, wxCRT_StrcollW, wxStrcoll_String)
      |                                           ^~~~~~~~~~~~~~
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrt.h: In function ‘size_t wxStrspn(const wchar_t*, const wchar_t*)’:
/home/benedict/projects/toy-processor-2/libs/wxWidgets-3.1.6/include/wx/wxcrtbase.h:118:26: error: ‘wcsspn’ was not declared in this scope
  118 | #define wxCRT_StrspnW    wcsspn
      |                          ^~~~~~
(I've only included the first few errors since the whole message was far to long for the threat)

Do you know where I messed up here?
Thanks in advance and I'm very sorry for my bad English.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4183
Joined: Sun Jan 03, 2010 5:45 pm

Re: Building using a subdirectory

Post by PB »

Konben wrote: Mon May 16, 2022 7:42 pm I've also added a setup.h to wxWidgets-3.1.6/include, (I just copied setup.h.in).
Why would you that? You should just follow the instructions you linked. Copying setup.h anywhere is a very bad idea and should never be done.

I don't think you should use

Code: Select all

include_directories(include/ libs/wxWidgets-3.1.6/include/)
for wxWidgets when using add_subdirectory either, add_subdirectory() uses CMakeLists.txt from the subdirectory. Once again, I would advise to just follow the instructions. Just make sure wxWidgets folder actually includes the full unmodified source tree.

FWIW, it worked for me on Windows with MinGW like this, following the instruction to the letter: viewtopic.php?p=210402#p210402
Konben
In need of some credit
In need of some credit
Posts: 2
Joined: Mon May 16, 2022 11:40 am

Re: Building using a subdirectory

Post by Konben »

Thanks for your reply.
I followed that tutorial and it worked as long as all of my code using wx was located in src, but the problem is that I also need to include wx headers in my gui subdirectory since most of my UI is supposed to reside there, that's why I've added

Code: Select all

include_directories(include/ libs/wxWidgets-3.1.6/include/)
Is it not possible to include wx headers in any of your subdirectories?
Last edited by Konben on Tue May 17, 2022 1:33 am, edited 4 times in total.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4183
Joined: Sun Jan 03, 2010 5:45 pm

Re: Building using a subdirectory

Post by PB »

Konben wrote: Tue May 17, 2022 12:08 am Is it not possible to include wx headers in any of your subdirectories?
I think it should work just fine, but it depends what you do in the "gui" folder CMakeLists.txt. I would assume this is a library (CMake target) linking to wxWidgets just as your application does and if so, I think you need to tell it about wxWidgets as well there (and not just headers).

In other words, I would add wxWidgets dependency as public in the gui's folder CMakeLists.txt, e.g. something like

Code: Select all

...
target_link_libraries(gui PUBLIC wx::core wx::base)
and removed linking to wx from the main CMakeLists.txt.

But I know little about CMake...
Konben
In need of some credit
In need of some credit
Posts: 2
Joined: Mon May 16, 2022 11:40 am

Re: Building using a subdirectory

Post by Konben »

That worked!

What still kinda baffles me though is why my first attempt didn't.

Since when I build the project by hand using g++ and wx-config pretty much all that wx-config --cxxflags does on my machine is include my local installation of the wxwidgets headers which should be pretty much what the cmake file did (or I just don't understand cmake as well as I thought, which is equally likely).
Maybe building wx as part of your source just works differently?

I would really be interested in what target_link_libraries(gui PUBLIC wx::core wx::base) really does behind the scenes (some kind of black magic probably).

But thank you so very much, you've just made my day!
Last edited by Konben on Tue May 17, 2022 9:58 am, edited 1 time in total.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4183
Joined: Sun Jan 03, 2010 5:45 pm

Re: Building using a subdirectory

Post by PB »

Konben wrote: Tue May 17, 2022 9:53 am Since when I build the project by hand using g++ and wx-config pretty much all that wx-config --cxxflags does on my machine is include my local installation of the wxwidgets headers which should be pretty much what the cmake file did (or I just don't understand cmake as well as I thought, which is equally likely).
I am not really familiar with wx-config, but AFAIK, you cannot use just wx-config -cxx flags: that is only for compiler (headers and defines) so you must be using wx-config --libs somewhere too, to tell the linker about libraries and where to find them.

I think that target_link_libraries() does both for a dependency library, i.e., adds headers and libraries (and other stuff such as definitions).

BTW, you still need to add wx::net somewhere, I forgot to write that before.
Konben
In need of some credit
In need of some credit
Posts: 2
Joined: Mon May 16, 2022 11:40 am

Re: Building using a subdirectory

Post by Konben »

Thanks I've added wx::net.
Post Reply