{"id":18315380,"url":"https://github.com/lefticus/i2c_hacking","last_synced_at":"2025-07-27T15:09:24.431Z","repository":{"id":54645437,"uuid":"331381615","full_name":"lefticus/i2c_hacking","owner":"lefticus","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-06T07:35:02.000Z","size":33,"stargazers_count":14,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T09:35:18.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lefticus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"lefticus","patreon":"lefticus"}},"created_at":"2021-01-20T17:33:36.000Z","updated_at":"2024-05-20T01:09:57.000Z","dependencies_parsed_at":"2022-08-13T22:40:27.562Z","dependency_job_id":null,"html_url":"https://github.com/lefticus/i2c_hacking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"cpp-best-practices/gui_starter_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefticus%2Fi2c_hacking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefticus%2Fi2c_hacking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefticus%2Fi2c_hacking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefticus%2Fi2c_hacking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lefticus","download_url":"https://codeload.github.com/lefticus/i2c_hacking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399818,"owners_count":20932875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T16:39:28.626Z","updated_at":"2025-04-05T20:32:31.893Z","avatar_url":"https://github.com/lefticus.png","language":"C++","funding_links":["https://github.com/sponsors/lefticus","https://patreon.com/lefticus"],"categories":[],"sub_categories":[],"readme":"# cpp_starter_project\n\n[![codecov](https://codecov.io/gh/lefticus/cpp_starter_project/branch/master/graph/badge.svg)](https://codecov.io/gh/lefticus/cpp_starter_project)\n\n[![Build Status](https://travis-ci.org/lefticus/cpp_starter_project.svg?branch=master)](https://travis-ci.org/lefticus/cpp_starter_project)\n\n[![Build status](https://ci.appveyor.com/api/projects/status/ro4lbfoa7n0sy74c/branch/master?svg=true)](https://ci.appveyor.com/project/lefticus/cpp-starter-project/branch/master)\n\n![CMake](https://github.com/lefticus/cpp_starter_project/workflows/CMake/badge.svg)\n\n\n## Getting Started\n\n### Use the Github template\nFirst, click the green `Use this template` button near the top of this page.\nThis will take you to Github's ['Generate Repository'](https://github.com/lefticus/cpp_starter_project/generate) page. \nFill in a repository name and short description, and click 'Create repository from template'. \nThis will allow you to create a new repository in your Github account, \nprepopulated with the contents of this project. \nNow you can clone the project locally and get to work!\n\n    $ git clone https://github.com/\u003cuser\u003e/\u003cyour_new_repo\u003e.git\n\n### Remove frameworks you're not going to use\nIf you know you're not going to use one or more of the optional gui/graphics \nframeworks (fltk, gtkmm, imgui, etc.), you can remove them with `git rm`:\n\n    $ git rm -r src/\u003cunnecessary_framework\u003e\n\n## Dependencies\n\nNote about install commands: \n- for Windows, we use [choco](https://chocolatey.org/install).\n- for MacOS, we use [brew](https://brew.sh/). \n- In case of an error in cmake, make sure that the dependencies are on the PATH.\n\n### Necessary Dependencies\n1. A C++ compiler that supports C++17.\nSee [cppreference.com](https://en.cppreference.com/w/cpp/compiler_support)\nto see which features are supported by each compiler.\nThe following compilers should work:\n\n  * [gcc 7+](https://gcc.gnu.org/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall command\u003c/summary\u003e\n\n\t- Debian/Ubuntu:\n\t\t\n\t\t\tsudo apt install build-essential\n\n\t- Windows:\n\t\t\n\t\t\tchoco install mingw -y\n\n\t- MacOS:\n\t\t\n\t\t\tbrew install gcc\n\t\u003c/details\u003e\n\n  * [clang 6+](https://clang.llvm.org/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall command\u003c/summary\u003e\n\n\t- Debian/Ubuntu:\n\t\t\n\t\t\tbash -c \"$(wget -O - https://apt.llvm.org/llvm.sh)\"\n\n\t- Windows:\n\n\t\tVisual Studio 2019 ships with LLVM (see the Visual Studio section). However, to install LLVM separately:\n\t\t\n\t\t\tchoco install llvm -y\n\t\t\t\n\t\tllvm-utils for using external LLVM with Visual Studio generator:\n\t\t\t\n\t\t\tgit clone https://github.com/zufuliu/llvm-utils.git\n\t\t\tcd llvm-utils/VS2017\n\t\t\t.\\install.bat\n\n\t- MacOS:\n \t\t\n\t\t\tbrew install llvm\n\t\u003c/details\u003e\n\n  * [Visual Studio 2019 or higher](https://visualstudio.microsoft.com/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall command + Environment setup\u003c/summary\u003e\n\n\tOn Windows, you need to install Visual Studio 2019 because of the SDK and libraries that ship with it.\n\n  \tVisual Studio IDE - 2019 Community (installs Clang too):\n\t\t\n  \t  \tchoco install -y visualstudio2019community --package-parameters \"add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --includeOptional --passive --locale en-US\"\n\t\t\n\tPut MSVC compiler, Clang compiler, and vcvarsall.bat on the path:\n\n\t\t\tchoco install vswhere -y\n\t\t\trefreshenv\n\t\t\t\n\t\t\t$clpath = vswhere -latest -prerelease -find **/Hostx64/x64/*   # for x64\n\t\t\t[Environment]::SetEnvironmentVariable(\"Path\", $env:Path + \";$clpath\", \"User\")\n\t\t\t\n\t\t\t$clangpath = vswhere -latest -prerelease -find **/Llvm/bin/*\n\t\t\t[Environment]::SetEnvironmentVariable(\"Path\", $env:Path + \";$clangpath\", \"User\")\n\n\t\t\t$vcvarsallpath =  vswhere -latest -prerelease -find **/Auxiliary/Build/*\n\t\t\t[Environment]::SetEnvironmentVariable(\"Path\", $env:Path + \";$vcvarsallpath\", \"User\")\n\t\t\trefreshenv\n\n\t\u003c/details\u003e\n\n\n2. [Conan](https://conan.io/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall Command\u003c/summary\u003e\n\t\n\t- Via pip - https://docs.conan.io/en/latest/installation.html#install-with-pip-recommended\n\t\t\n\t\t\tpip install --user conan\n\t\n\t- Windows:\n\t\t\n\t\t\tchoco install conan -y\n\t\n\t- MacOS:\n\t \t\n\t\t\tbrew install conan\n\t\n\t\u003c/details\u003e\n\n3. [CMake 3.15+](https://cmake.org/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall Command\u003c/summary\u003e\n\t\n\t- Debian/Ubuntu:\n\t\t\n\t\t\tsudo apt-get install cmake\n\t\n\t- Windows:\n\t\t\n\t\t\tchoco install cmake -y\n\t\n\t- MacOS:\n\t \t\t\n\t\t\tbrew install cmake\n\t\n\t\u003c/details\u003e\n\n### Optional Dependencies\n#### C++ Tools\n  * [Doxygen](http://doxygen.nl/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall Command\u003c/summary\u003e\n\n\t- Debian/Ubuntu:\n\t\t\n\t\t\tsudo apt-get install doxygen\n\t\t\tsudo apt-get install graphviz\n\n\t- Windows:\n\t\t\n\t\t\tchoco install doxygen.install -y\n\t\t\tchoco install graphviz -y\n\n\t- MacOS:\n \t\t\n\t\t\tbrew install doxygen\n\t \t\tbrew install graphviz\n\n\t\u003c/details\u003e\n\n\n  * [ccache](https://ccache.dev/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall Command\u003c/summary\u003e\n\n\t- Debian/Ubuntu:\n\t\t\n\t\t\tsudo apt-get install ccache\n\n\t- Windows:\n\t\t\n\t\t\tchoco install ccache -y\n\n\t- MacOS:\n \t\t\n\t\t\tbrew install ccache\n\n\t\u003c/details\u003e\n\n\n  * [Cppcheck](http://cppcheck.sourceforge.net/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall Command\u003c/summary\u003e\n\n\t- Debian/Ubuntu:\n\t\t\n\t\t\tsudo apt-get install cppcheck\n\n\t- Windows:\n\t\t\n\t\t\tchoco install cppcheck -y\n\n\t- MacOS:\n \t\t\n\t\t\tbrew install cppcheck\n\n\t\u003c/details\u003e\n\n\n  * [include-what-you-use](https://include-what-you-use.org/)\n\t\u003cdetails\u003e\n\t\u003csummary\u003eInstall Command\u003c/summary\u003e\n\n\tFollow instructions here:\n\thttps://github.com/include-what-you-use/include-what-you-use#how-to-install\n\t\u003c/details\u003e\n\n#### GUI libraries\nThis project can be made to work with several optional GUI frameworks.\n\nIf desired, you should install the following optional dependencies as\ndirected by their documentation, linked here:\n \n- [FLTK](https://www.fltk.org/doc-1.4/index.html)\n- [GTKMM](https://www.gtkmm.org/en/documentation.html)\n- [QT](https://doc.qt.io/)\n\nThe following dependencies can be downloaded automatically by CMake and Conan. \nAll you need to do to install them is to turn on a CMake flag during \nconfiguration.\nIf you run into difficulty using them, please refer to their documentation,\nlinked here:\n\n- [NANA](http://nanapro.org/en-us/documentation/)\n- [SDL](http://wiki.libsdl.org/FrontPage)\n- [IMGUI](https://github.com/ocornut/imgui/tree/master/docs): \n  This framework depends on SFML, and if you are using Linux, you may need\n  to install several of SFML's dependencies using your package manager. See \n  [the SFML build tutorial](https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php)\n  for specifics.\n\n## Build Instructions\n\n### Build directory\nMake a build directory:\n```\nmkdir build\n```\n### Specify the compiler using environment variables\n\nBy default (if you don't set environment variables `CC` and `CXX`), the system default compiler will be used.\n\nConan and CMake use the environment variables CC and CXX to decide which compiler to use. So to avoid the conflict issues only specify the compilers using these variables.\n\nCMake will detect which compiler was used to build each of the Conan targets. If you build all of your Conan targets with one compiler, and then build your CMake targets with a different compiler, the project may fail to build.\n\n\u003cdetails\u003e\n\u003csummary\u003eCommands for setting the compilers \u003c/summary\u003e\n\n- Debian/Ubuntu/MacOS:\n\t\n\tSet your desired compiler (`clang`, `gcc`, etc):\n\t\t\n\t- Temporarily (only for the current shell)\n\t\n\t\tRun one of the followings in the terminal:\n\t\n\t\t- clang\n\t\t\n\t\t\t\tCC=clang CXX=clang++\n\t\t\t\n\t\t- gcc\n\t\t\n\t\t\t\tCC=gcc CXX=g++\n\t\n\t- Permanent:\n\n\t\tOpen `~/.bashrc` using your text editor:\n\t\t\t\n\t\t\tgedit ~/.bashrc\n\t\t\t\n\t\tAdd `CC` and `CXX` to point to the compilers:\n\t\t\t\n\t\t\texport CC=clang\n\t\t\texport CXX=clang++\n\t\t\t\n\t\tSave and close the file.\n\n- Windows:\n\n\t- Permanent:\n\t\n\t\tRun one of the followings in PowerShell:\n\t\t\t\t\n\t\t- Visual Studio generator and compiler (cl)\n\t\t\t\n\t\t\t\t[Environment]::SetEnvironmentVariable(\"CC\", \"cl.exe\", \"User\")\n\t\t\t\t[Environment]::SetEnvironmentVariable(\"CXX\", \"cl.exe\", \"User\")\n\t\t\t\trefreshenv\n\t\t\t\n\t\t  Set the architecture using [vsvarsall](https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019#vcvarsall-syntax):\n\t\t\t\n\t\t\t\tvsvarsall.bat x64\n\n\t\t- clang\n\n\t\t\t\t[Environment]::SetEnvironmentVariable(\"CC\", \"clang.exe\", \"User\")\n\t\t\t\t[Environment]::SetEnvironmentVariable(\"CXX\", \"clang++.exe\", \"User\")\n\t\t\t\trefreshenv\n\t \n\t\t- gcc\n\n\t\t\t\t[Environment]::SetEnvironmentVariable(\"CC\", \"gcc.exe\", \"User\")\n\t\t\t\t[Environment]::SetEnvironmentVariable(\"CXX\", \"g++.exe\", \"User\")\n\t\t\t\trefreshenv\n\t \n\n  - Temporarily (only for the current shell):\n\t\t\n\t\t\t$Env:CC=\"clang.exe\"\n\t\t\t$Env:CXX=\"clang++.exe\"\n\t\t\t\n\u003c/details\u003e\n\n### Configure your build\n\nTo configure the project and write makefiles, you could use `cmake` with a bunch of command line options.\nThe easier option is to run cmake interactively:\n\n#### **Configure via cmake-gui**:\n\n1) Open cmake-gui from the project directory:\n```\ncmake-gui .\n```\n2) Set the build directory:\n\n![build_dir](https://user-images.githubusercontent.com/16418197/82524586-fa48e380-9af4-11ea-8514-4e18a063d8eb.jpg)\n\n3) Configure the generator:\n\nIn cmake-gui, from the upper menu select `Tools/Configure`.\n\n**Warning**: if you have set `CC` and `CXX` always choose the `use default native compilers` option. This picks `CC` and `CXX`. Don't change the compiler at this stage!\n\n\u003cdetails\u003e\n\u003csummary\u003eWindows - MinGW Makefiles\u003c/summary\u003e\n\nChoose MinGW Makefiles as the generator:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/16418197/82769479-616ade80-9dfa-11ea-899e-3a8c31d43032.png\" alt=\"mingw\"\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWindows - Visual Studio generator and compiler\u003c/summary\u003e\n\nYou should have already set `C` and `CXX` to `cl.exe`.\n\nChoose \"Visual Studio 16 2019\" as the generator:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/16418197/82524696-32502680-9af5-11ea-9697-a42000e900a6.jpg\" alt=\"default_vs\"\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eWindows - Visual Studio generator and Clang Compiler\u003c/summary\u003e\n\nYou should have already set `C` and `CXX` to `clang.exe` and `clang++.exe`.\n\nChoose \"Visual Studio 16 2019\" as the generator. To tell Visual studio to use `clang-cl.exe`:\n- If you use the LLVM that is shipped with Visual Studio: write `ClangCl` under \"optional toolset to use\". \n\n\u003cimg src=\"https://user-images.githubusercontent.com/16418197/82781142-ae60ac00-9e1e-11ea-8c77-222b005a8f7e.png\" alt=\"visual_studio\"\u003e\n\n- If you use an external LLVM: write [`LLVM_v142`](https://github.com/zufuliu/llvm-utils#llvm-for-visual-studio-2017-and-2019)\n under \"optional toolset to use\".\n\n\u003cimg src=\"https://user-images.githubusercontent.com/16418197/82769558-b3136900-9dfa-11ea-9f73-02ab8f9b0ca4.png\" alt=\"visual_studio\"\u003e\n\n\u003c/details\u003e\n\u003cbr/\u003e\n\n4) Choose the Cmake options and then generate:\n\n![generate](https://user-images.githubusercontent.com/16418197/82781591-c97feb80-9e1f-11ea-86c8-f2748b96f516.png)\n\n#### **Configure via ccmake**:\nwith the Cmake Curses Dialog Command Line tool:  \n\n    ccmake -S . -B ./build\n\nOnce `ccmake` has finished setting up, press 'c' to configure the project, \npress 'g' to generate, and 'q' to quit.\n\n### Build\nOnce you have selected all the options you would like to use, you can build the \nproject (all targets):\n\n    cmake --build ./build\n\nFor Visual Studio, give the build configuration (Release, RelWithDeb, Debug, etc) like the following:\n\n    cmake --build ./build -- /p:configuration=Release\n\n## Troubleshooting\n\n### Update Conan\nMany problems that users have can be resolved by updating Conan, so if you are \nhaving any trouble with this project, you should start by doing that.\n\nTo update conan: \n\n    $ pip install --user --upgrade conan \n\nYou may need to use `pip3` instead of `pip` in this command, depending on your \nplatform.\n\n### Clear Conan cache\nIf you continue to have trouble with your Conan dependencies, you can try \nclearing your Conan cache:\n\n    $ conan remove -f '*'\n    \nThe next time you run `cmake` or `cmake --build`, your Conan dependencies will\nbe rebuilt. If you aren't using your system's default compiler, don't forget to \nset the CC, CXX, CMAKE_C_COMPILER, and CMAKE_CXX_COMPILER variables, as \ndescribed in the 'Build using an alternate compiler' section above.\n\n### Identifying misconfiguration of Conan dependencies\n\nIf you have a dependency 'A' that requires a specific version of another \ndependency 'B', and your project is trying to use the wrong version of \ndependency 'B', Conan will produce warnings about this configuration error \nwhen you run CMake. These warnings can easily get lost between a couple \nhundred or thousand lines of output, depending on the size of your project. \n\nIf your project has a Conan configuration error, you can use `conan info` to \nfind it. `conan info` displays information about the dependency graph of your \nproject, with colorized output in some terminals.\n\n    $ cd build\n    $ conan info .\n\nIn my terminal, the first couple lines of `conan info`'s output show all of the\nproject's configuration warnings in a bright yellow font. \n\nFor example, the package `spdlog/1.5.0` depends on the package `fmt/6.1.2`.\nIf you were to modify the file `cmake/Conan.cmake` so that it requires an \nearlier version of `fmt`, such as `fmt/6.0.0`, and then run:\n\n    $ conan remove -f '*'       # clear Conan cache\n    $ rm -rf build              # clear previous CMake build\n    $ mkdir build \u0026\u0026 cd build\n    $ cmake ..                  # rebuild Conan dependencies\n    $ conan info .\n\n...the first line of output would be a warning that `spdlog` needs a more recent\nversion of `fmt`.\n\n## Testing\nSee [Catch2 tutorial](https://github.com/catchorg/Catch2/blob/master/docs/tutorial.md)\n\n## Fuzz testing\n\nSee [libFuzzer Tutorial](https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flefticus%2Fi2c_hacking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flefticus%2Fi2c_hacking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flefticus%2Fi2c_hacking/lists"}