4

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!

ionree
  • 45
  • 1
  • 1
  • 5
  • Those are no compiler errors, but linker errors (LNK = LINKER or LINK). Make sure the file `LogitechLcd.lib` can be found. – dyp Jan 01 '14 at 16:35
  • Don't make us guess at the errors. – Hans Passant Jan 01 '14 at 16:35
  • 1
    Please copy the exact output. These are errors from the linker. It can't find symbols. You are probably not passing the path to the library to the linker. – TimDave Jan 01 '14 at 16:36
  • ok, here's the exact output: – ionree Jan 01 '14 at 16:47
  • Fehler 2 error LNK1120: 1 nicht aufgelöste Externe E:\Freizeit\Programmieren\G19s\thisWillWork\Debug\thisWillWork.exe 1 1 thisWillWork Fehler 1 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_WinMain@16" in Funktion "___tmainCRTStartup". E:\Freizeit\Programmieren\G19s\thisWillWork\thisWillWork\MSVCRTD.lib(crtexew.obj) thisWillWork -yes, I'm german! – ionree Jan 01 '14 at 16:48
  • This is related to [undefined reference to `WinMain@16'](http://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16). Maybe the answer there helps. – Sebastian Jan 01 '14 at 16:51
  • As statet in the edit, i finally got it working – ionree Jan 03 '14 at 14:52

2 Answers2

2

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

Look here.

And here.

Community
  • 1
  • 1
FuzzyBunnySlippers
  • 3,387
  • 2
  • 18
  • 28
  • My project is set up as a win32-Application, and if I'm not totally mistaken this means its native c++ PS: The compiler is set to 32 bit as well – ionree Jan 02 '14 at 18:47
1

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.

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
  • In case you missed it, the OP typed in [a comment](https://stackoverflow.com/questions/20870676/c-compile-error-lnk1120-and-lnk2019-with-visual-studio/46133902#comment31381733_20870676): "_As statet in the edit, i finally got it working_" Jan 3 '14 at 14:52 – Sᴀᴍ Onᴇᴌᴀ Sep 09 '17 at 19:01