• Stars
    star
    433
  • Rank 100,464 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created over 2 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Linux (clang) Linux (gcc)

MacOS

Windows (MinGW) 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 and API

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 API
CPU Vendor βœ”οΈ βœ”οΈ βœ”οΈ CPU::getVendor()
Model βœ”οΈ βœ”οΈ βœ”οΈ CPU::getModelName()
Frequency βœ”οΈ βœ”οΈ βœ”οΈ CPU::getRegularClockSpeed_kHz()
CPU::getMaxClockSpeed_kHz()
Physical Cores βœ”οΈ βœ”οΈ βœ”οΈ CPU::getNumPhysicalCores()
Logical Cores βœ”οΈ βœ”οΈ βœ”οΈ CPU::getNumLogicalCores()
Cache Size βœ”οΈ βœ”οΈ βœ”οΈ CPU::getCacheSize_Bytes()
GPU Vendor βœ”οΈ βœ”οΈ βœ”οΈ GPU::getVendor()
Model βœ”οΈ βœ”οΈ βœ”οΈ GPU::getName()
Memory Size ❌ ❌ βœ”οΈ GPU::getMemory_Bytes()
Memory (RAM) Vendor ❌ ❌ βœ”οΈ RAM::getVendor()
Model ❌ ❌ βœ”οΈ RAM::getModel()
Name ❌ ❌ βœ”οΈ RAM::getName()
Serial Number ❌ ❌ βœ”οΈ RAM::get()
Total Memory Size βœ”οΈ βœ”οΈ βœ”οΈ RAM::getTotalSizes_Bytes()
Free Memory Size βœ”οΈ ❌ ❌ -
Mainboard Vendor βœ”οΈ ❌ βœ”οΈ MainBoard::getVendor()
Model βœ”οΈ ❌ βœ”οΈ MainBoard::getName()
Version βœ”οΈ ❌ βœ”οΈ MainBoard::getVersion()
Serial-Number ❌ ❌ βœ”οΈ MainBoard::getSerialNumber()
Bios ❌ ❌ ❌ -
Disk Vendor βœ”οΈ ❌ βœ”οΈ Disk::vendor()*
Model βœ”οΈ ❌ βœ”οΈ Disk::model()*
Serial-Number ❌ ❌ βœ”οΈ Disk::serialNumber*
Size ❌ ❌ ❌ Disk::size_Bytes()*
Operating System Name βœ”οΈ βœ”οΈ βœ”οΈ OS::getFullName()
Short Name βœ”οΈ βœ”οΈ βœ”οΈ OS::getName()
Version βœ”οΈ βœ”οΈ ❌ OS::getVersion()
Kernel βœ”οΈ ❌ ❌ OS::getKernel()
Architecture (Bit) βœ”οΈ βœ”οΈ βœ”οΈ OS::getIs32bit()
OS::getIs64bit()
Endianess βœ”οΈ βœ”οΈ βœ”οΈ OS::getIsBigEndian()
OS::getIsLittleEndian()
Battery Vendor βœ”οΈ ❌ ❌ Battery::vendor()*
Model βœ”οΈ ❌ ❌ Battery::model()*
Serial Number βœ”οΈ ❌ ❌ Battery::serialNumber()*
Technology βœ”οΈ ❌ ❌ Battery::technology()*
Capacity βœ”οΈ ❌ ️❌ Battery::capacity()*
Charging βœ”οΈ ❌ ❌ Battery::charging()
Battery::discharging()*

*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)