hw01 icon indicating copy to clipboard operation
hw01 copied to clipboard

HW1

Open PtCu opened this issue 3 years ago • 0 comments

HW1 Report

步骤

  1. 在stbiw中添加stb_image_write.cpp文件,include对应头文件并添加开关宏。
  2. 在CMakeLists.txt中添加stbiw的静态库,并指定stbiw的include路径。

解释

  1. 编译时以cpp文件为单位进行编译,只有头文件无法编译,所以需要在stbiw中添加对应的.cpp文件以编译静态库。
  2. stb_image_write.h的内容大致为:
    #ifndef INCLUDE_STB_IMAGE_WRITE_H
    //声明
    #endif
    
    #ifdef STB_IMAGE_WRITE_IMPLEMENTATION
    //定义
    #endif
    
    所以需要添加STB_IMAGE_WRITE_IMPLEMENTATION来开启对应部分的实现。由于实现部分并没有类似的头文件保护,如果多处添加该宏就会重定义。

PtCu avatar Jan 14 '22 11:01 PtCu