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

ionree picture ionree · Jan 1, 2014 · Viewed 56.6k times · Source

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!

Answer

FuzzyBunnySlippers picture FuzzyBunnySlippers · Jan 1, 2014

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

Look here.

And here.