POLINK error with pcre & PB4.61

Just starting out? Need help? Post your questions and find answers here.
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

POLINK error with pcre & PB4.61

Post by Perkin »

I'm sure I'm being a numpty and missing something obvious, I've checked a lot of search results but haven't seen a solution.

I've just compiled one of my projects with the new 4.61, (also b4 errors as well), and have this error crop up.

Code: Select all

POLINK: error: Unresolved external symbol '_pcre_exec'.
POLINK: fatal error: 1 unresolved external(s).
Now compiling with 4.60 worked, and I think (but can't be sure) that 4.61b3 worked as well.

this code below (an example from another topic) shows the problem.

Any help or suggestions on how to fix?

Code: Select all

;{ LIB code
ImportC ""
   pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize)
EndImport

Structure List_Extraction
   Array Extract.s(0)
EndStructure


Procedure.s BackrefReplaceRegularExpression(regexp_handle, string.s, replacement.s, maximum_reference.l = 10) ; 0 <= maximum_reference <= 99
   Static Dim pcre_results.l(202)
   
   depart = 0
   Repeat
      res.l = pcre_exec(PeekI(regexp_handle), 0, string, Len(string), depart, 0, @pcre_results(), 202)
      If res > 0
         
         rpl.s = replacement
         
         p = pcre_results(0)
         q = pcre_results(1)
         If FindString(replacement,"$0", 1)
            rpl = ReplaceString(rpl, "$0", PeekS(@string + p, q - p))
            
         EndIf
         
         tableau_ref = 2
         
         For _a = 1 To maximum_reference
            tag$ = "$" + Str(_a)
            
            If FindString(replacement, tag$, 1)
               p1 = pcre_results(tableau_ref)
               q1 = pcre_results(tableau_ref + 1)
               rpl = ReplaceString(rpl, tag$, PeekS(@string + p1, q1 - p1))
               
            EndIf
            
            tableau_ref + 2
         Next
         
         depart = p + Len(rpl)
         
         string = Left(string, p) + rpl + Right(string, Len(string) - q)
      EndIf
   Until res = -1
   
   ProcedureReturn string
EndProcedure

Procedure.s BackrefExtractRegularExpression(regexp_handle, string.s, Array Extract.b(1), List Resultat.List_Extraction()) ; 0 <= Taille tableau Extract <= 99
   Static Dim pcre_results.l(202)
   
   depart = 0
   
   maximum_reference = ArraySize(Extract())
   
   ClearList(Resultat())
   
   Repeat
      res.l = pcre_exec(PeekI(regexp_handle), 0, string, Len(string), depart, 0, @pcre_results(), 202)
      If res > 0
         ; pcre_exec(PeekL(regexp_handle), 0, string, Len(string), pcre_results(1), 0, @pcre_results(), 202)
         
         AddElement(Resultat())
         Dim Resultat()\Extract(maximum_reference)
         
         p = pcre_results(0)
         q = pcre_results(1)
         If Extract(0) = #True
            Resultat()\Extract(0) = PeekS(@string + p, q - p)
         EndIf
         
         tableau_ref = 2
         
         For _a = 1 To maximum_reference
            
            If Extract(_a) = #True
               p1 = pcre_results(tableau_ref)
               q1 = pcre_results(tableau_ref + 1)
               
               Resultat()\Extract(_a) = PeekS(@string + p1, q1 - p1)
            EndIf
            
            tableau_ref + 2
         Next
         
         depart = p ; + Len(rpl)
         
         ;   string = Left(string, p) + rpl + Right(string, Len(string) - q)
         string = Left(string, p) + Right(string, Len(string) - q)
      EndIf
   Until res =-1
   
   ProcedureReturn string
EndProcedure

;}

REGEX$ = " t(.*?)e(.*?) "

CHAINE$ = "As they functions tried importing them through the tset "

; regular expression creation
rh = CreateRegularExpression(0, REGEX$)


Debug "#### Recurrent Replacement test :"
Debug ""
Debug "Starting text :"
Debug CHAINE$
Debug "Regex = ||" + REGEX$ + "||"
Debug ""
Debug "Result :"
Debug BackrefReplaceRegularExpression(rh, CHAINE$, "________$0")


; creation of the array specifying which parenthesis must be returned
Dim tableau_extraction.b(2)

