Page 1 of 1

import (PB 5.60) Windows 10

Posted: Thu Sep 07, 2017 6:36 pm
by dobro
the troubles begin :roll:

I generate a DLL "operations_x86.dll" as well as the file "operations_x86.lib"
here is the code of my DLL

Code: Select all


 ; ; ; 
 ;  ; Code "operations.dll "  a compiler en DLL
     ProcedureDLL.i AttachProcess(Instance)
     EndProcedure   
     ; Called when the program release (free) the DLL    ;
     ProcedureDLL.i DetachProcess(Instance)
     EndProcedure   
     ; Both are called when a thread in a program call or release (free) the DLL    ;
     ProcedureDLL.i AttachThread(Instance)
     EndProcedure  
     ProcedureDLL.i DetachThread(Instance)
     EndProcedure
     ; ********************************************
      ProcedureDLL.i A(a,b)
  	 ret=a+b
      		ProcedureReturn ret
      EndProcedure
      ProcedureDLL.i s(a,b)
  	 Ret= a-b
      		ProcedureReturn Ret
      EndProcedure
      ProcedureDLL.i d(a,b)
  	 Ret=a/b
      		ProcedureReturn Ret
      EndProcedure
      ProcedureDLL.i M(a,b)
  	 Ret=a*b
      		ProcedureReturn Ret
      EndProcedure
the 4 basic operations in procedures, nothing very complicated!


then I test with this code:

Code: Select all


    ; 
     ; 
      Import "operations_x86.lib"
      		a(a,b)
      		s(a,b)
      		d(a,b)
      		M(a,b)
      EndImport 
      
   
   
    ;   Utilisation
   debug a(5,8)
   debug S(8,2)
   debug d(10,8)
   debug M(5,8)


it does not work ! Any ideas ??

the import of the file Lib beside its DLL, must work, out, it does not work ...
contrary to what the Doc says .

Is there a special writing to respect ?? :shock:

Re: import (PB 5.60) Windows 10

Posted: Thu Sep 07, 2017 7:00 pm
by fryquez
Dll Exports/Imports are case sensitive.

Import "operations_x86.lib"
A(a,b)
s(a,b)
d(a,b)
M(a,b)
EndImport

Re: import (PB 5.60) Windows 10

Posted: Thu Sep 07, 2017 7:17 pm
by dobro
Thank you I corrected the Case sensitive , But

but it does not work better because in fact the code does not even launch
I have a POLINK error
Error: LinkerPOLINK: error: Unresolved external symbol 'a'.
POLINK: error: Unresolved external symbol' .
.....
.....
fatal error : 4 unresolved external (s).

Re: import (PB 5.60) Windows 10 (Resolved )

Posted: Thu Sep 07, 2017 7:22 pm
by dobro
ok , resolved,
I was wrong compiler :lol:

Thanks

Re: import (PB 5.60) Windows 10

Posted: Thu Sep 07, 2017 7:24 pm
by fryquez
Have you choose the same compiler for dll and for exe?
If so what version are you using?

Re: import (PB 5.60) Windows 10

Posted: Sat Sep 09, 2017 1:41 pm
by dobro
avec le compilateur et le Flag "/Import"+chr(34)+name_file.s+chr(34)
je genere un fichier d'importation ..... . ( a partir d'un fichier PB source d'une DLL )


mais, ou dois t'on le mettre, pour qu'il soit reconnu par PB ??
comment dois t'on s'y prendre, pour s'en servir ?

la doc dit :
-i, --import, /IMPORT "Fichier": crée un fichier d'importation au nom de fichier donné. Seulement un seul bloc Import/EndImport autorisé dans le fichier. Les fonctions importées seront chargées automatiquement pour tous les projets de PureBasic.
comment faire pour que mes projets puissent se servir de ce fichier d'import ?

***********************************************************************************************************************
Google translate :


with PBcompiler and Flag "/Import"+chr(34)+name_file.s+chr(34)
I generate an import file ..... (from a source PB file of a DLL)

but, or should you put it, so that it is recognized by PB ??
how should we go about it, to use it?

the doc says:
-i, --import, / IMPORT "File": creates an import file for the given file name. Only one import / endImport block allowed in the file. The imported functions will be loaded automatically for all PureBasic projects.
how to make my projects use this import file?

Re: import (PB 5.60) Windows 10

Posted: Sun Sep 10, 2017 8:24 am
by dobro
Nobody knows ?

Re: import (PB 5.60) Windows 10

Posted: Sun Sep 10, 2017 1:55 pm
by chi
dobro wrote:the doc says:
-i, --import, / IMPORT "File": creates an import file for the given file name. Only one import / endImport block allowed in the file. The imported functions will be loaded automatically for all PureBasic projects.
how to make my projects use this import file?
This is what I use to create import files for missing API functions... Just adapt to your own DLL ;)

