使用Visual Studio的C ++编译错误(LNK1120和LNK2019) [英] C++ compile error (LNK1120 and LNK2019) with Visual Studio
问题描述
我是C ++的新手,我需要帮助一个非常基本的程序。
背景信息:获得了Logitech G19s 。它有一个小彩色液晶屏。你可以用C ++编写应用程序。所以我决定尝试它,即使我是新来的C + +,写一些你好世界。
问题:
当我编译我的小的Hello World应用程序,我得到2错误:LNK1120和LNK2019,没有任何其他信息。这里是我的代码:
#pragma comment(lib,LogitechLcd.lib)
#includeLogitechLcd.h
int main(){
LogiLcdInit(LHello World,LOGI_LCD_TYPE_COLOR);
while(true){
LogiLcdUpdate();
LogiLcdColorSetText(4,LHello G19s,255,0,0);
}
LogiLcdShutdown();
return 0;
}
,这里是 LogitechLcd.h(pastebin.com)。
当我编译这个(使用Visual Studio Professional 2013)上面提到的错误。任何人都可以帮助我(如果可能,解释为什么它不工作)?
编辑:让它现在工作! Viusal Studio没有找到lib,所以我不得不把它放在项目文件夹中。非常愚蠢的错误!
听起来你的项目设置错误类型。
I am a newbie to C++ and I need help with a very basic program.
Background information: I recently got the Logitech G19s. It has a small color LCD screen. You can write apps for it in C++. So I decided to try it out, even though I'm new to C++, and write some hello world. Shouldn't be to dificult, but it turns out to be a real pain!
Problem: When I compile my small Hello World app, I get 2 errors: LNK1120 and LNK2019, without any other information. Here's my code:
#pragma comment(lib, "LogitechLcd.lib")
#include "LogitechLcd.h"
int main() {
LogiLcdInit(L"Hello World", LOGI_LCD_TYPE_COLOR);
while (true) {
LogiLcdUpdate();
LogiLcdColorSetText(4, L"Hello G19s", 255, 0, 0);
}
LogiLcdShutdown();
return 0;
}
and here's the LogitechLcd.h (pastebin.com).
When I compile this (with Visual Studio Professional 2013), I get the errors mentioned above. Can anyone help me out (and, if possible, explain why it doesn't work)?
EDIT: I somewhat got it to work now! Viusal Studio didn't find the lib, so I had to place it in the project folder. Very stupid mistake!
It sounds like you have the project set up as the wrong type.
Look here.
And here.
这篇关于使用Visual Studio的C ++编译错误(LNK1120和LNK2019)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!