Ich bin neu in C++ und ich möchte ein einfaches Programm schreiben, das die Monitor-Farbtemperatur an die Konsole ausgibt. Hier ist, was ich habe:Undefinierter Verweis auf GetMonitorColorTemperature
#include <iostream>
#include <HighLevelMonitorConfigurationAPI.h>
using namespace std;
int main() {
HMONITOR hMonitor = NULL;
// Get the monitor handle.
hMonitor = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTOPRIMARY);
MC_COLOR_TEMPERATURE *colTemp;
BOOL bSuccess = FALSE;
bSuccess = GetMonitorColorTemperature(hMonitor, colTemp);
if (bSuccess){
cout << colTemp << endl;
}
return 0;
}
jedoch die Erstellung meiner Projekte ergibt:
Building target: FirstC++Project.exe
Invoking: Cygwin C++ Linker
g++ -o "FirstC++Project.exe" ./src/FirstC++Project.o
./src/FirstC++Project.o: In function `main':
/cygdrive/c/Users/User/workspace/FirstC++Project/Debug/../src/FirstC++Project.cpp:35: undefined reference to `GetMonitorColorTemperature'
/cygdrive/c/Users/User/workspace/FirstC++Project/Debug/../src/FirstC++Project.cpp:35:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `GetMonitorColorTemperature'
collect2: error: ld returned 1 exit status
make: *** [makefile:47: FirstC++Project.exe] Error 1
05:42:02 Build Finished (took 5s.242ms)
Jede Hilfe wird geschätzt!
Vielen Dank!
Für gcc, nehmen Sie den Linker-Dateinamen ('was.lib') von MSDN, legen Sie die' .lib', und fügen Sie '-l' an den Anfang. Zum Beispiel wird 'user32.lib' zu '-luser32'. – andlabs