安装qrencode 库
sudo apt-get install qrencode
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <string.h>
using namespace std;
int main()
{
char buf[128];
string num = "hello world";
sprintf(buf,"qrencode \'%s\' -o a.png",num.c_str());
system(buf);
}
命令行生成二维码:qrencode hello_world -o a.png