hw01 icon indicating copy to clipboard operation
hw01 copied to clipboard

完成了小彭老师hw01作业

Open macxt opened this issue 3 years ago • 2 comments

因为自己的疏忽大意,没有看清楚本来已经在README.md文件中说明的可能会引起错误的原因导致迟迟不能编译通过。 最终反复看了README.md才恍然大悟。 说实话对于在windows下用cmake生成的工程使用起来还是有些不太熟悉,主要不太明白生成的几个工程文件(ZERO_CHECK, ALL_BUILD等都是应该怎么用的)。 如果老师有时间的话,能否关于这些做一个几分钟的简单讲解,那就太好了。

macxt avatar Jan 20 '22 12:01 macxt

ZERO_CHECK用于在检测到CMakeLists.txt改变时重新生成sln文件,ALL_BUILD则是会构建全部目标。

archibate avatar Jan 20 '22 15:01 archibate

非常感谢小彭老师对于 ZERO_CHECK 以及 ALL_BUILD 的讲解。 对于 stbiw_EXPORTS 这个宏的定义,VS里面是这样处理的: 如果构建目标为一个库文件的话,编译器会自动定义一个 $(PROJECT_NAME)_EXPORTS 这样的宏写在预处理器里面。

我对这个CMakeLists.txt文件的命令用的不熟,用下面这样应该也是可以的。 target_compile_definitions(stbiw PRIVATE -Dstbiw_EXPORTS)

------------------ 原始邮件 ------------------ 发件人: "parallel101/hw01" @.>; 发送时间: 2022年1月20日(星期四) 晚上11:33 @.>; @.@.>; 主题: Re: [parallel101/hw01] 完成了小彭老师hw01作业 (PR #74)

@archibate approved this pull request.

使用了dllexport和dllimport很有新意!94分!

In stbiw/generate_stb_images.h: > @@ -0,0 +1,17 @@ +#pragma once + +#ifdef _MSC_VER +#ifdef stbiw_EXPORTS +#define STBIW_API __declspec(dllexport) +#else +#define STBIW_API __declspec(dllimport) +#endif +#else +#define STBIW_API +#endif
哦!似乎是第一个这样做的同学?太棒啦

In stbiw/generate_stb_images.h: > @@ -0,0 +1,17 @@ +#pragma once + +#ifdef _MSC_VER +#ifdef stbiw_EXPORTS
不过这个宏好像没有定义?

In stbiw/CMakeLists.txt: > @@ -1 +1,9 @@ -message(FATAL_ERROR "请修改 stbiw/CMakeLists.txt!要求生成一个名为 stbiw 的库") +cmake_minimum_required(VERSION 3.12) +project(stbiw CXX) + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +add_library(stbiw SHARED generate_stb_images.cpp) +target_include_directories(stbiw PUBLIC .)
target_compile_definitions(stbiw PRIVATE -Dstbiw_EXPORTS) 可能忘记加这一行了?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

macxt avatar Jan 20 '22 16:01 macxt