; we want all parenthesis so we complete the array all the way
For a = 0 To 2
   tableau_extraction(a) = #True
Next


; creation of the list returning the result
NewList Result.List_Extraction()


; processing
BackrefExtractRegularExpression(rh, CHAINE$, tableau_extraction(), Result())

Debug ""
Debug ""
Debug "#### Recurrent extraction test :"
Debug ""
Debug "Starting text :"
Debug CHAINE$
Debug "Regex = ||" + REGEX$ + "||"
Debug ""
Debug "Extracted values :"
Debug ""

b = 0
ForEach Result()
   Debug "Occurrence " + Str(b)
   
   For a = 0 To 2
      Debug "$" + Str(a) + " = " + Result()\Extract(a)
   Next
   
   b + 1
Next
%101010 = $2A = 42
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: POLINK error with pcre & PB4.61

Post by gnozal »

Try

Code: Select all

ImportC ""
  pb_pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize)
EndImport
It seems that all PCRE functions now have a 'pb_' prefix.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: POLINK error with pcre & PB4.61

Post by ts-soft »

or use:

Code: Select all

Macro pcre_exec
  pb_pcre_exec
EndMacro

ImportC ""
   pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize)
EndImport
so no more other changes required :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: POLINK error with pcre & PB4.61

Post by skywalk »

Macros are fine for small functions or well established code, but I cannot suffer losing Context Help... :(
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: POLINK error with pcre & PB4.61

Post by Perkin »

Many thanks.
You've saved the last of my barnet' follicles from being yanked ;)

Wonder why the prefix was added?
%101010 = $2A = 42
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: POLINK error with pcre & PB4.61

Post by ts-soft »

skywalk wrote:Macros are fine for small functions or well established code, but I cannot suffer losing Context Help... :(
Okay, here another solution without Macro :wink:

Code: Select all

ImportC ""
   CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
      pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "pb_pcre_exec"
   CompilerElse
      pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "_pb_pcre_exec"
   CompilerEndIf
EndImport
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: POLINK error with pcre & PB4.61

Post by skywalk »

ts-soft wrote:
skywalk wrote:Macros are fine for small functions or well established code, but I cannot suffer losing Context Help... :(
Okay, here another solution without Macro :wink:

Code: Select all

ImportC ""
   CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
      pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "pb_pcre_exec"
   CompilerElse
      pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "_pb_pcre_exec"
   CompilerEndIf
EndImport
That is preferred to me.
I use 'As' to create a unique 'prefix+fn_name' for common imported functions, but I noticed I have to add case-sensitive decorations to the 'As' portion for other libs like zlib?

Code: Select all

zl_uncompress(*mTo.i, *lenTo.i, *mFrom.i, lenFrom.i)                           As "_uncompress@16"
pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "_pb_pcre_exec@32"
Is that not required for pcre?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: POLINK error with pcre & PB4.61

Post by ts-soft »

skywalk wrote: Is that not required for pcre?
No, the 32-Bit version of pcre uses CDECL and not StdCall decorations!
CDECL without decoration but with underscore in front
FASTCALL (64-Bit) the same without underscore
StdCall requires underscore and @... decorations (allways 32-Bit)

Exceptions to the rule are the rule :mrgreen:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: POLINK error with pcre & PB4.61

Post by ts-soft »

Perkin wrote:Wonder why the prefix was added?
All to pb exported functions in a lib have the "hidden" prefix PB_, but this function not exported to PB so i think it is
a small mistake

More Info's to libs find you with PBLIBTool: http://www.realsource.de/index.php/down ... or-pb-libs
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Re: POLINK error with pcre & PB4.61

Post by Perkin »

ts-soft wrote:Okay, here another solution without Macro :wink:

Code: Select all

ImportC ""
   CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
      pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "pb_pcre_exec"
   CompilerElse
      pcre_exec(*pcre,*extra,subject.s,length,startoffset,options,*ovector,ovecsize) As "_pb_pcre_exec"
   CompilerEndIf
EndImport
I'm going to go with this way - seems the better/neater option.

Thanks to all.
%101010 = $2A = 42
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: POLINK error with pcre & PB4.61

Post by skywalk »

Thanks ts-soft for the explanation and lib browsers! 8)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply