构建环境
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/be4f13450e1165fedaa6341131f6339d.png)
- 随时可以在底部看到
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/0d7a8322c72f4ca1b8e9e8338acd2dc8.png)
conan的配置文件
[requires]
libpng/1.6.37@bincrafters/stable
[generators]
cmake
[options]
*:shared=True
[imports]
bin, *.dll -> ./bin
lib, *.dylib* -> ./bin
cmake 的配置文件
cmake_minimum_required(VERSION 3.0.0)
project(cdsConan VERSION 0.1.0)
include(CTest)
enable_testing()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(cdsConan main.cpp)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
注意事项
- 下载动态库,并且将动态库导入文件中.
[options]
*:shared=True
[imports]
bin, *.dll -> ./bin
lib, *.dylib* -> ./bin
- cmake链接conan工程
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
- deubg
- 修改为debug模式
- 修改all为需要调试的文件
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/da1cbca1438bcfe227691b9b983325f1.png)
测试代码
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/24e16944929062c1f1e733c65adff04d.png)
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <png.h>
#include <zlib.h>
#include <string>
using namespace std;
int main(int argc, const char **argv)
{
png_image image; /* The control structure used by libpng */
memset(&image, 0, (sizeof image));
image.version = PNG_IMAGE_VERSION;
printf("dsfsdfsfsfdsf============");
printf("dsfsdfsfsfdsf============");
printf("dsfsdfsfsfdsf============");
char* name = "xxx.png";
if (png_image_begin_read_from_file(&image, name) != 0) {
png_bytep buffer;
image.format = PNG_FORMAT_RGBA;
buffer = (png_bytep)malloc(PNG_IMAGE_SIZE(image));
if (buffer != NULL &&
png_image_finish_read(&image, NULL/*background*/, buffer,
0/*row_stride*/, NULL/*colormap*/) != 0) {
if (png_image_write_to_file(&image, "./cds.png", 0/*convert_to_8bit*/,
buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
{
/* The image has been written successfully. */
printf("dsfsdfsfsfdsf============");
printf("dsfsdfsfsfdsf============");
printf("dsfsdfsfsfdsf============");
printf("dsfsdfsfsfdsf============");
exit(0);
}
} else {
if (buffer == NULL)
png_image_free(&image);
else
free(buffer);
}
}
fprintf(stderr, "pngtopng: error: %s\n", image.message);
system("pause");
return 0;
}