Polink error with personnal user asm lib x86 Backend_C only

Post bugreports for the Windows version here
Denis
Enthusiast
Enthusiast
Posts: 578
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: 14413
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: 578
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
DeanH
Enthusiast
Enthusiast
Posts: 116
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")
DeanH
Enthusiast
Enthusiast
Posts: 116
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: 1215
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
Enthusiast
Enthusiast
Posts: 154
Joined: Wed Feb 03, 2021 12:46 pm
Location: 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...
Denis
Enthusiast
Enthusiast
Posts: 578
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
Post Reply