私はC++を初めて使用しており、モニターの色温度をコンソールに出力する簡単なプログラムを作成したいと思います。ここで私が持っているものです。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;
}
、利回り私のプロジェクトをコンパイルする:
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)
任意の助けが理解されるであろう!
ありがとうございました!
gccの場合、リンカファイル名( 'whatever.lib')をMSDNから取り出し、' .lib'をドロップし、 '-l'を先頭に追加します。たとえば、 'user32.lib'は' -luser32'になります。 – andlabs