CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Posts
    17

    DLL won't build! Please help!

    Hi, I am trying to write a DLL which contain the quicksort function as an excercise. I can't seem to build this dll. The code for the dll is as follows


    // Sort DLL.
    ////////////

    #include <windows.h>

    template <class Stype> void qsort(Stype *item, int count);
    template <class Stype> void quicksort(Stype *item, int left, int right);

    BOOL WINAPI DllEntryPoint (HINSTANCE hDLL, DWORD dwReason, LPVOID Reserved)
    {
    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
    {

    break;
    }

    case DLL_PROCESS_DETACH:
    {

    break;
    }

    }

    return TRUE;

    }


    //Sort Function : Quicksort Entry function
    template <class Stype> void qsort(Stype *item, int count)
    {
    quicksort(item,0,count-1);
    }

    //Quicksort Function : Actual Quicksort algorithm
    template <class Stype> void quicksort(Stype *item, int left, int right)
    {
    register int p,q;
    Stype x,y;

    p = left;
    q = right;
    x = item[(left+right)/2];

    do {

    while (item[p] <x && p <right) {
    p++;
    }

    while (item[q] && q>left) {
    q--;
    }

    if (p<=q) {
    y = item[p];
    item[p] = item[q];
    item[q] = y;
    p++;
    q--;
    }

    } while (p<=q);

    if (left<q) {
    quicksort(item, left, q);
    }

    if (p<right) {
    quicksort(item, p, right);
    }

    }





    The DEF file is as follows

    ;Sort.def
    ;
    ; Definition File for Sort.dll

    LIBRARY sort

    CODE PRELOAD MOVABLE DISCARDABLE
    DATA PRELOAD SINGLE

    EXPORTS
    qsort
    quicksort
    ;end

    I get the following error when I try to build the DLL.

    --------------------Configuration: Sort - Win32 Release--------------------
    Linking...
    .\Sort.def : warning LNK4017: CODE statement not supported for the target platform; ignored
    .\Sort.def : warning LNK4017: DATA statement not supported for the target platform; ignored
    Sort.def : error LNK2001: unresolved external symbol quicksort
    Release/Sort.lib : fatal error LNK1120: 1 unresolved externals
    LINK : fatal error LNK1141: failure during build of exports file
    Error executing link.exe.

    Sort.dll - 3 error(s), 2 warning(s)

    I would really appreciate any help. Thank you.

    Harold Soh





  2. #2
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: DLL won't build! Please help!

    try this:

    extern "C" template <class Stype> void qsort(Stype *item, int count);
    extern "C" template <class Stype> void quicksort(Stype *item, int left, int right);
    //Sort Function : Quicksort Entry function
    extern "C" template <class Stype> void qsort(Stype *item, int count)
    {
    quicksort(item,0,count-1);
    }
    //Quicksort Function : Actual Quicksort algorithm
    extern "C" template <class Stype> void quicksort(Stype *item, int left, int right)
    {
    //.......
    }




    Let me know if this help u
    Regards,
    Ovidiu


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