how add steam api to C++ project?

while digging around i tryed some tricks:



void USteam_Functions::UE_RequestLobbyList()
{
	SteamAPICall_t hSteamAPICall = 1;
}


this code compiles fine, but!



void USteam_Functions::UE_RequestLobbyList()
{
	SteamAPICall_t hSteamAPICall = 1;//SteamMatchmaking()->RequestLobbyList();
	SteamMatchmaking();
}


this one won’t with same error and it lead to SteamMatchmaking, seems like VS can’t find where’s function body of SteamMatchmaking, but steam_api.lib path already added, but i have to note it’s not the like link lib files normally, it’s only path added in includes, because “linker” folder doesn’t exist in “project properties” for any unknow reason (while in normal win32 app it exist)

still diggin, tryed another steam function



void USteam_Functions::UE_RequestLobbyList()
{
	SteamAPI_SetMiniDumpComment("Minidump comment: SteamworksExample.exe
");
}


and it failed with same error, vs don’t have idea where it referencing, while it can find only definition

interesting , man told

If you project is a library, there is no “linker” tab so you need to navigate as such: Myproject –>properties –> Librarian –> additional dependencies and add the dll or lib

do you have any idea where is it

Myproject –>properties –> Librarian –> additional dependencies???

exactly “Librarian”, i don’t have such option

on | Microsoft Learn i found interesting note about Linking Implicitly, it says

The classes, functions, and data should all have __declspec(dllimport), for more information

can it be the problem in our case? because we have to link lib file to dll solution and not executable

but seems



__declspec(dllimport) void SteamAPI_SetMiniDumpComment();

void USteam_Functions::UE_RequestLobbyList()
{
	SteamAPI_SetMiniDumpComment("Minidump comment: SteamworksExample.exe
");
}


makes no difference, still same error with unresolved external symbol

p.s. added .lib files and .dll to solution, no changes, same error

So, I got this working in my own project following the steps laid out in Epic’s wiki but there certainly seems to be some weird behavior. The Steam Libs/DLLs always fail to load when launched from the editor (whether simply hitting Play or actually telling it to launch an instance of the game). It’s only if I launched my game from within Visual Studio (I just added “-game” to my command line arguments and ran the project with F5) that the libraries loaded correctly and the steam interface comes up normally.

I haven’t sync’d down the engine/editor to build in debug and find out what is going on, but you may want to give just launching from VS a shot. There may be a bug here for the Epic guys to look at.

can you share your project? so i can try compare it or try compile mine https://yadi.sk/d/l_yn3IwBgRVs2, because maybe you miss “build” steap in VS while your custom function refer to any steam API function and that’s why you didn’t had building errors, as i told i have no problem with bringing up steam overlay after packaging, but my custom functions refering steam API functions won’t compile in VS, not in EDITOR :slight_smile:

Unfortunately I can’t share my project. :frowning: If you tried to manually add the includes to your project and that failed then I’m out of ideas. :confused:

no, include don’t fail and #include “steam_api.h” work fine, only after that VS understand where SteamAPI_SetMiniDumpComment method defined, but after definition VS can’t find method body, because it buried inside steam_api.lib (VS can’t find it after adding library path to steam_api.lib in project properties and there’s no linker folder to add it like to executable )

i already sent a request to epic’s support, hope they send some programmer staff to look at this !@#$% :frowning:

seems i miss

/YourUnrealEnginePath/Engine/Source/ThirdParty/Steamworks/Steamv130/sdk

and now added sdk folder here, but it didn’t fix the problem with unresolved external symbol, so i still have no idea what wrong :frowning:

i also found that packaging doesn’t work with



#include "steam_api.h"


or



#include <steam_api.h>


or

adding steam_api.h into solution files

UnrealBuildTool.txt says:



Parsing headers for steam_training
Reflection code generated for steam_training
Performing 9 actions (4 in parallel)
[3/9] Resource steam_training.rc
PCH.UELinkerFixups.UELinkerFixupsName.h.cpp
PCH.steam_training.steam_training.h.cpp
UELinkerFixups.cpp
steam_training.generated.cpp
Steam_Functions.cpp
empty.cpp
D:\ue4\projects\4.7.6\steam_training\Source\steam_training\Steam_Functions.cpp(7) : fatal error C1083: Cannot open include file: 'steam_api.h': No such file or directory
steam_training.cpp
-------- End Detailed Actions Stats -----------------------------------------------------------
ERROR: UBT ERROR: Failed to produce item: D:\ue4\projects\4.7.6\steam_training\Binaries\Win64\steam_training.exe
Cumulative action seconds (4 processors): 0,00 building projects, 28,70 compiling, 0,00 creating app bundles, 0,00 generating debug info, 0,00 linking, 0,00 other
UBT execution time: 37,21 seconds


after few tryes packaging with included steam_api.h worked fine, don’t sure what caused it, but error with unresolved external symbol still here :frowning:

checked with process monitor from begin build to error



Error	5	error LNK2019: unresolved external symbol __imp_SteamAPI_SetMiniDumpComment referenced in function "private: void __cdecl USteam_Functions::UE_RequestLobbyList(void)" (?UE_RequestLobbyList@USteam_Functions@@AEAAXXZ)	D:\ue4\projects\4.7.6\steam_training\Intermediate\ProjectFiles\Steam_Functions.cpp.obj	steam_training


there’s no accesses to file steam_api.lib, but tons of other libs, how the hell can i force VS use steam_api.lib to get access to its functions?

also tryed this way:

added steam_api.h to solution and lib files too and put

#pragma import steam_api.lib

in begin of steam_api.h, still same error unresolved external symbol

also i found why “linker/librarian” doesn’t exist in project properties, it’s because in general properties project type set to “makefile”

i found what makefile project type is, it’s all configured now by one property folder Nmake

in this case i really confused how link steam_api.lib

image for example Nmake_makefile_type.png — Yandex Disk

any ideas?

found solution, it’s a

#pragma comment(lib, “steam_api64.lib”)

note that i setted path to lib file separatly in project setting, but you can use full path with double slashes like “C:\any folder\your.lib”

now VS project compiles fine

also little note for those who can have problem calling your methods not related to any objects, after “begin play” for example call your method and in “target” provide just empty variable (right click on PIN, promote to variable), but to do it your method should be based on Actor