简体   繁体   中英

C++ compile error (LNK1120 and LNK2019) with Visual Studio

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 .

Is it a console project? (If you don't know, look at Project Properties > Linker > System > Subsystem ). It should be the first thing that comes up. If so, make your main function a wmain function. If it's a Win32 project it was something like WinMain(16) , not sure.

I hope it helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM