Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete hw01 #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

complete hw01 #113

wants to merge 1 commit into from

Conversation

XcodeRole
Copy link

1.创建cpp,cpp中只需要include <stb_image_write.h>就可以,cpp文件用来编译动态链接库,add_library(stbiw SHARED stb_image_write.cpp)
2. 使用PUBLIC的target_include_directories,将所有链接了stbiw.so的target都从stbiw中搜索头文件,target_include_directories(stbiw PUBLIC ./)
3. 使用target_compile_definitions定义动态链接库的宏以编译stbi_write_png()这些函数,这里需要注意使用PRIVATE属性,否则会多重定义,因为前面还include了多次这个库的头文件,而函数的定义就在头文件中,所以会编译很多次。这里用PRIVATE不会将宏传递出去,只会在库编译时定义一次函数。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant