dll entry point not found [Solved]

Windows specific questions.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

dll entry point not found [Solved]

Post by BasicScience »

Trying to call routines in a commercially provided dll. The company provides the .h file with the proc and func definitions. Part of the .h file is shown below

Code: Select all

// define the macro for exporting/importing the API entry points.
// N.B. the symbol below should only be defined when building this DLL.
#ifdef MAK_AXCAPI_DLL
   #define AXCAPI __declspec(dllexport)
#else
   #define AXCAPI __declspec(dllimport)
#endif

// Check on the version number of the API interface.
AXCAPI BOOL WINAPI AXC_CheckAPIVersion(LPCSTR pszQueryVersion);

// Get scaled output gain
AXCAPI BOOL WINAPI AXC_GetScaledOutputGain(HAXC hAXC, double *pdGain, UINT uChannel, UINT uMode, int *pnError);
When I use PExplorer to create the list of entry points, some of the function names are preceded by "underscore"

Code: Select all

AXC_CheckAPIVersion; Index 8;
_AXC_GetScaledOutputGain@20; Index 77
I've tried dlltool, with and without the underscore, to create the library. The code compiles in FB but I get this windows runtime error
"The procedure entry point _AXC_GetScaledOutputGain could not be located in the dynamic link library.
Last edited by BasicScience on Jan 18, 2019 2:59, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

Is it AxoclampDriver.h ?
https://github.com/johndempster/WinWCPXE

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

I don't have the AxoclampDriver.dll but this should work.

Joshy

file: AxoclampDriver.bi:

Code: Select all

#ifndef __AXOCLAMPDRIVER_BI__
#define __AXOCLAMPDRIVER_BI__

#include once "windows.bi"

#inclib "axoclampdriver"

#define DECLARE_HANDLE(name) type name##__ : as integer unused : end type : type name as name##__ ptr

' The handle type declaration.
DECLARE_HANDLE(HAXC)
' API version number.
#define AXC_APIVERSION       1,0,0,56
#define AXC_APIVERSION_STR  "1.0.0.56"
extern "Windows-MS"

' Check on the version number of the API interface.
declare function AXC_CheckAPIVersion(pszQueryVersion as const zstring ptr) as BOOL
' Get scaled output gain
declare function AXC_GetScaledOutputGain(hAXC as HAXC, pdGain as double ptr, uChannel as UINT, uMode as UINT, pnError as integer ptr) as BOOL
 '...

end extern

#endif '__AXOCLAMPDRIVER_BI__
file test.bas

Code: Select all

#include once "AxoclampDriver.bi"

print AXC_CheckAPIVersion(AXC_APIVERSION_STR)

sleep
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: dll entry point not found

Post by BasicScience »

Yes, it's axoclampdriver.dll. I'll try tomorrow AM.
Thanks.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: dll entry point not found

Post by BasicScience »

The FB compiler doesn't like the

extern "Windows-MS"
...
end Extern

statements, which cause the error message "undefined reference to 'AXC_CheckAPIVersion'.

If I remove the extern statements, then it complies and seems to work (Returns API version "1" but I'm not sure if that's correct). I need the hardware connected to check the other functions at work tomorrow.

Thanks again for your help. I did find the JohnDempster WinWCP material on github, but unfortunately the syntax for Delphi is about as mysterious to me as that of .h files in C (and the WIN API). For example, even with > 10 years experience in FB, I never would have come up with the code you suggested for DECLARE_HANDLE.

Many thanks.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

then replace
extern "Windows-MS"
with
extern "Windows"

but the declares should be in an extern XXX : end extern block.

Joshy
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: dll entry point not found

Post by BasicScience »

Still getting the same error - Entry Point could not be located

Here's a screen shot of the export table from PExplorer. All the functions with the "_" prefix cause the same error, whereas I can call any of the functions without "_". I have tried making a MyLIb.def file with and without "_" but neither works. Seems to be the "mangled name" curse of procedure calls.

[img]
https://sites.google.com/site/freebasic ... edirects=0
[/img]
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: dll entry point not found

Post by dodicat »

Try loadlibraryex with parameter 3=0.
try some other values.

Code: Select all


 

