Page 1 of 1
Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Oct 08, 2021 8:55 am
by Denis
Fred, as you tell me, asm lib are compatible with C backend.
With all my asm libs i use, i get an Polink error only with x86 Backend_C.
All is Ok with other x86 versions (Ok with 6.00 alpha 5 asm backend)
All is Ok with all x64 versions (no decoration)
all functions are declared in descriptor file as StdCall in accordance with your answer
here
for example the error reported above, asm file + desc file:
Code: Select all
format MS COFF
public PB_Fonction_1
;--------------------------------------------------------------------------------
; paramètre de la fonction
;--------------------------------------------------------------------------------
; valeur (Integer)
valeur equ esp+4
;--------------------------------------------------------------------------------
; section code
;--------------------------------------------------------------------------------
section '.text' code readable executable
PB_Fonction_1:
MOV edx, [valeur]
LEA eax, [edx*2]
RET 4
; Langage utilisé pour coder la librairie ASM ou C
ASM
; Nombre de Dll windows utilisées par la lib
0
; Type de librairie
LIB
; Nombre de librairie PureBasic/Utilisateur utilisé par la librairie
0
; Nom du fichier d'aide de la libraire
Essai.chm
; Enumération des fonctions créées
Fonction_1, Long, (valeur.i) - Retourne la valeur passée en paramètre x 2
Long | StdCall
Is it a real bug or may I something wrong ?
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Oct 08, 2021 9:08 am
by Fred
Hello Denis,
C backend only support StdCall and for Windows x86 StdCall requiers the decoration. So you need to call your symbol like this:
'PB_Fonction_1@4' or '_PB_Fonction_1@4' I can't remember.
And put 'C' instead of 'ASM' in the lib desc and it should work.
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Oct 08, 2021 10:13 am
by Denis
Ok Fred, i will try .
Tks
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Sun Oct 10, 2021 2:41 am
by DeanH
Netmaestro suggested I report this error here. With PB6 Alpha 5 ,it generates
POLINK: error. Unresolved external symbol '_PB_Blue@4',
POLINK: error. Unresolved external symbol '_PB_Green@4',
POLINK: error. Unresolved external symbol '_PB_Red@4',
POLINK: error. Unresolved external symbol '_PB_RGB@12',
errors only with the 32-bit C backend x86 compiler. No errors for the 32-bit asm or either 64-bit compilers.
Code: Select all
Procedure$ GETRGB(COL)
Protected R,G,B
R=Red(COL)
G=Green(COL)
B=Blue(COL)
RESULT$=Str(R)+","+Str(G)+","+Str(B)
ProcedureReturn RESULT$
EndProcedure
Procedure.i GETCOLFROMRGB(A$)
R=Val(StringField(A$,1,","))
G=Val(StringField(A$,2,","))
B=Val(StringField(A$,3,","))
RESULT=RGB(R,G,B)
ProcedureReturn RESULT
EndProcedure
Debug RGB(164,0,0)
Debug GetRGB(255)
Debug GetColfromRGB("255,0,0")
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Sun Oct 10, 2021 10:11 am
by User_Russian
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Sun Oct 10, 2021 10:12 am
by jacdelad
Red/Green/Blue/RGB produce an error with the x86 C-Compiler. This has already been reported and seems to be a specific problem with these functions (and is already solved in the upcoming Alpha 6/Beta 1, see the specific thread).
Edit: User_Russian was a blink of an eye faster...
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Wed Oct 13, 2021 5:51 am
by Denis
Hope this new version will also solve the problem i reported here with asm lib.
for now i wasn't able to get it work (I've tried many different ways to code desc file).
If the final version of the library should be different in asm and C, this will cause a problem with the compiler because the user library folder is shared (it will certainly indicate a duplicate function).
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Thu Feb 16, 2023 6:09 pm
by Fred
Could you share your library code which doesn't work ? You need to put C in the .Desc as well instead of ASM
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Feb 17, 2023 6:34 am
by Denis
I let it down (no answer) ...
I'll see if I kept the lib.
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Feb 24, 2023 4:08 pm
by Denis
Fred,
I done little tests with this :
ASM file
Code: Select all
;******** Fonction_1___x86.asm ************************************************
format MS COFF
public PB_Fonction_1
; valeur (Integer) -- > parameter
valeur equ esp+4
section '.text' code readable executable
PB_Fonction_1:
MOV edx, [valeur]
LEA eax, [edx*2]
.EndFunction:
RET 4
Desc file
Code: Select all
; Langage utilisé pour coder la librairie ASM ou C
ASM
; Nombre de Dll windows utilisées par la lib
0
; Type de librairie
LIB
; Nombre de librairie PureBasic/Utilisateur utilisé par la librairie
0
; Nom du fichier d'aide de notre libraire
Essai_2.chm
; fonction créée
Fonction_1, Long, (valeur.i) - Essai pour le bug
None | StdCall | Unicode
Pb file test
Code: Select all
Global a = -126
MessageRequester("", Str(Fonction_1(a)))
PB 6.00 LTS (x86) et
PB 6.01 b4 (x86) Asm Backend
It compile with no erreur and result is Ok
With same files (lib files)
PB 6.01 b4 (x86) C Backend[/u]
I've restarted compiler I get this
Now i only change in desc file ASM by C and recompile to get files
Essai_2___x86 and Essai_2___x86.lib
Restart C backend compiler and try to compile exemple
I still get the same error
Now (always with desc file with C), i change asm file decorations
So public PB_Fonction_1 become _public PB_Fonction_1
PB_Fonction_1: become _PB_Fonction_1:
The same error with ASM or C backend (I restarted the compiler each time)
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Mon Mar 24, 2025 3:53 pm
by Fred
Here is a working example
Asm file (compile with fasm):
Code: Select all
;******** Fonction_1___x86.asm ************************************************
format MS COFF
public _PB_Fonction_1@4
; valeur (Integer) -- > parameter
valeur equ esp+4
section '.text' code readable executable
_PB_Fonction_1@4:
MOV edx, [valeur]
LEA eax, [edx*2]
.EndFunction:
RET 4
Desc file
Code: Select all
; Langage utilisé pour coder la librairie ASM ou C
C
; Nombre de Dll windows utilisées par la lib
0
; Type de librairie
LIB
; Nombre de librairie PureBasic/Utilisateur utilisé par la librairie
0
; Nom du fichier d'aide de notre libraire
Essai_2.chm
; fonction créée
Fonction_1, Long, (valeur.i) - Essai pour le bug
None | StdCall | Unicode
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Apr 04, 2025 8:21 am
by Denis
Salut Fred,
Now with fonction decoration (asm fonction) it's Ok with x86 ASM/C backend.
With desc file, I had to delete the "
| Unicode" for the function return, otherwise I'd get an error (UNICODE is not a valide result).
I've written a second function for testing with the FASM synthaxis (predefined FASM macro) and it works too.
Second function :
Code: Select all
; Fonction_2(valeur.i)
; Fasm x86
format MS COFF
; Include files
include 'G:\PureBasic\Projets\Denis\Fasmw17332\INCLUDE\Win32a.inc'
include 'G:\PureBasic\Projets\Denis\Fasmw17332\INCLUDE\MACRO\IF.inc'
include '..\..\Constantes_PureBasic_x86.inc'
public _PB_Fonction_2@4
section '.text' code readable executable
proc _PB_Fonction_2@4 , valeur:DWORD
MOV edx, [valeur]
LEA eax, [edx*2]
.EndFunction:
ret
endp
corrected desc file:
Code: Select all
; Langage utilisé pour coder la librairie ASM ou C
C
; Nombre de Dll windows utilisées par la lib
0
; Type de librairie
LIB
; Nombre de librairies PureBasic/Utilisateur utilisé par la librairie
0
; Nom du fichier d'aide de la libraire
Fred_ASM_C.chm
; Enumération des 2 fonctions créées
Fonction_1, Long, ( valeur.i ) - Essai 04 avril 2025
Long | StdCall
Fonction_2, Long, ( valeur.i ) - Essai 04 avril 2025
Long | StdCall
Re: Polink error with personnal user asm lib x86 Backend_C only
Posted: Fri Apr 04, 2025 8:24 am
by Fred
Glad it works for you too !