Skip to content

zip_file.hpp is missing #4

@mikucionisaau

Description

@mikucionisaau

Congratulations with the book!
I did not read it, I am looking for one for teaching, hence I am trying to compile blindly. Got stuck with an error:

examples/ch04/fig04_11.cpp:5:10: fatal error: zip_file.hpp: No such file or directory
    5 | #include "zip_file.hpp"

zip_file.hpp is not in the repo, where can we get it?

I hastily came up with CMake script to compile it (something like this would be nice to have in the repo):

cmake_minimum_required(VERSION 3.15)
project(CXX20ForProgrammers LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for clang-tidy
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)

add_subdirectory("examples/libraries/fmt")
add_subdirectory("examples/libraries/GSL")

file(GLOB sources "${CMAKE_CURRENT_SOURCE_DIR}/examples/ch*/*.cpp")
foreach(source ${sources})
  file(STRINGS ${source} hasmain REGEX ".+\ main\(.+\).+")
  if (hasmain)
    get_filename_component(name "${source}" NAME_WLE)
    if (NOT ${name} STREQUAL "fig04_07_with_error")
        add_executable(${name} ${source})
        file(STRINGS ${source} usesfmt REGEX ".+fmt/format.+")
        if (usesfmt)
          target_include_directories(${name} PRIVATE "examples/libraries/fmt/include")
          target_link_libraries(${name} PRIVATE fmt)
        endif()
        file(STRINGS ${source} usesgsl REGEX ".+gsl/gsl.+")
        if (usesgsl)
            target_include_directories(${name} PRIVATE "examples/libraries/GSL/include")
        endif()
    endif()
  endif(hasmain)
endforeach()

Then used the usual cmake dance:

cmake -S . -B build -G Ninja
cmake --build build

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions