Converting FString to integer, KismetStringLibrary linker compile error

Dear Friends at Epic,

I am trying to utilize:

KismetStringLibrary.h which is in EngineClasses.h

   FString TheFString = "232.122";
    int32 MyFancyNewInt32 = UKismetStringLibrary::Conv_StringToInt(TheFString);

When I try to use it I get a compile error:

I tried including several different headers:

#include "EngineClasses.h"
#include "EngineKismetLibraryClasses.h"
#include "KismetStringLibrary.h"

But I still get this linker error:

1>Module.VictoryGame.cpp.obj : error LNK2019: unresolved external symbol "public: static int __cdecl UKismetStringLibrary::Conv_StringToInt(class FString const &)" (?Conv_StringToInt@UKismetStringLibrary@@SAHAEBVFString@@@Z) referenced in function "public: void __cdecl USagResponse::ParseServerArray(class TArray &)" (?ParseServerArray@USagResponse@@QEAAXAEAV?$TArray@UFServer@@VFDefaultAllocator@@@@@Z)
1>E:\RocketVictory\VictoryGame\Binaries\Win64\RocketEditor-VictoryGame.dll : fatal error LNK1120: 1 unresolved externals 

Any ideas?


Is there an easier to access function to convert a FString to an int32 ?


Thanks so much!

Rama

As was discussed here https://rocket.unrealengine.com/questions/6239/access-kismetmathlibrary.html, the Kismet libraries are not intended for general C++ use. They are generally wrappers around basic engine functionality so as to be accessible using blueprints.

Most of the functions in there simply wrap basic FString of FCString functionality and you should be using that directly. In your specific case FCString::Atoi(*InString)

I highly recommend that you use these classes rather than something like _tstoi because we will ensure that it is correct for all platforms.

Woohooo!

Thanks again Marc!

FCString is what I was looking for!

:heart:

Rama

Here’s the workaround I wrote for now

would still like to not have the kismet library throw linker errors, will be wanting to use other things from that library!

int32 YourClass::ConvertStringToInteger(FString &TheStr)
{
	return _tstoi( * TheStr);
}