# How write CMakeLists.txt for Windows for wxWidgets and Boost ?

**URL:** <https://discourse.cmake.org/t/how-write-cmakelists-txt-for-windows-for-wxwidgets-and-boost/3512>\
**Category:** Code\
**Created:** [June 7, 2021, 3:15am UTC](https://discourse.cmake.org/t/how-write-cmakelists-txt-for-windows-for-wxwidgets-and-boost/3512 "2021-06-07T03:15:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrzejB](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrzejb/32/815_2.png) [@AndrzejB](https://discourse.cmake.org/u/AndrzejB)\
**Post date:** [June 7, 2021, 3:15am UTC](https://discourse.cmake.org/t/how-write-cmakelists-txt-for-windows-for-wxwidgets-and-boost/3512/1 "2021-06-07T03:15:27Z")

</div>

Creating CMakeLists.txt on Linux for these is simple but are problems on Windows with MinGw or Visual (generating project from CMakeLists.txt).  
What are minimal examples for wxWidgets and Boost on Windows?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 7, 2021, 11:06am UTC](https://discourse.cmake.org/t/how-write-cmakelists-txt-for-windows-for-wxwidgets-and-boost/3512/2 "2021-06-07T11:06:14Z")

</div>

What are those problems? Do you have error output you can share?

---

<div class="post-metadata">

**Author:** ![AndrzejB](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrzejb/32/815_2.png) [@AndrzejB](https://discourse.cmake.org/u/AndrzejB)\
**Post date:** [June 9, 2021, 3:18pm UTC](https://discourse.cmake.org/t/how-write-cmakelists-txt-for-windows-for-wxwidgets-and-boost/3512/3 "2021-06-09T15:18:41Z")

</div>

For example project borneq/hexFinder from github, where CMakeLists.txt is

```
cmake_minimum_required(VERSION 3.1)
project(hexFinder)
find_package(Boost COMPONENTS filesystem system)
set(CMAKE_CXX_STANDARD 14)
add_executable(hexFinder hexFinder.cpp)
target_link_libraries(hexFinder
                   boost_system
                   boost_filesystem
                   boost_regex)

```

In Linux is OK, but in Windows:

- I install Boost on c:\boost\_1\_76\_0
- generate VC++ project by c:\gitmy\hexFinder\build\>cmake -G “Visual Studio 16 2019” …  
Try build and are errors: (no paths)

| Ważność | Kod | Opis | Projekt | Plik | Wiersz | Stan pominięcia |
| --- | --- | --- | --- | --- | --- | --- |
| Błąd (aktywny) | E1696 | nie można otworzyć pliku źródło boost/interprocess/file\_mapping.hpp | hexFinder | C:\gitmy\hexFinder\hexFinder.cpp | 1 | |
| Błąd (aktywny) | E1696 | nie można otworzyć pliku źródło boost/interprocess/mapped\_region.hpp | hexFinder | C:\gitmy\hexFinder\hexFinder.cpp | 2 | |
| Błąd (aktywny) | E1696 | nie można otworzyć pliku źródło boost/regex.hpp | hexFinder | C:\gitmy\hexFinder\hexFinder.cpp | 3 | |
| Błąd (aktywny) | E1696 | nie można otworzyć pliku źródło boost/filesystem.hpp | hexFinder | C:\gitmy\hexFinder\hexFinder.cpp | 4 | |
| Błąd (aktywny) | E0276 | nazwa, po której następują znaki „::”, musi być nazwą klasy lub przestrzeni nazw | hexFinder | C:\gitmy\hexFinder\hexFinder.cpp | 9 | |

(errors in Polish because I have Polish WIndows)

I want avoid put literal pathes to cmake like c:\boost\_1\_76\_0 , espacially names like libboost\_graph-vc142-mt-gd-x32-1\_76.lib and prefer not put version like 1.76 to cmake.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 9, 2021, 11:41pm UTC](https://discourse.cmake.org/t/how-write-cmakelists-txt-for-windows-for-wxwidgets-and-boost/3512/4 "2021-06-09T23:41:15Z")

</div>

You should use `Boost::boost`, `Boost::filesystem`, `Boost::regex`, and `Boost::system` to the `target_link_libraries` call. You’re just listing library names which is just `-l` flags. This works with the Linux distro packages because everything is in the default locations.
