Sign inSign up

openeuler/libconfig

Sponsored OSS

By openeuler

•Updated about 24 hours ago

Image
0

277

openeuler/libconfig repository overview

⁠Quick reference

⁠libconfig | openEuler

Current libconfig docker images are built on the openEuler⁠. This repository is free to use and exempted from per-user rate limits.

C/C++ library for processing structured configuration files.

Learn more on libconfig | C/C++ Library for Processing Structured Configuration Files⁠.

The tag of each libconfig docker image is consist of the version of libconfig and the version of basic image. The details are as follows

TagCurrentlyArchitectures
1.8.2-oe2403sp4⁠libconfig 1.8.2 on openEuler 24.03-LTS-SP4amd64, arm64

⁠Usage

In this usage, users can select the corresponding {Tag} based on their requirements.

  • Pull the openeuler/libconfig image from docker

    docker pull openeuler/libconfig:{Tag}
    
  • Run with an interactive shell

    docker run -it --rm openeuler/libconfig:{Tag} bash
    
  • Compile and run a C program using libconfig

    Create a file named example.c in the current directory:

    #include <stdio.h>
    #include <libconfig.h>
    
    int main(void)
    {
      config_t cfg;
      const char *name;
      int port;
    
      config_init(&cfg);
      if(! config_read_string(&cfg, "name = \"libconfig\"; port = 8080;"))
      {
        fprintf(stderr, "%s\n", config_error_text(&cfg));
        config_destroy(&cfg);
        return 1;
      }
    
      config_lookup_string(&cfg, "name", &name);
      config_lookup_int(&cfg, "port", &port);
      printf("%s:%d\n", name, port);
    
      config_destroy(&cfg);
      return 0;
    }
    

    Compile and run it with pkg-config inside the container:

    docker run --rm -v "$(pwd)":/work -w /work openeuler/libconfig:{Tag} \
        sh -c 'gcc $(pkg-config --cflags libconfig) example.c -o example $(pkg-config --libs libconfig) && ./example'
    

    Expected output:

    libconfig:8080
    
  • Compile and run a C++ program using libconfig

    Create a file named example.cpp in the current directory:

    #include <iostream>
    #include <libconfig.h++>
    
    using namespace libconfig;
    
    int main()
    {
      Config cfg;
      cfg.readString("name = \"libconfig\"; port = 8080;");
    
      std::string name = cfg.lookup("name");
      int port = cfg.lookup("port");
      std::cout << name << ":" << port << std::endl;
      return 0;
    }
    

    Compile and run it with pkg-config inside the container:

    docker run --rm -v "$(pwd)":/work -w /work openeuler/libconfig:{Tag} \
        sh -c 'g++ $(pkg-config --cflags libconfig++) example.cpp -o example_cpp $(pkg-config --libs libconfig++) && ./example_cpp'
    

    Expected output:

    libconfig:8080
    
  • Start a long-running container for exploration

    docker run -d --name my-libconfig openeuler/libconfig:{Tag} sleep infinity
    
  • View the container logs

    docker logs -f my-libconfig
    
  • To get an interactive shell

    docker exec -it my-libconfig bash
    

⁠Question and answering

If you have any questions or want to use some special features, please submit an issue or a pull request on openeuler-docker-images⁠.

Tag summary

Content type

Image

Digest

sha256:7f72cc2dc…

Size

169.2 MB

Last updated

about 24 hours ago

docker pull openeuler/libconfig

This week's pulls

Pulls:

4

Last week