DEV Community

Tong Liu
Tong Liu

Posted on

Lab10 Reflect

In this week, I uploaded my SSGifier to a C++ package manager named conan. It was quite a lot of learning I had this week in trying to understand how does conan work, how do I integrate it into my project, and how do I encapsulate and upload a package of my project to remote server for other users to use. However, conan only provides packages as libraries for other projects to use, it is not like pip in python where we can install packages and use it standalone. That is being said, we need to createa conan project to use the package. To make sure that my instruction is easy to read and covers all needed requirements, I asked Piotr to install it with the only instruction from my README.md, and he later found out he has no difficulty installing my package.

How did I set up conan?

To set up conan, there are few steps need to be followed:

  1. Install python first because conan relies on python to run its script.
  2. Use pip install conan to install conan.
  3. In the SSGifier project folder, create a folder named packageand create a folder src inside package and put all source files of SSGifier to the package/src folder.
  4. In package folder, use $ conan new mypackage/1.0 -t to generate a package template for us to use.
  5. Edit the generated conanfile.py and add the source files that to be packed into the package into the function def package(self). For example, self.copy("*.h", dst="src", src="src").
  6. After finished setting up the conanfile.py, we need to register an account here to host our packages.
  7. Follow the instruction to add the remote package source to conan.
  8. In the package folder, use conan upload . -r put-your-remote-name-here --all to upload the package to remote. Now the package is uploaded to the remote server.

How to use the package?

You can also use SSGifier in your projectas as a library. To use it you need to do following:

  1. Downlaod & install Conan from here and clang from here.
  2. Create a conanfile.txt inside your project and add SSGifier/1.0.0 in the category of [requires] to conanfile.txt. Click to see official documents. You can use this template:
[requires]
SSGifier/1.0.0

[generators]
cmake
Enter fullscreen mode Exit fullscreen mode
  1. Edit conan.conf file in the location C:\Users\<your user name>\.conan and add revisions_enabled = 1 to [general].
  2. Add this remote repository to conan by using this command conan remote add tommy-conan-local https://tommyliu.jfrog.io/artifactory/api/conan/tommy-conan-local
  3. Add credential information to this repository by using this command conan user -p AKCp8nHPJwRCr2my24TiMaikQgQUW4e3xRbqsiGw45j9nPfPdLWEREYigcMLLW4pQtqg18n8b -r tommy-conan-local lt19930320@gmail.com.
  4. Go to the directory of you project which you created in step 2(make sure conaninfo.txt), install SSGifier by using conan install . -r tommy-conan-local
  5. Go to C:\Users\<your user name>\.conan\data\SSGifier\1.0.0\_\_\package\3fb49604f9c2f729b85ba3115852006824e72cab\src to find the source file.
  6. Compile these code. For gcc, use g++ -std=c++17 main.cpp Utils.cpp ArgumentQueue.cpp FileProcessor.cpp MessagePrinter.cpp, for clang, use clang++ -std=c++17 main.cpp Utils.cpp ArgumentQueue.cpp FileProcessor.cpp MessagePrinter.cpp.
  7. After compilation, a binrary executatable of SSGifier will be generated with the name of a.exe.

Top comments (0)