declare function LoadLibraryExA alias "LoadLibraryExA"(byval as zstring ptr, byval as any ptr,byval as long) as any ptr


dim as any ptr L=LoadLibraryexA("axoclampdriver.dll",0,0)
if L=0 then print "unable to load dll":sleep:end 


 dim fn as function(pszQueryVersion as const zstring ptr) as BOOLEAN=dylibsymbol(L,"AXC_CheckAPIVersion")
  if fn=0 then print "unable to load function":sleep:end 
   print "OK"
     


sleep  
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

@BasicScience upload the dll I can create the right import lib and *.bi file.
I self can't use it I don't have the Equipment.

Joshy
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: dll entry point not found

Post by BasicScience »

Thanks. I have been able to communicate with the DLL to confirm the API Version and to communicate with the hardware to retrieve the serial number (via AXC_FindFirstDevice).

Here's the DLL
https://sites.google.com/site/freebasic ... ects=0&d=1

and the axoclampdriver.h file
https://sites.google.com/site/freebasic ... ects=0&d=1

The DLL contains 163 functions! I only need a subset, and I can follow from your (successful) examples.

Code: Select all

Section contains the following exports for AxoclampDriver.dll

    00000000 characteristics
    5A6790B7 time date stamp Tue Jan 23 11:44:55 2018
        0.00 version
           1 ordinal base
         163 number of functions
         163 number of names

    ordinal hint RVA      name

          5    0 00019650 AXC_BuildErrorText
          8    1 00014C40 AXC_CheckAPIVersion
         10    2 00014F00 AXC_CloseDevice
         11    3 00014CA0 AXC_CreateHandle
         12    4 00014D20 AXC_DestroyHandle
         14    5 00014D80 AXC_FindFirstDevice
         15    6 00014E20 AXC_FindNextDevice
        107    7 00014E90 AXC_OpenDevice
          1    8 00015AB0 _AXC_AcquireMeterData@12
          2    9 000175B0 _AXC_AutoBridge@16
          3    A 00017100 _AXC_AutoPipetteOffset@16
          4    B 00018670 _AXC_AutoScaledOutputZero@16
          6    C 00016F30 _AXC_Buzz@16
          7    D 000150D0 _AXC_CalibrateHeadstageProperties@12
          9    E 00017980 _AXC_ClearElectrode@24
         13    F 00019510 _AXC_EraseFirmware@8
         16   10 00018FC0 _AXC_GetAudioEnable@12
         17   11 000190B0 _AXC_GetAudioGain@12
         18   12 00019120 _AXC_GetAudioGainRange@12
         19   13 00019200 _AXC_GetAudioMode@12
         20   14 000192E0 _AXC_GetAudioSignal@20
         21   15 00015D60 _AXC_GetAutoEnable@16
         22   16 00016240 _AXC_GetAutoICDelay@16
         23   17 000162B0 _AXC_GetAutoICDelayRange@16
         24   18 00016160 _AXC_GetAutoICReturn@16
         25   19 00015E50 _AXC_GetAutoPolarity@16
         26   1A 00015F30 _AXC_GetAutoSource@16
         27   1B 00015730 _AXC_GetAutoSyncOutput@12
         28   1C 00016010 _AXC_GetAutoThreshold@16
         29   1D 00016080 _AXC_GetAutoThresholdRange@16
         30   1E 00016390 _AXC_GetAutoVCDelay@16
         31   1F 00016400 _AXC_GetAutoVCDelayRange@16
         32   20 00017690 _AXC_GetBridgeEnable@20
         33   21 000178A0 _AXC_GetBridgeLevel@20
         34   22 00017790 _AXC_GetBridgeLock@20
         35   23 00017910 _AXC_GetBridgeRange@20
         36   24 00017020 _AXC_GetBuzzDuration@20
         37   25 00017090 _AXC_GetBuzzDurationTable@24
         38   26 00017A70 _AXC_GetCapNeutEnable@20
         39   27 00017B80 _AXC_GetCapNeutLevel@20
         40   28 00017BF0 _AXC_GetCapNeutRange@20
         41   29 000152B0 _AXC_GetCi@16
         42   2A 00019430 _AXC_GetCommandCount@12
         43   2B 000153A0 _AXC_GetCustomHeadstageValues@24
         44   2C 00018EC0 _AXC_GetDCRestoreEnable@20
         45   2D 00015810 _AXC_GetDeviceName@16
         46   2E 00016740 _AXC_GetExtCmdEnable@20
         47   2F 000167D0 _AXC_GetExtCmdSensit@20
         48   30 000195E0 _AXC_GetFirmwareCRC@20
         49   31 000157A0 _AXC_GetFirmwareVersion@20
         50   32 000151D0 _AXC_GetHeadstageType@20
         51   33 000164E0 _AXC_GetHoldingEnable@20
         52   34 000165F0 _AXC_GetHoldingLevel@20
         53   35 00016660 _AXC_GetHoldingRange@20
         54   36 00018C00 _AXC_GetLoopGain@20
         55   37 00018C70 _AXC_GetLoopGainRange@20
         56   38 00018D60 _AXC_GetLoopLag@20
         57   39 00018DD0 _AXC_GetLoopLagTable@24
         58   3A 00015880 _AXC_GetManufactureDate@16
         59   3B 000194A0 _AXC_GetMeanCommandTime@12
         60   3C 00015B90 _AXC_GetMeterAttenuatorEnable@16
         61   3D 00015A40 _AXC_GetMeterSignal@20
         62   3E 00015C80 _AXC_GetMode@16
         63   3F 00017440 _AXC_GetOscKillerEnable@20
         64   40 00017540 _AXC_GetOscKillerMethod@20
         65   41 000172F0 _AXC_GetPipetteOffset@20
         66   42 000171E0 _AXC_GetPipetteOffsetLock@20
         67   43 00017360 _AXC_GetPipetteOffsetRange@20
         68   44 00015490 _AXC_GetPropertyRules@20
         69   45 00016E50 _AXC_GetPulseAmplitude@20
         70   46 00016EC0 _AXC_GetPulseAmplitudeRange@20
         71   47 00016CF0 _AXC_GetPulseDuration@20
         72   48 00016D60 _AXC_GetPulseDurationTable@24
         73   49 00015240 _AXC_GetRf@20
         74   4A 00018AA0 _AXC_GetSamplePeriod@20
         75   4B 00018B10 _AXC_GetSamplePeriodRange@20
         76   4C 00018940 _AXC_GetScaledOutputCacheSettings@24
         77   4D 000181F0 _AXC_GetScaledOutputGain@20
         78   4E 00018260 _AXC_GetScaledOutputGainTable@24
         79   4F 00018590 _AXC_GetScaledOutputHPF@20
         80   50 00018600 _AXC_GetScaledOutputHPFTable@24
         81   51 00018430 _AXC_GetScaledOutputLPF@20
         82   52 000184A0 _AXC_GetScaledOutputLPFTable@24
         83   53 00018340 _AXC_GetScaledOutputLPFType@20
         84   54 00018090 _AXC_GetScaledOutputSignal@20
         85   55 00018100 _AXC_GetScaledOutputSignalTable@20
         86   56 00018750 _AXC_GetScaledOutputZeroEnable@20
         87   57 00018860 _AXC_GetScaledOutputZeroLevel@20
         88   58 000188D0 _AXC_GetScaledOutputZeroRange@20
         89   59 000193C0 _AXC_GetScopeMode@12
         90   5A 00014F60 _AXC_GetSerialNumber@16
         91   5B 000189B0 _AXC_GetSignalScaleFactor@16
         92   5C 00015650 _AXC_GetSyncOutput@12
         93   5D 000169C0 _AXC_GetTestSignalAmplitude@20
         94   5E 00016A30 _AXC_GetTestSignalAmplitudeRange@20
         95   5F 000168B0 _AXC_GetTestSignalEnable@20
         96   60 00016B90 _AXC_GetTestSignalFreqRange@24
         97   61 00016B20 _AXC_GetTestSignalFrequency@20
         98   62 00017CD0 _AXC_GetTrackEnable@20
         99   63 00017DE0 _AXC_GetTrackLevel@20
        100   64 00017E50 _AXC_GetTrackLevelRange@20
        101   65 00017F40 _AXC_GetTrackSpeed@20
        102   66 00017FB0 _AXC_GetTrackSpeedTable@24
        103   67 00015050 _AXC_IsDemo@12
        104   68 00014FD0 _AXC_IsDeviceOpen@12
        105   69 00015140 _AXC_IsHeadstagePresent@20
        106   6A 00015500 _AXC_LoadProperties@20
        108   6B 00016C00 _AXC_Pulse@16
        109   6C 00015430 _AXC_Reset@8
        110   6D 00015570 _AXC_SaveProperties@20
        111   6E 00018F50 _AXC_SetAudioEnable@12
        112   6F 00019040 _AXC_SetAudioGain@12
        113   70 00019190 _AXC_SetAudioMode@12
        114   71 00019270 _AXC_SetAudioSignal@20
        115   72 00015CF0 _AXC_SetAutoEnable@16
        116   73 000161D0 _AXC_SetAutoICDelay@20
        117   74 000160F0 _AXC_SetAutoICReturn@16
        118   75 00015DE0 _AXC_SetAutoPolarity@16
        119   76 00015EC0 _AXC_SetAutoSource@16
        120   77 000156C0 _AXC_SetAutoSyncOutput@12
        121   78 00015FA0 _AXC_SetAutoThreshold@20
        122   79 00016320 _AXC_SetAutoVCDelay@20
        123   7A 00017620 _AXC_SetBridgeEnable@20
        124   7B 00017820 _AXC_SetBridgeLevel@24
        125   7C 00017720 _AXC_SetBridgeLock@20
        126   7D 00016FA0 _AXC_SetBuzzDuration@24
        127   7E 000158F0 _AXC_SetCacheEnable@12
        128   7F 00017A00 _AXC_SetCapNeutEnable@20
        129   80 00017B00 _AXC_SetCapNeutLevel@24
        130   81 00015320 _AXC_SetCustomHeadstageValues@32
        131   82 00018E40 _AXC_SetDCRestoreEnable@20
        132   83 000166D0 _AXC_SetExtCmdEnable@20
        133   84 00015960 _AXC_SetHardwareAccessEnable@12
        134   85 00016470 _AXC_SetHoldingEnable@20
        135   86 00016570 _AXC_SetHoldingLevel@24
        136   87 00018B80 _AXC_SetLoopGain@24
        137   88 00018CE0 _AXC_SetLoopLag@24
        138   89 00015B20 _AXC_SetMeterAttenuatorEnable@16
        139   8A 000159D0 _AXC_SetMeterSignal@20
        140   8B 00015C10 _AXC_SetMode@16
        141   8C 000173D0 _AXC_SetOscKillerEnable@20
        142   8D 000174D0 _AXC_SetOscKillerMethod@20
        143   8E 00017270 _AXC_SetPipetteOffset@24
        144   8F 00017170 _AXC_SetPipetteOffsetLock@20
        145   90 00016DD0 _AXC_SetPulseAmplitude@24
        146   91 00016C70 _AXC_SetPulseDuration@24
        147   92 00018A20 _AXC_SetSamplePeriod@24
        148   93 00018170 _AXC_SetScaledOutputGain@24
        149   94 00018510 _AXC_SetScaledOutputHPF@24
        150   95 000183B0 _AXC_SetScaledOutputLPF@24
        151   96 000182D0 _AXC_SetScaledOutputLPFType@20
        152   97 00018020 _AXC_SetScaledOutputSignal@20
        153   98 000186E0 _AXC_SetScaledOutputZeroEnable@20
        154   99 000187E0 _AXC_SetScaledOutputZeroLevel@24
        155   9A 00019350 _AXC_SetScopeMode@12
        156   9B 000155E0 _AXC_SetSyncOutput@12
        157   9C 00016940 _AXC_SetTestSignalAmplitude@24
        158   9D 00016840 _AXC_SetTestSignalEnable@20
        159   9E 00016AA0 _AXC_SetTestSignalFrequency@24
        160   9F 00017C60 _AXC_SetTrackEnable@20
        161   A0 00017D60 _AXC_SetTrackLevel@24
        162   A1 00017EC0 _AXC_SetTrackSpeed@24
        163   A2 00019570 _AXC_WriteFirmware@16
