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

67.5k views Asked by At

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!

2

There are 2 answers

1
FuzzyBunnySlippers On BEST ANSWER

It sounds like you have the project set up as the wrong type.

Look here.

And here.

1
Toucan Sign On

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.