How can I find the name of the gpu and cpu in qt c ++

0

Any of these solutions work for me, first I tried a system management code to try to find the name of the gpu and cpu, but of that error for me in visual studio, the compiler does not seem to accept the clr, and I'm using qt in the project with the 64bit msvs2017 compiler.

Gravidade   Código  Descrição   Projeto Arquivo Linha   Estado de Supressão
Erro    D8016   opções de linha de comando '/clr' e '/EHs' são incompatíveis    Denoiser    C:\Git\Denoiser-Script\src\cl   1

Another problem is that the api itself does not identify the cpu name or gpu, so I did not find what I wanted. So what would be the solution?

code that I used

using namespace System;
using namespace System::Management;

void printHardwareInfo(String^ HardwareClass, String^ propetyName)
{
    ManagementObjectSearcher^ searcher = gcnew ManagementObjectSearcher("root\CIMV2", "SELECT * FROM" + HardwareClass);
    ManagementObjectCollection^ collection = searcher->Get();

    for each (ManagementObjectSearcher^ object in collection)
    {
        Console::WriteLine(object[propetyName]->ToString());
    }
}
    
asked by anonymous 05.12.2018 / 17:17

1 answer

0

The CLR command causes your code to refer to the dynamically installed msvc (vcredist) runtime equivalent to '/ MD', this acts as a proxy between your code and the CRT. It's hard to say exactly what this proxy does, but I think it acts as an interface to allocations in the heap manager, garbage collector, and threads. If you link statically to the CRT, the proxy will not be able to intercept your calls to the libraries at runtime.

CLR presents several constraints including the use of exceptions '/ EH', because the CLR implies in a redundant way. The compiler will generate an error if '/ EHs' is used after '/ CLR'.

If you want to make your application static, you will need to use the '/ MT' command. But there is another problem, because Qt is dynamically linked. Aside from the licensing part of this framework, you would need to recompile the source code of the framework statically using '/ MT' since by default '/ MD' is used.

    
06.12.2018 / 16:09