Thread: Unresolved External Symbol

  1. #1
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313

    Unresolved External Symbol

    Here's a good one for you all. I'm making a very (VERY) simple Win32 application that is supposed to display a message box. And it won't. I know good and well that <windows.h> is the header to use when using MessageBox(), so I'm getting REALLY confused.

    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
    	MessageBox(NULL, "Test", "Test", MB_OK);
    
        return(0);
    }
    Yes, the linker is set /SUBSYSTEM:WINDOWS. I checked that one already. The error is:

    main.obj : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _WinMain@16
    Help?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    that's odd - what compiler are you using?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Visual Studio 2005 Beta WITH the Core SDK installed and referenced in the compiler.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    you might try re-installing it - it appears the linker is confused.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Reinstalling didn't work - but.

    It appears that the Core SDK is moronic and the "Register PSDK Directories with Visual Studio" command does not work. YAY.

    *tries something*

    Nope. Even telling the compiler manually that the includes are at X and libs are at Y didn't work. Hello complete loss of ideas.

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Get a different compiler?
    Woop?

  7. #7
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Ok.. what is your suggestion for a Visual Studio 6-like IDE using compiler that's more standards-compliant than Visual Studio 6?

  8. #8
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Well I personally love Dev-C++ because its free and its awesome . If you want a sorta vc++ fell you could go for minGW developer studio.
    Woop?

  9. #9
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Ok, so we'll try Dev-C++. Why not, right?

  10. #10
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    MessageBox() is in user32.lib so you have to link with it.
    If it still doesn't work make sure the search path for libraries includes the directory that contains user32.lib.

    gg

  11. #11
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    I had done that, actually, according to Microsoft's instructions (How to use the SDK with Visual Express 2005 Beta). *shrugs*

    Using Dev-C++ now. Thank you for all the help, though!

  12. #12
    Karsten
    Join Date
    Sep 2004
    Posts
    8
    checked it with Dev-C++ and it works perfect

    Hoschi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM