Announcement

Collapse
No announcement yet.

DLL entry point not found

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DLL entry point not found

    Hey everybody,

    I'm trying to use a function from a C/C++ DLL to detect faces in an image.

    This is how it's in the DLL:

    Code:
    int * __cdecl facedetect_frontal(unsigned char *,unsigned char *,int,int,int,float,int,int,int,int)
    I'm trying to import it into my project using this declaration:

    Code:
    DECLARE FUNCTION facedetect_frontal LIB "libfacedetect.DLL" CDECL ALIAS "facedetect_frontal" (BYVAL result_buf AS BYTE PTR, BYVAL img_data AS DWORD, BYVAL xwidth AS LONG, BYVAL xheight AS LONG, _
    BYVAL xstep AS LONG, BYVAL scale AS SINGLE, BYVAL min_neighbors AS LONG, BYVAL min_object_width AS LONG, _
    BYVAL max_object_width AS LONG, BYVAL doLandmark AS LONG) AS DWORD
    When I run my program, it errors out with the message that the function "facedetect_frontal" can't be found.

    I haven't done this much so it might be an obvious oversight on my part but... does anybody have an idea what I'm doing wrong? Thanks in advance for any guidance the community can give.

  • #2
    Oliver,
    I'm wondering why these
    unsigned char *,unsigned char *

    are declared differently.
    BYVAL result_buf AS BYTE PTR, BYVAL img_data AS DWORD

    Also shouldn't there be an IMPORT in there. Like this:

    Code:
    DECLARE FUNCTION CopyFileExA IMPORT "KERNEL32.DLL" ALIAS "CopyFileExA" ( _
    BYREF lpExistingFileName AS ASCIIZ _ ' __in LPCSTR lpExistingFileName
    , BYREF lpNewFileName AS ASCIIZ _ ' __in LPCSTR lpNewFileName
    , BYVAL lpProgressRoutine AS DWORD _ ' __in LPPROGRESS_ROUTINE lpProgressRoutine
    , BYVAL lpData AS DWORD _ ' __in LPVOID lpData
    , BYREF pbCancel AS LONG _ ' __in LPBOOL pbCancel
    , BYVAL dwCopyFlags AS DWORD _ ' __in DWORD dwCopyFlags
    ) AS LONG ' BOOL
    CDECL IMPORT

    Where is your DLL located? Is the library already loaded in the address space?

    Comment


    • #3
      Hi Jim,

      Thank you for replying.

      result_buf is a pointer to a block of memory which will contain the rectangles identifying faces on return.

      img_data is a pointer to a block of memory containing single-channel (grayscale) image pixels with every pixel being one byte.

      I've tried having both as BYTE PTRs and DWORDs as well as tried the mix you see above. As long as they're both 32-bit pointers, wouldn't BYTE PTR and DWORD effectively be the same four-byte representation?

      If you were to write that declaration, what data types would you use?

      Thanks again, Jim. I really appreciate the help. Have been trying this dozens of different ways in the last two days and am at my wit's end ;-)

      Comment


      • #4
        I would say you'll need to fix this problem first. "When I run my program, it errors out with the message that the function "facedetect_frontal" can't be found."

        Ok, I see you are using the legacy LIB for IMPORT.

        I'm thinking LIB "libfacedetect.DLL"
        should be
        LIB "LIBFACEDETECT.DLL"

        Comment


        • #5
          Also shouldn't there be an IMPORT in there. Like this:
          Not really. IMPORT is the new syntax, but LIB is still allowed. He has a LIB param.

          the message that the function "facedetect_frontal" can't be found.
          Sounds like an alias mis-match. I don't do C, but maybe ALIAS "FACEDETECT_FRONTAL" in the DECLARE might work. (When a function is created in a DLL with PB with no ALIAS, the function name is capitalized as a default ALIAS.)

          Cheers,
          Dale

          Comment


          • #6
            I'm thinking LIB "libfacedetect.DLL"
            should be
            LIB "LIBFACEDETECT.DLL"
            File names not case sensitive.
            Dale

            Comment


            • #7
              Maybe the name is mangled, something like "[email protected]". You may need to get a list of exported names from the dll.
              Forum: http://www.jose.it-berater.org/smfforum/index.php

              Comment


              • #8
                Jim,

                I had tried both all caps for the alias and the exact capitalization from the DLL itself (I used DLL Export Viewer to see the exact definition).

                I had also tried both LIB and IMPORT to make sure this wasn't the reason.

                The DLL is sitting in the same folder as the executable. The result doesn't change if I put it in the SYSTEM32 folder either.

                It also doesn't complain that it can't access the DLL - which it does if I move it out of the folder. It's complaining that it can't find the function.

                I'm really not trying to pawn off my own homework on you guys :-). It's just that I thought I was checking all the boxes by using the exact capitalization from the DLL itself and having the DLL in the same folder as the EXE.

                After two days of constant research and trial and error, I don't know what else I could try.

                Thanks again for your suggestions!

                Comment


                • #9
                  Originally posted by José Roca View Post
                  Maybe the name is mangled, something like "[email protected]". You may need to get a list of exported names from the dll.
                  Thank you, José. I opened the DLL in a hex editor now and lo and behold, the function's actual name is "[email protected]@[email protected]", although it is shown as "facedetect_frontal" in DLL Export Viewer.

                  Using this alias, it's working fine now.

                  Really appreciate your help - again!

                  Comment


                  • #10
                    Thank you José. That was next.

                    Comment

                    Working...
                    X