Tech Off Thread

7 posts

unresolved external symbols with eMbedded VC4 :(

Back to Forum: Tech Off
  • User profile image
    LookitsPuck

    Hey all!

    I just asked a question yesterday regarding VS.NET and Windows CE development with native C++, so I went ahead and dl'ed eMbedded VC4 + SP4, and got it running and the emulator that's built in.

    After much testing, I got things running the way I like. Smiley Now, i need to start working with jpegs/bmps for a slideshow application I'll be developing, so I needed a library to use for this and happened upon imgdecmp, but unfortunately this library isn't very well documented. Sad So I finally founded a site called unsupported software that actually documented it. Smiley

    Either way, I got everything hooked up, have everything properly linked, and these are the errors I'm getting:

    Linking...
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol __imp__FreeLibrary@4 referenced in function _GetHalftonePalette
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol __imp__GetProcAddressW@8 referenced in function _GetHalftonePalette
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol _MessageBoxW@16 referenced in function _GetHalftonePalette
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol _LoadLibraryW@4 referenced in function _GetHalftonePalette
    emulatorRel/SlideshowNATest.exe : fatal error LNK1120: 4 unresolved externals
    Error executing link.exe.

    I am not getting anywhere with this, and I've Googled it up to no end. Sad Everything is properly linked that I can see, and I am using either the WCE emulator or WCE x86 with the same errors.

    Here is the quote from the main program (it is terribly sloppy, I know, this is my first time fiddling with WinCE programming and this is more or less a template test):

    [code]
    // SlideshowNATest.cpp : Defines the entry point for the application.
    //
     
    #include "stdafx.h"
    #include "SlideshowNATest.h"
    #include <imgdecmp.h>
    #include <msgboxlib.h>
    #include <commctrl.h>
     
    #define MAX_LOADSTRING 100
     
    // Global Variables:
    HINSTANCE   hInst;   // The current instance
    HWND    hwndCB;   // The command bar handle
     

    HINSTANCE g_hInst = NULL;  // Local copy of hInstance, used in Commandbar_Create & Commandbar_InsertMenubar
    HWND      g_hwndMain = NULL;    // Handle to Main window returned from CreateWindow
    HWND   g_hwndCBr =NULL;       // Handle to a commandbar
    HMENU   g_hMenu =NULL;       // Handle to a commandbar0 menu
     
    HBITMAP  g_hDestBitmap = NULL;
    HDC    g_hdcMem = NULL;      //A global compatible HDC
     
    UINT   g_nCBrHeight = 0;
     
    TCHAR szAppName[] = TEXT("PalmImgDecmp1 Application");
    TCHAR szTitle[]   = TEXT("PalmImgDecmp1");
     
    int g_iScale = 100;
    int g_iMaxWidth = 10000;
    int g_iMaxHeight = 10000;
    BOOL g_bStretchBlt = FALSE;
     
    // Forward declarations of functions included in this code module:
    ATOM    MyRegisterClass (HINSTANCE, LPTSTR);
    BOOL    InitInstance (HINSTANCE, int);
    LRESULT CALLBACK WndProc   (HWND, UINT, WPARAM, LPARAM);
    LRESULT CALLBACK About   (HWND, UINT, WPARAM, LPARAM);
     

    BOOL CALLBACK  AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK  OptionsDlgProc(HWND, UINT, WPARAM, LPARAM);
     
    BOOL  GetPictureFromFile(HWND );          //Uses the OpenFile dialog to get filename
    BOOL ReadPictureFile(HWND , LPTSTR );         //Does the work
     
    static DWORD CALLBACK GetImageData( LPSTR , DWORD , LPARAM  );   //Callback for reading data
    static void CALLBACK ImageProgress( IImageRender *, BOOL , LPARAM  ); //Callback for completion
     
    int WINAPI WinMain( HINSTANCE hInstance,
         HINSTANCE hPrevInstance,
         LPTSTR    lpCmdLine,
         int       nCmdShow)
    {
     MSG msg;
     HACCEL hAccelTable;
     
     // Perform application initialization:
     if (!InitInstance (hInstance, nCmdShow))
     {
      return FALSE;
     }
     
     hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SLIDESHOWNATEST);
     
     // Main message loop:
     while (GetMessage(&msg, NULL, 0, 0))
     {
      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
      {
       TranslateMessage(&msg);
       DispatchMessage(&msg);
      }
     }
     
     return msg.wParam;
    }
     
    //
    //  FUNCTION: MyRegisterClass()
    //
    //  PURPOSE: Registers the window class.
    //
    //  COMMENTS:
    //
    //    It is important to call this function so that the application
    //    will get 'well formed' small icons associated with it.
    //
    ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
    {
     WNDCLASS wc;
     
        wc.style   = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc  = (WNDPROC) WndProc;
        wc.cbClsExtra  = 0;
        wc.cbWndExtra  = 0;
        wc.hInstance  = hInstance;
        wc.hIcon   = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SLIDESHOWNATEST));
        wc.hCursor   = 0;
        wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
        wc.lpszMenuName  = 0;
        wc.lpszClassName = szWindowClass;
     
     return RegisterClass(&wc);
    }
     
    // === ReadPictureFile ==============================================
    BOOL ReadPictureFile(HWND hwnd, LPTSTR szFilenameW)
    {
     HRESULT hr;
     BYTE    szBuffer[1024] = {0};
     HANDLE hFile = INVALID_HANDLE_VALUE;
     DecompressImageInfo dii;
     HDC hdc;
     
     hFile = CreateFile(szFilenameW , GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
     if (hFile == INVALID_HANDLE_VALUE)
      return FALSE;
     
     hdc = GetDC(hwnd);
     
     dii.dwSize = sizeof( DecompressImageInfo );      // Size of this structure
     dii.pbBuffer = szBuffer;          // Pointer to the buffer to use for data
     dii.dwBufferMax = 1024;           // Size of the buffer
     dii.dwBufferCurrent = 0;          // The amount of data which is current in the buffer
     dii.phBM = &g_hDestBitmap;          // Pointer to the bitmap returned (can be NULL)
     dii.ppImageRender = NULL;          // Pointer to an IImageRender object (can be NULL)
     dii.iBitDepth = GetDeviceCaps(hdc,BITSPIXEL);     // Bit depth of the output image
     dii.lParam = ( LPARAM ) hFile;         // User parameter for callback functions
     dii.hdc = hdc;             // HDC to use for retrieving palettes
     dii.iScale = g_iScale;           // Scale factor (1 - 100)
     dii.iMaxWidth = g_iMaxWidth;         // Maximum width of the output image
     dii.iMaxHeight = g_iMaxHeight;         // Maxumum height of the output image
     dii.pfnGetData = GetImageData;         // Callback function to get image data
     dii.pfnImageProgress = ImageProgress;       // Callback function to notify caller of progress decoding the image
     dii.crTransparentOverride = ( UINT ) -1;      // If this color is not (UINT)-1, it will override the
                     // transparent color in the image with this color. (GIF ONLY)
     hr = DecompressImageIndirect( &dii );
      
     // Clean up
     CloseHandle( hFile );
     ReleaseDC(hwnd, hdc);
     
     return true;
    }
     
    //
    //  FUNCTION: InitInstance(HANDLE, int)
    //
    //  PURPOSE: Saves instance handle and creates main window
    //
    //  COMMENTS:
    //
    //    In this function, we save the instance handle in a global variable and
    //    create and display the main program window.
    //
    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
     HWND hWnd;
     TCHAR szTitle[MAX_LOADSTRING];   // The title bar text
     TCHAR szWindowClass[MAX_LOADSTRING];  // The window class name
     
     hInst = hInstance;  // Store instance handle in our global variable
     // Initialize global strings
     LoadString(hInstance, IDC_SLIDESHOWNATEST, szWindowClass, MAX_LOADSTRING);
     MyRegisterClass(hInstance, szWindowClass);
     
     LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
     hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
     
     if (!hWnd)
     { 
      return FALSE;
     }
     
     ShowWindow(hWnd, nCmdShow);
     UpdateWindow(hWnd);
     if (hwndCB)
      CommandBar_Show(hwndCB, TRUE);
     
     return TRUE;
    }
     
    //
    //  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
    //
    //  PURPOSE:  Processes messages for the main window.
    //
    //  WM_COMMAND - process the application menu
    //  WM_PAINT - Paint the main window
    //  WM_DESTROY - post a quit message and return
    //
    //
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
     HDC hdc;
     int wmId, wmEvent;
     PAINTSTRUCT ps;
     TCHAR szHello[MAX_LOADSTRING];
     
     switch (message)
     {
      case WM_COMMAND:
       wmId    = LOWORD(wParam);
       wmEvent = HIWORD(wParam);
       // Parse the menu selections:
       switch (wmId)
       {
        case IDM_HELP_ABOUT:
           DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
           break;
        case IDM_FILE_EXIT:
           DestroyWindow(hWnd);
           break;
        default:
           return DefWindowProc(hWnd, message, wParam, lParam);
       }
       break;
      case WM_CREATE:
       hwndCB = CommandBar_Create(hInst, hWnd, 1);   
       CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
       CommandBar_AddAdornments(hwndCB, 0, 0);
       break;
      case WM_PAINT:
       RECT rt;
       hdc = BeginPaint(hWnd, &ps);
       GetClientRect(hWnd, &rt);
       LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
       DrawText(hdc, szHello, _tcslen(szHello), &rt,
        DT_SINGLELINE | DT_VCENTER | DT_CENTER);
       EndPaint(hWnd, &ps);
       break;
      case WM_DESTROY:
       CommandBar_Destroy(hwndCB);
       PostQuitMessage(0);
       break;
      default:
       return DefWindowProc(hWnd, message, wParam, lParam);
       }
       return 0;
    }
     
    // Mesage handler for the About box.
    LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
     RECT rt, rt1;
     int DlgWidth, DlgHeight; // dialog width and height in pixel units
     int NewPosX, NewPosY;
     
     switch (message)
     {
      case WM_INITDIALOG:
       // trying to center the About dialog
       if (GetWindowRect(hDlg, &rt1)) {
        GetClientRect(GetParent(hDlg), &rt);
        DlgWidth = rt1.right - rt1.left;
        DlgHeight = rt1.bottom - rt1.top ;
        NewPosX  = (rt.right - rt.left - DlgWidth)/2;
        NewPosY  = (rt.bottom - rt.top - DlgHeight)/2;
        
        // if the About box is larger than the physical screen
        if (NewPosX < 0) NewPosX = 0;
        if (NewPosY < 0) NewPosY = 0;
        SetWindowPos(hDlg, 0, NewPosX, NewPosY,
         0, 0, SWP_NOZORDER | SWP_NOSIZE);
       }
       return TRUE;
     
      case WM_COMMAND:
       if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
       {
        EndDialog(hDlg, LOWORD(wParam));
        return TRUE;
       }
       break;
     }
        return FALSE;
    }
     
     
     
    // ImageProgress
    static void CALLBACK ImageProgress( IImageRender *pRender, BOOL bComplete, LPARAM lParam )
    {
     if( bComplete )
     {
      //Do whatever when done processing the image
     }
    }
     
    // GetImageData
    static DWORD CALLBACK GetImageData( LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam )
    {
      DWORD dwNumberOfBytesRead;
     
     if ( (HANDLE)lParam != INVALID_HANDLE_VALUE )
     {
      //graphics file
      ReadFile( (HANDLE)lParam, szBuffer, dwBufferMax, &dwNumberOfBytesRead, NULL );
     }
     else
     {
      return 0;
     }
     
      return dwNumberOfBytesRead;
      // return amount read
    }
    [/code]

    Can anyone tell me why I'm getting these unresolved symbol files? I'm going out of my mind with this. Sad

  • User profile image
    Rossj

    LookitsPuck wrote:
    Linking...
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol __imp__FreeLibrary@4 referenced in function _GetHalftonePalette
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol __imp__GetProcAddressW@8 referenced in function _GetHalftonePalette
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol _MessageBoxW@16 referenced in function _GetHalftonePalette
    imgdecmp.lib(imagedecmp.obj) : error LNK2019: unresolved external symbol _LoadLibraryW@4 referenced in function _GetHalftonePalette
    emulatorRel/SlideshowNATest.exe : fatal error LNK1120: 4 unresolved externals
    Error executing link.exe.


    Assuming you have the .libs in the path and that they are for the right target platform and that there are no further dependencies for the third party lib and you have already included them and it is linking correctly - I'm stumped Smiley

  • User profile image
    Mike Dimmick

    You appear to be using the desktop version of the imgdecmp library. The symbol decoration scheme given is the one used by the desktop __stdcall calling convention. Windows CE does not have different calling conventions - __stdcall and __cdecl are in fact the same thing for a CE platform.

    Ensure that you're using a suitable import library for Windows CE and for your processor type.

  • User profile image
    LookitsPuck

    Hi Mike,

       I figured this is a library issue, but now the aggravating issue is...where?

       I got the lib file from here:
       http://www.unsupportedsoftware.com/ce/dev/imgdecmp.htm

       There's a zip that has all the library files for it, and I took the default named lib file (imgdecmp.lib) and threw it in the x86 and emulator lib folders. I get the same unresolved external symbol for both of them. Is there any other place you'd recommend that I can get the library file? This is a huge hold up for me and I can't make any progress. Sad Ugh, I hate being a newb at this!

       Just as a quick question, what are the differences for the Win32 WCE's? There's x86, emulator, shx, mipsx, armx?

       I'm going to be deploying to a machine using Windows CE .NET 4.2, so I figure x86 will be the way to go. Either way, I'd like to at least run the program in the emulator to see if I can get it going, and I can't even do that. Sad This is unfortunatley not hooked up/debugging against the handheld device, yet.

       What can I do to solve this problem?

  • User profile image
    LookitsPuck

    For further reference, the processor info is this:

    Samsung 2440 processor @ 400 MHz

  • User profile image
    Mike Dimmick

    The page you've got there is very, very old. It dates back to Palm-Size PC 1.0 as far as I can tell. At that point, I don't think Palm-Size PC (which later evolved into Pocket PC then Windows Mobile) even supported ARM-instruction-set processors.

    The download has import libraries for x86em, Hitachi SHx and MIPS R4000-series processors. 'x86em' is a Microsoft invention - the original 'emulators' for Handheld PC, Palm-Size PC and right up to Pocket PC 2000 were kludges that actually ran the program code directly on your regular Windows (NT, 2000) desktop. As such the code needed to be compiled using the desktop Windows conventions.

    The Pocket PC 2002, CE 4.x, and Windows Mobile 2003 emulator is based on Virtual PC. It's still using your PC processor but is actually running (a special build of) the target operating system in a virtualised environment. It's a lot closer to how a device with an x86 processor would behave.

    The newest emulator supplied with Visual Studio 2005 emulates an ARM processor. That means that the emulator is running pretty much the same code that an actual device does.

    The Samsung 2440 processor uses the ARM instruction set. To compile for the device, you should use the ARMV4 processor type (possibly ARMV4I if the platform was compiled that way). You should also be using the correct SDK for the device - you may find that imgdecmp.dll isn't available on that device. This article mentions that imgdecmp.lib was supplied in the Pocket PC 2002 SDK but I'm inclined to think that was an accident since the header file is not included. The situation is the same in Windows Mobile 2003 and Windows Mobile 5.0 Pocket PC SDKs.

    Since it's not documented or officially available, I'd be wary of using it in my application. I'd look for a different library to achieve your goal.

  • User profile image
    LookitsPuck

    Thank you, Mike. This is a simple slideshow application, so all I need is a library that will let me display images (preferably JPG or BMP). What is same to assume on the Samsung processor that I labeled using Windows CE .NET 4.2 and native C++? I need this by Monday and am absolutely (unfortunately) clueless. What library should I use and are there any resources you can point me to.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.