C++ Linking Chilkat Linux

Create project folder, for example ~cktest:
cd cktest
Download C++ GCC Chilkat Library: wget https://chilkatdownload.com/9.5.0.84/chilkat-9.5.0-x86_64-linux-gcc.tar.gz
tar xfz ./*.gz
Move include and lib folder to cktest
Create your .cpp program, for example my.cpp
#include <CkJsonObject.h>
#include <iostream>

int ChilkatSample()
{
CkJsonObject json;
    bool success;
int index = -1;

success = json.AddStringAt(-1,"Title","Pan's Labyrinth");
success = json.AddStringAt(-1,"Director","Guillermo del Toro");
success = json.AddStringAt(-1,"Original_Title","El laberinto del fauno");
success = json.AddIntAt(-1,"Year_Released",2006);

json.put_EmitCompact(false);
std::cout << json.emit() << "\r\n";
exit(EXIT_SUCCESS);
}

static int s = ChilkatSample();

int main()
{
std::cout << "Inside main() - dummy things";
}

To compile: g++ my.cpp -I./include -L./lib -lchilkat-9.5.0 -lresolv -lpthread
To execute, you must copy library to default in your system location (/usr/lib /lib etc.)

Execute: ./a.out

 

#user@srv:~/C++/cktest# ./a.out
{
"Title": "Pan's Labyrinth",
"Director": "Guillermo del Toro",
"Original_Title": "El laberinto del fauno",
"Year_Released": 2006
}


Comments

Popular posts from this blog

Certbot

Mapserver install on Ubuntu 18.04 with Naviserver: