GithubHelp home page GithubHelp logo

alan0526 / hwinfo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lfreist/hwinfo

0.0 0.0 0.0 1.12 MB

cross platform C++ library for hardware information (CPU, RAM, GPU, ...)

License: MIT License

Shell 0.78% C++ 94.14% Python 2.40% C 0.76% CMake 1.92%

hwinfo's Introduction

Linux (clang) Linux (gcc)

MacOS

Windows (Visual Studio)

clang format

hwinfo

hwinfo provides an easy-to-use and modern C++ API for retrieving hardware information of your systems components such as CPU, RAM, GPU, Disks, Mainboard, ...

Note

If you face any issues, find bugs or if your platform is not supported yet, do not hesitate to create an issue.

Content

Supported Components

Note

The listed components that are not yet implemented (indicated with ❌) are in development and will be supported in later releases. You are welcome to start contributing and help improving this library!

Component Info Linux Apple Windows
CPU Vendor ✔️ ✔️ ✔️
Model ✔️ ✔️ ✔️
Frequency ✔️ ✔️ ✔️
Physical Cores ✔️ ✔️ ✔️
Logical Cores ✔️ ✔️ ✔️
Cache Size ✔️ ✔️ ✔️
GPU Vendor ✔️ ✔️ ✔️
Model ✔️ ✔️ ✔️
Memory Size ✔️
Memory (RAM) Vendor ✔️
Model ✔️
Name ✔️
Serial Number ✔️
Total Memory Size ✔️ ✔️ ✔️
Free Memory Size ✔️
Mainboard Vendor ✔️ ✔️
Model ✔️ ✔️
Version ✔️ ✔️
Serial-Number ✔️
Bios
Disk Vendor ✔️ ✔️
Model ✔️ ✔️
Serial-Number ✔️
Size
Operating System Name ✔️ ✔️ ✔️
Short Name ✔️ ✔️ ✔️
Version ✔️ ✔️
Kernel ✔️
Architecture (Bit) ✔️ ✔️ ✔️
Endianess ✔️ ✔️ ✔️
Battery Vendor ✔️
Model ✔️
Serial Number ✔️
Technology ✔️
Capacity ✔️ ️❌
Charging ✔️

*Disks must be initialized using getAllDisks()

*Batteries should be initialized using getAllBatteries() or an ID must be provided: Battery::Battery(int8_t id)

Build hwinfo

Requirements: git, cmake, c++ compiler (gcc, clang, MSVC)

  1. Download repository:
    git clone https://github.com/lfreist/hwinfo
    
  2. Build using cmake:
    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Release .. && make -j $(nproc)
    

Example

See example.cpp

The output should look similar to this one:

Hardware Report:

----------------------------------- CPU -----------------------------------
vendor:             GenuineIntel
model:              Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
physical cores:     8
logical cores:      16
max frequency:      5100000
regular frequency:  3800000
current frequency:  4700189
cache size:         16384000
----------------------------------- OS ------------------------------------
Operating System:   Ubuntu 22.04 LTS
short name:         Ubuntu
version:            22.04
kernel:             5.15.0-37-generic
architecture:       64 bit
endianess:          little endian
----------------------------------- GPU -----------------------------------
vendor:             NVIDIA Corporation
model:              GeForce RTX 3070 Ti
driverVersion:      <unknown>
memory [MiB]:       -1
----------------------------------- RAM -----------------------------------
vendor:             <unknown>
model:              <unknown>
name:               <unknown>
serial-number:      <unknown>
size [MiB]:         64213.2
------------------------------- Main Board --------------------------------
vendor:             ASUSTeK COMPUTER INC.
name:               PRIME Z490-A
version:            Rev 1.xx
serial-number:      <unknown>
------------------------------- Batteries ---------------------------------
No Batteries installed or detected
--------------------------------- Disks -----------------------------------
Disk 0:
  vendor:           <unknown>
  model:            WDS500G3X0C-00SJG0
  serial-number:    2105EZ440111
  size:             -1
---------------------------------------------------------------------------

Include hwinfo in your cmake project

  1. Download hwinfo into your project (e.g. in <project-root>/third_party/hwinfo)
    mkdir third_party
    cd third_party
    git clone https://github.com/lfreist/hwinfo
    
  2. Simply add the following to your <project-root>/CMakeLists.txt file:
    # file: <project-root>/CMakeLists.txt
    
    add_subdirectory(third_party/hwinfo)
    include_directories(third_party/hwinfo/include)
  3. Include hwinfo into your .cpp/.h files:
    // file: your_executable.cpp
    
    #include "hwinfo/hwinfo.h"
    
    int main(int argc, char** argv) {
     // Your code
    }
  4. Link it in cmake
    add_executable(your_executable your_executable.cpp)
    target_link_libraries(your_executable PUBLIC hwinfo::HWinfo)

hwinfo's People

Contributors

lfreist avatar facug91 avatar egecetin avatar germanaizek avatar ace-krypton avatar lstrsrt avatar omnibench avatar liguobao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.