The functions I need are:
LIBRARY Axoclampdriver.dll
EXPORTS
AXC_CheckAPIVersion
AXC_CloseDevice
AXC_CreateHandle
AXC_FindFirstDevice
AXC_OpenDevice
AXC_GetSerialNumber
AXC_GetFirmwareVersion
AXC_GetHeadstageType
AXC_GetScaledOutputGain
AXC_GetScaledOutputHPF
AXC_GetScaledOutputLPF
AXC_GetScaledOutputLPFType
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

Looks like you need only some underscores in the *.def and *.bi file I'm right ?

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

Axoclampdriver.dll depends on AXHIDMANAGER.DLL where is it ?

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

The company shiny3d is pleased to announce that it has solved the problem professionally for you :-)

Creating AxoclampDriver.def and lib/win32/libAxoclampDriver.dll.a 5 minutes
Translating AxoclampDriver.h to AxoclampDriver.bi by hand 25 minutes
Solving the linking problem 30 minutes the solution is tricky.

download: fbAxoclampDriver.zip

If you use it at your business you are free to send me "Johnnie walker Black Edition" via PayPal ;-)

Joshy
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: dll entry point not found

Post by BasicScience »

Almost there, happy to supply Johnnie Walker Black Edition when I can get it to work here.

Here's a link to AxHIDManager.dll. The company didn't provide the .h file :-(
https://sites.google.com/site/freebasic ... ects=0&d=1

I'm still getting a problem with the functions preceded by "_"

For example, this code generates the compiler error "undefined reference to "AXC_GetSerialNumber@16". All the functions without the "_" prefix are working. (FB 1.05.0-win32 running on 64-bit Dell laptop)

Code: Select all

#include once "AxoclampDriver.bi"
DIM hAXC as HAXC
DIM as zstring*8 SerialNum
DIM as uinteger uBufSize = 9
DIM pnError as integer ptr

print AXC_CheckAPIVersion(AXC_APIVERSION_STR)
Print "GetSerialNumber: " & AXC_GetSerialNumber(hAXC, Strptr(SerialNum), uBufSize, pnError)

sleep
I'm also curious the learn why "Extern Windows" is needed for the functions without underscore whereas "Extern Windows-MS" is for the ones with underscore
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: dll entry point not found

Post by D.J.Peters »

BasicScience wrote:Almost there, happy to supply Johnnie Walker Black Edition when I can get it to work here.
Only if you make money in any kind with "my work for you" forget it if you used it only for hobby.
BasicScience wrote:Here's a link to AxHIDManager.dll. The company didn't provide the .h file :-(
I don't need the *.h file AxoclampDriver.dll depends on AxHIDManager.dll you can see it here:
Image
I needed it only to test my hand created *.bi file may be you have to remove AxHIDManager.dll from fbAxoclampDriver folder.
BasicScience wrote:I'm still getting a problem with the functions preceded by "_"
Should be fixed download the zip file again.

The primary problem are they mixed __sdtcall exports with and without name decoration and exported the names for "C" compilers under Linux also.

Linux "C" add an underscore in front of imported names
can be to use the SDK on Windows and Linux with FreeBASIC
you have to add two section in the *.bi file one with name aliases and on section without !

Code: Select all

extern "Windows"

#ifdef __FB_WIN32__
  declare function AXC_GetSerialNumber alias "_AXC_GetSerialNumber" (byval m_hAXC as HAXC, byval pszSerialNum as zstring ptr, byval uBufSize as UINT, byval pnError as long ptr) as BOOL 
  ' ...
#else
  declare function AXC_GetSerialNumber (byval m_hAXC as HAXC, byval pszSerialNum as zstring ptr, byval uBufSize as UINT, byval pnError as long ptr) as BOOL 
  '...
#endif
end extern
By the way you used AXC_GetSerialNumber() in a wrong manner look in file: "test.bas"

You used a NULL pointer for the nError argument and it crashed here !
It must be a "address" to a var to store the bool (long) like this @nError

Joshy
Post Reply