Polink error with personnal user asm lib x86 Backend_C only

Post bugreports for the Windows version here
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Polink error with personnal user asm lib x86 Backend_C only

Post 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
Image

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 ?
A+
Denis
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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.
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: Polink error with personnal user asm lib x86 Backend_C only

Post by Denis »

Ok Fred, i will try .

Tks
A+
Denis
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 223
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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")
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 223
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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")
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Polink error with personnal user asm lib x86 Backend_C only

Post by User_Russian »

User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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...
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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).
A+
Denis
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: Polink error with personnal user asm lib x86 Backend_C only

Post by Denis »

I let it down (no answer) ...
I'll see if I kept the lib.
A+
Denis
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: Polink error with personnal user asm lib x86 Backend_C only

Post 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
Image

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)
A+
Denis
Post Reply