(Run from IDE and restart afterwards)

Code: Select all

CompilerSelect 0
    
  CompilerCase 0
    FileName$ = "chi_gdi32.imp"
    Import "gdi32.lib"
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        SetLayout_(hdc,dwLayout) As "_SetLayout@8"
        GetLayout_(hdc) As "_GetLayout@4"
        GdiAlphaBlend_(hdcDest,nXOriginDest,nYOriginDest,nWDest,nHDest,hdcSrc,nXOriginSrc,nYOriginSrc,nWSrc,nHSrc,Blendfunction) As "_GdiAlphaBlend@44"
        GdiTransparentBlt_(hdcDest,nXOriginDest,nYOriginDest,nWDest,nHDest,hdcSrc,nXOriginSrc,nYOriginSrc,nWSrc,nHSrc,Blendfunction) As "_GdiTransparentBlt@44"
      CompilerElse
        SetLayout_(hdc, dwLayout) As "SetLayout"
        GetLayout_(hdc) As "GetLayout"
        GdiAlphaBlend_(hdcDest,nXOriginDest,nYOriginDest,nWDest,nHDest,hdcSrc,nXOriginSrc,nYOriginSrc,nWSrc,nHSrc,Blendfunction) As "GdiAlphaBlend"
        GdiTransparentBlt_(hdcDest,nXOriginDest,nYOriginDest,nWDest,nHDest,hdcSrc,nXOriginSrc,nYOriginSrc,nWSrc,nHSrc,Blendfunction) As "GdiTransparentBlt"
      CompilerEndIf
    EndImport
    
  CompilerCase 1
    FileName$ = "chi_user32.imp"
    Import "user32.lib"
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        DisableProcessWindowsGhosting_() As "_DisableProcessWindowsGhosting@0"
        PrintWindow_(hwnd, hdcBlt, nFlags) As "_PrintWindow@12"
        UpdateLayeredWindowIndirect_(hWnd, *pULWInfo) As "_UpdateLayeredWindowIndirect@8"        
      CompilerElse
        DisableProcessWindowsGhosting_() As "DisableProcessWindowsGhosting"
        PrintWindow_(hwnd, hdcBlt, nFlags) As "PrintWindow"
        UpdateLayeredWindowIndirect_(hWnd, *pULWInfo) As "UpdateLayeredWindowIndirect"
      CompilerEndIf
    EndImport

  CompilerCase 2
    FileName$ = "chi_comctl32.imp"
    Import "comctl32.lib"
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        GetWindowSubclass_(hWnd, pfnSubclass, uIdSubclass, *outRefData) As "_GetWindowSubclass@16"
        SetWindowSubclass_(hWnd, pfnSubclass, uIdSubclass, inRefData) As "_SetWindowSubclass@16"
        RemoveWindowSubclass_(hWnd, pfnSubclass, uIdSubclass) As "_RemoveWindowSubclass@12"
        DefSubclassProc_(hWnd, uMsg, wParam, lParam) As "_DefSubclassProc@16"
      CompilerElse
        GetWindowSubclass_(hWnd, pfnSubclass, uIdSubclass, *outRefData) As "GetWindowSubclass"
        SetWindowSubclass_(hWnd, pfnSubclass, uIdSubclass, inRefData) As "SetWindowSubclass"
        RemoveWindowSubclass_(hWnd, pfnSubclass, uIdSubclass) As "RemoveWindowSubclass"
        DefSubclassProc_(hWnd, uMsg, wParam, lParam) As "DefSubclassProc"
      CompilerEndIf
    EndImport
    
CompilerEndSelect

Compiler = RunProgram(#PB_Compiler_Home + "Compilers\pbcompiler", #PB_Compiler_FilePath + #PB_Compiler_Filename + " --Import " + FileName$, "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
If Compiler
  While ProgramRunning(Compiler)
    If AvailableProgramOutput(Compiler)
      Output$ + ReadProgramString(Compiler) + Chr(13)
    EndIf
  Wend
  CloseProgram(Compiler)
EndIf
LibFile$ = #PB_Compiler_Home + "PureLibraries\Windows\" + FileName$
If CopyFile(FileName$, LibFile$)
  DeleteFile(FileName$)
EndIf
MessageRequester(FileName$, Output$ + Chr(13) + Chr(10) + "File '" + FileName$ + "' moved to " + LibFile$)

Re: import (PB 5.60) Windows 10

Posted: Sun Sep 10, 2017 6:19 pm
by dobro
Excellent ! Thanks :)