import (PB 5.60) Windows 10

Just starting out? Need help? Post your questions and find answers here.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

import (PB 5.60) Windows 10

Post 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:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: import (PB 5.60) Windows 10

Post 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
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: import (PB 5.60) Windows 10

Post 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).
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

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

Post by dobro »

ok , resolved,
I was wrong compiler :lol:

Thanks
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: import (PB 5.60) Windows 10

Post by fryquez »

Have you choose the same compiler for dll and for exe?
If so what version are you using?
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: import (PB 5.60) Windows 10

Post 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?
Last edited by dobro on Sun Sep 10, 2017 8:25 am, edited 1 time in total.
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: import (PB 5.60) Windows 10

Post by dobro »

Nobody knows ?
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: import (PB 5.60) Windows 10

Post 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$)
Et cetera is my worst enemy
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: import (PB 5.60) Windows 10

Post by dobro »

Excellent ! Thanks :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Post Reply