Thread: Linker Setting Issue In IDE - Console/Windows?

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    205

    Exclamation Linker Setting Issue In IDE - Console/Windows?

    Hi there,

    I noticed to my amazement that a program I had open would run in Debug but not in Release version. When I tried to run it in Release version it threw the C2102 error code '&' requires l-value.

    I did a little research and it seems it's related to either passing the address of a temporary, or passing the address of a definition rather than an actual object.

    Needless to say I got all caught up in some of the _DEBUG includes in the program thinking that was relevant. Picked over everything in the settings until I eventually found what it was and it was this:

    Linker Setting Issue In IDE - Console/Windows?-wincon-jpg

    For some reason in the Linker settings where System is concerned on the Release version it was set to CONSOLE not WINDOWS. When I changed that it ran fine.

    Ok so I fixed the problem. But that doesn't mean I really understood it. I was wondering if anyone else could give me a bit more insight into exactly why this happens?

    Thanks

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    The point of this page is to specify what platform you are targeting. Platform isn't strictly the right word, but besides, there are different types of applications you can program for Windows. The subsystem you have highlighted tells the linker to look for Windows specific entry points like WinMain().

    The relevant Microsoft developer page, where you can learn a little about all the things you can target if you want, has this to say about it:
    WINDOWS
    The application doesn't require a console, probably because it creates its own windows for interaction with the user. If WinMain or wWinMain is defined for native code, or WinMain(HINSTANCE *, HINSTANCE *, char *, int) or wWinMain(HINSTANCE *, HINSTANCE *, wchar_t *, int) is defined for managed code, WINDOWS is the default.
    If your application doesn't use one of these entry points the linker was bound to have a problem. Console seems like the correct setting because you are in fact using a console or powershell or something similar where int main(int argc, char **argv) is the entry point.

    The error you specified seems unrelated to me, but if you're sure you fixed it, that's better I suppose.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    205
    Thanks very much for the replies, especially yours whiteflags, cheers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker Issue - Getting PortAudio to work with Code::Blocks
    By samGwilliam in forum C++ Programming
    Replies: 9
    Last Post: 06-16-2019, 05:17 PM
  2. Setting up hotkeys in console apps
    By Geek on Skates in forum Linux Programming
    Replies: 4
    Last Post: 12-10-2018, 07:16 AM
  3. Setting console title
    By tony_rusia in forum C++ Programming
    Replies: 2
    Last Post: 06-28-2007, 02:17 PM
  4. Setting Console Size
    By twomers in forum C++ Programming
    Replies: 4
    Last Post: 08-20-2006, 03:24 PM
  5. Setting the console title
    By Diablo84 in forum C++ Programming
    Replies: 6
    Last Post: 04-11-2005, 11:22 AM

Tags for this Thread