undefined symbol: strnicmp

Just starting out? Need help? Post your questions and find answers here.
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

undefined symbol: strnicmp

Post by Quin »

I'm trying to link against a library built with Visual Studio 2022 in my PB app. I had to import a couple libraries like ole32 and version.lib, but the only import I can't figure out is strnicmp. According to microsoft, this is an old and not supported alias to _strnicmp. I tried:

Code: Select all

	Import "ucrt.lib"
strnicmp(String1$, String2$, Count)
EndImport
and many other variations, including trying to import the underscore version as the non-underscore name, but none of them fixed it. Has anyone successfully done this?
Thanks.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: undefined symbol: strnicmp

Post by infratec »

This works in PB 6.11 x86 on Windows 10 x64

Code: Select all

ImportC "oldnames.lib"
  strnicmp.i(String1.p-Ascii, String2.p-Ascii, Count)
EndImport


Debug strnicmp("abcx213e12", "ABCY9789", 2)
Debug strnicmp("abcx213e12", "ABCY9789", 5)
Debug strnicmp("bbcx213e12", "ABCY9789", 1)
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: undefined symbol: strnicmp

Post by Quin »

Infratec,
This worked perfectly, thanks for the help!
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: undefined symbol: strnicmp

Post by Fred »

It should work without oldnames:

Code: Select all

ImportC "ucrt.lib"
  CompilerIf #PB_Compiler_32Bit
    strnicmp(String1.p-utf8, String2.p-utf8, Count) As "__strnicmp"
  CompilerElse
    strnicmp(String1.p-utf8, String2.p-utf8, Count) As "_strnicmp"
  CompilerEndIf
EndImport


Debug strnicmp("abcx213e12", "ABCY9789", 2)
Debug strnicmp("abcx213e12", "ABCY9789", 5)
Debug strnicmp("bbcx213e12", "ABCY9789", 1)
Note: why not using _strnicmp directly (if it's only a name issue, you can use a macro to map it) ?

Code: Select all

ImportC "ucrt.lib"
  _strnicmp(String1.p-utf8, String2.p-utf8, Count)
EndImport

Macro strnicmp(a,b,c) : _strnicmp(a,b,c) : EndMacro


Debug strnicmp("abcx213e12", "ABCY9789", 2)
Debug strnicmp("abcx213e12", "ABCY9789", 5)
Debug strnicmp("bbcx213e12", "ABCY9789", 1)
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: undefined symbol: strnicmp

Post by Quin »

@Fred, ucrt.lib with a Macro works perfectly. Thanks so much!
Post Reply