coodblock调试_codeblock如何调试编译cairomm程序

系统opensuse tumbleweed

平台:code::block 17.12

新建一个console application,

将主程序修改为:

/* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris,

* et. al.

*/

#if defined(_MSC_VER)

#define _USE_MATH_DEFINES

#endif

#include

#include

#include

#include

#include

#include

int main()

{

#ifdef CAIRO_HAS_PDF_SURFACE

std::string filename = "image.pdf";

int width = 600;

int height = 400;

Cairo::RefPtr<:pdfsurface> surface =

Cairo::PdfSurface::create(filename, width, height);

Cairo::RefPtr<:context> cr = Cairo::Context::create(surface);

cr->save(); // save the state of the context

cr->set_source_rgb(0.86, 0.85, 0.47);

cr->paint(); // fill image with the color

cr->restore(); // color is back to black now

cr->save();

// draw a border around the image

cr->set_line_width(20.0); // make the line wider

cr->rectangle(0.0, 0.0, cairo_image_surface_get_width(surface->cobj()), height);

cr->stroke();

cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);

// draw a circle in the center of the image

cr->arc(width / 2.0, height / 2.0, height / 4.0, 0.0, 2.0 * M_PI);

cr->stroke();

// draw a diagonal line

cr->move_to(width / 4.0, height / 4.0);

cr->line_to(width * 3.0 / 4.0, height * 3.0 / 4.0);

cr->stroke();

cr->restore();

cr->show_page();

std::cout << "Wrote PDF file \"" << filename << "\"" << std::endl;

return 0;

#else

std::cout << "You must compile cairo with PDF support for this example to work."

<< std::endl;

return 1;

#endif

}

在codeblock projection build option中添加link setting如图

添加search directories 如图

然后编译链接运行即可。

生成的PDF图形如下;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值