CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2010
    Posts
    38

    How Solve error LNK2019?

    Dear my friend,
    I have one code as below:

    Code:
    #define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
    #include <windows.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string>
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <wininet.h>
    
    
    using namespace std;
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    static bool bAccValidated = false;
    
    
    //----
    #define MT4_EXPFUNC __declspec(dllexport)
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    
    //+------------------------------------------------------------------+
    
    
    MT4_EXPFUNC char* __stdcall Get_Account_Number()
    {
        return("889789619");
    }
    
    // the callback function to find our WND
    BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam )
    {
        DWORD pid = lParam;
        DWORD pOfWindow = 0;
        GetWindowThreadProcessId(hwnd, &pOfWindow);    
        // this window is our process window
        if ( pOfWindow == pid )
        {
            char text[MAX_PATH];    
            GetWindowText(hwnd,text,sizeof(text));
            char* A_N = Get_Account_Number();
            if ( strstr(text, A_N) != NULL )
            {
                bAccValidated = true;        
                return (FALSE);
            }
        }
        return (TRUE);
    }
    
    
    MT4_EXPFUNC bool __stdcall Account_Validation()
    {
        bAccValidated = false;
        DWORD pid = GetCurrentProcessId();
        EnumWindows( EnumWindowsProc, pid );
        
        time_t seconds = time (NULL);
    
        if (bAccValidated && seconds<1293861600)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    
    
    MT4_EXPFUNC char* __stdcall Get_Signal(double S1, double S2, double S3, double S4, double S5, double S6, double S7, double S8, double S9, double S10, double S11, double S12, double S13, double S14, double S15, double S16, double S17, double S18, double S19, double S20, double S21, double S22, double S23, double S24, double S25, double S26, double S27, double S28, double S29, double S30, double S31, double S32, double S33, double S34, double S35, double S36, double S37, double S38, double S39, double S40, double S41, double S42, double S43, double S44, double S45)
    {
        if ( Account_Validation() )
        {
            if ((S39> 95))
            {
                return("Sell" );
            }
            if ((S39< 5))
            {
                return("Buy");
            }
        }
        return("Forbiden");    
    }


    When compile that I have not any error but when want make dll and build I have below errors:

    1>------ Build started: Project: ExpertSample, Configuration: Debug Win32 ------
    1>Linking...
    1> Creating library .\Debug/ExpertSample.lib and object .\Debug/ExpertSample.exp
    1>LINK : warning LNK4199: /DELAYLOAD:OleAcc.dll ignored; no imports found from OleAcc.dll
    1>ExpertSample.obj : error LNK2019: unresolved external symbol __imp__GetWindowTextA@12 referenced in function "int __stdcall EnumWindowsProc(struct HWND__ *,long)" (?EnumWindowsProc@@YGHPAUHWND__@@J@Z)
    1>ExpertSample.obj : error LNK2019: unresolved external symbol __imp__GetWindowThreadProcessId@8 referenced in function "int __stdcall EnumWindowsProc(struct HWND__ *,long)" (?EnumWindowsProc@@YGHPAUHWND__@@J@Z)
    1>ExpertSample.obj : error LNK2019: unresolved external symbol __imp__EnumWindows@8 referenced in function "bool __stdcall Account_Validation(void)" (?Account_Validation@@YG_NXZ)
    1>.\Debug/ExpertSample.dll : fatal error LNK1120: 3 unresolved externals
    1>Build log was saved at "file://c:\Users\Reza\Desktop\Unlimited\DLLSample\Debug\BuildLog.htm"
    1>ExpertSample - 4 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    I added Wininet.lib too, but I have these errors too.
    Can you help me for solve that.
    Thanks.
    Last edited by ovidiucucu; June 22nd, 2010 at 04:23 AM. Reason: [CODE] and [/CODE] tags added

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How Solve error LNK2019?

    Quote Originally Posted by rezame View Post
    Code:
    1>Linking...
    1>   Creating library .\Debug/ExpertSample.lib and object .\Debug/ExpertSample.exp
    1>LINK : warning LNK4199: /DELAYLOAD:OleAcc.dll ignored; no imports found from OleAcc.dll
    1>ExpertSample.obj : error LNK2019: unresolved external symbol __imp__GetWindowTextA@12 referenced in function "int __stdcall EnumWindowsProc(struct HWND__ *,long)" (?EnumWindowsProc@@YGHPAUHWND__@@J@Z)
    1>ExpertSample.obj : error LNK2019: unresolved external symbol __imp__GetWindowThreadProcessId@8 referenced in function "int __stdcall EnumWindowsProc(struct HWND__ *,long)" (?EnumWindowsProc@@YGHPAUHWND__@@J@Z)
    1>ExpertSample.obj : error LNK2019: unresolved external symbol __imp__EnumWindows@8 referenced in function "bool __stdcall Account_Validation(void)" (?Account_Validation@@YG_NXZ)
    1>.\Debug/ExpertSample.dll : fatal error LNK1120: 3 unresolved externals
    1>Build log was saved at "file://c:\Users\Reza\Desktop\Unlimited\DLLSample\Debug\BuildLog.htm"
    1>ExpertSample - 4 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I added Wininet.lib too, but I have these errors too.
    Can you help me for solve that.
    Thanks.
    What does Wininet.lib have to do with GetWindowText API?
    Please, read the GetWindowText Function and other Windows API documentation and note the Requirements section:
    Requirements
    ...
    Header
    Winuser.h (include Windows.h)
    Library
    User32.lib
    DLL
    User32.dll
    Unicode and ANSI names
    GetWindowTextW (Unicode) and GetWindowTextA (ANSI)
    Besides, please, use Code tags!
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: How Solve error LNK2019?

    In the bootom of each function documentation from MSDN, you can find in which library it is.
    For example, if you use GetWindowText you need to link to User32.lib.
    However, to avoid headaches, you can create a Win32 application from scratch. The good Application Wizard will add libs itself.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    May 2010
    Posts
    38

    Re: How Solve error LNK2019?

    Dear Victor,
    Thanks.
    It works now.
    Best Regards,

  5. #5
    Join Date
    May 2010
    Posts
    38

    Re: How Solve error LNK2019?

    Dear ovidiucucu,
    Thanks.

  6. #6
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: How Solve error LNK2019?

    Dear rezame,

    You are welcome!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured