Mac Steamworks wrapper

BlitzMax Forums/BlitzMax Programming/Mac Steamworks wrapper

jkrankie(Posted 2012) [#1]
Hi,

I seem to remember reading there was a mac steamworks wrapper? is this the case? if so, who wrote it? I'd like to get in touch with them pretty soon!

Cheers
Charlie


Kryzon(Posted 2012) [#2]
- Skidracer: http://blitzbasic.com/Community/posts.php?topic=84183

- I think Hujiklo hired Brucey to write a custom steamworks wrapper for his game, so go talk to Brucey as well.

Last edited 2012


jkrankie(Posted 2012) [#3]
I've got skids wrapper, but it's windows only.

I'll send Brucey an email and see what he says.

Cheers
Charlie


skidracer(Posted 2012) [#4]
Hi Charlie,

Sorry about failing to reply again to your emails.

I have done some testing with steamstub on osx:

Unlike windows the C++ stub should be able to be embedded directly in BlitzMax, so you won't need to ship extra glue dll.

I'm not sure about the particulars linking to the steam dylib am testing now...

steamtest.bmx



steamstub.cpp (latest?)



Last edited 2012

Last edited 2012


jkrankie(Posted 2012) [#5]
Oooh! Thanks! I'll take a look at this in the morning :)

Cheers
Charlie


jkrankie(Posted 2012) [#6]
Just tried to compile the example. getting lots of undefined symbols followed by an ld error, so presumably it's not finding the .dylib, right? or i've done something wrong.



Cheers
Charlie


jkrankie(Posted 2012) [#7]
Oh, i'm using max 1.43 on snow leopard if that makes any difference.

EDIT happens on 1.45 too.

Cheers
Charlie

Last edited 2012


JoshK(Posted 2012) [#8]
I am experiencing similar errors with my own Xcode static library.


jkrankie(Posted 2012) [#9]
Just tried compiling on the new 1.46 on the off chance it might make a difference but no dice unfortunately.

Cheers
Charlie


skidracer(Posted 2012) [#10]
Sorry about posting that code and then abandoning this thread. I was sure I had the linking under control with my last tests, but I think I am mistaken.

Brucey has done a version of bmk that I think may allow the easy linking of dylibs with BlitzMax.

The other option for a Mac steamstub is to build a static glue library (.a) in xCode. I did this for Josh on another project that linked to BlitzMax so know that it is possible.

Last edited 2012


skidracer(Posted 2012) [#11]
OK, sorry for delay.


To build for Mac the following imports are needed, (subsitute path to steam sdk lib path)

Import "-L/Users/simon/steamsdk/lib"
Import "-lsteam_api"
Import "steamstub.cpp"


This will allow the demo to build.

For it to run you need to copy the dylib files from lib to your executable packages MacOS folder (don't forget to do for both debug and release) and voila steamstub should be alive.


jkrankie(Posted 2012) [#12]
Hi Simon,

It links! and appears to work correctly for opening and checking the steam state as well as getting and setting achievements. However, I notice that when setting the achievement you don't get a little popup window ala windows steam, and that the steam overlay doesn't appear when you hit shift+tab. I checked another game to see if it appears and it does.

Also, i'm getting this unlike on windows:
Setting breakpad minidump AppID = 202410
Steam_SetMinidumpSteamID:  Caching Steam ID:  ************** [API loaded no]


I've starred out my account number there, but the 'API loaded no' bit, is that me not setting the right path or something? i links and builds, so i'm assuming it's not.

Cheers
Charlie


jkrankie(Posted 2012) [#13]
Ah, it appears that for the overlay to appear it needs to be run from steam itself. I'll try that as soon as i can.

Cheers
Charlie


jkrankie(Posted 2012) [#14]
Success! http://store.steampowered.com/app/202410/

Cheers
Charlie


Oddball(Posted 2012) [#15]
Hi Simon thanks for your help on this, and I see Charlie has it working but I still can't get it to work. Here's where I'm up to. I have it working for Windows using the redistributable you included with the steamstub, but I get a memory exception when using the redist from my SDK, v1.18. I'm not to bothered about that as long as I have something that is working. For Mac I get a 'file not found' error and it highlights '#include "include/steam_api.h"' in steamstub.cpp. The output window contains the following errors.

Last week I had one of those 'I want to launch my computer out of the window' weeks, but this week I'm feeling more positive so I'm determined to get this up and running.

Last edited 2012


Oddball(Posted 2012) [#16]
My new found positivity did the trick. After a bit of fiddling I now have it compiling. Steam_api.h isn't in the folder include. I found which folder it was in and renamed the folder. A bit more fiddling and I was compiling. Now I'm off to put achievements into my game. I will report back if I am successful.


jkrankie(Posted 2012) [#17]
Ah, i probably should have mentioned i had to rename some folders! Oh well, glad you've got it working :)

If you need any help with setting up achievements let me know, although i imagine you'll have no problems there.

Cheers
Charlie


Oddball(Posted 2012) [#18]
You've been a great help Charlie, as has Simon. I also found that the path on this line [Import "-L/Users/simon/steamsdk/lib"] can't have any spaces in it. Might save someone a few headaches if they're trying to figure it out in the future.


Oddball(Posted 2012) [#19]
Just reporting that I have achievements working for Mac and Windows, although I do have separate problem regarding Mac/Steam but nothing to do with the wrapper. Now I'm just waiting for the Steam bods to get everything set up.

Another note, but not a big issue. There is a function called ResetAllStats in Steamworks, but not in steamstub, which is useful during testing. Like I say, not a biggie as I have it all working and tested.


siread(Posted 2012) [#20]
Has anyone been able to successfully submit leaderboard data with this?


jkrankie(Posted 2012) [#21]
not me, but i didn't try with this newer version.

Cheers
Charlie


siread(Posted 2012) [#22]
I had trouble with an earlier steamstub and it seems to be an issue still. It can create leaderboards but doesn't ever submit. Ah well, I'll just stick with achievements.


skidracer(Posted 2012) [#23]
After a quick look at the SDK example, I think I have found where I have gone wrong. Will post a new version for testing this weekend.


siread(Posted 2012) [#24]
Nice one Skid!


siread(Posted 2012) [#25]
Trying to build the test on Mac with the latest steam sdk but running into problems. I have the imports set up like this:

Import "-L/Users/simonread/Dropbox/Steam/sdk/public/steam"
Import "-lsteam_api"
Import "steamstub.cpp"

In steamstub.cpp I have changed this line:

#include "/Users/simonread/Dropbox/Steam/sdk/public/steam/steam_api.h"

But when building I get this:

ld: library not found for -lsteam_api

Where should it be looking for this api?

Last edited 2012


skidracer(Posted 2012) [#26]
Hi Simon, the file it is looking for is libsteam_api.dylib, and the location it is looking for is that listed in the Import "-L" line. This is the same file you also need copy to the MacOS dir of your app package once you have things linking ok.

Sorry for delay in new release, I'm having some mingw issues getting Windows version building correctly, possibly be another few days before I nut things out.

Last edited 2012


siread(Posted 2012) [#27]
Right, I've got it building and linking thanks!

When running it says:
Building NSS5
Executing:NSS5
Setting breakpad minidump AppID = 212780
Steam_SetMinidumpSteamID:  Caching Steam ID:  76561197970303243 [API loaded no]

And the steam overlay does not appear. Any idea?

Edit: It seems that achievements are updating so that's great! Is the overlay supposed to work during development?

Last edited 2012


jkrankie(Posted 2012) [#28]
You need to be running the game on contentserver for the overlay to appear on mac. You have to be running content server on a windows machine too, and point the mac steam client at it.

Cheers
Charlie


siread(Posted 2012) [#29]
Ah right. Btw, have you used the new steampipe?


jkrankie(Posted 2012) [#30]
No. Not heard of it actually.

Cheers
Charlie


siread(Posted 2012) [#31]
They seem to be ditching the old system and everything is uploaded and handled via the Steamworks site now. Great in theory but I can't get the blooming thing to install via my Steam client.


jkrankie(Posted 2012) [#32]
Ah, that does sound better! Faffing around with local servers isn't super fun. have you got the steam.cfg set up properly? that's usually the cause of connection/install bothers.

Cheers
Charlie


siread(Posted 2012) [#33]
Still having steam issues! I'm sure I had it running fine but since updating the game I can't get it to run after applying Steam's ContentPrep tool. Anyone else had to use it?


Oddball(Posted 2012) [#34]
I had a similar problem. I had to completely uninstall all versions of Xcode, I found a helpfully guide online somewhere, then re-install the very latest Xcode only. Once I'd done that I recompiled the app, and ContentPrep-ed it without the DRM wrapper, to do that I had to run the ContentPrep app from the Terminal.

Hope that helps.


siread(Posted 2012) [#35]
That did the trick! Thanks Dave. :)


siread(Posted 2012) [#36]
Skid, did you manage to fix the Leaderboards?


Godra25(Posted 2015) [#37]
i got this too:
ld: library not found for -lsteam_api


then, i copy libsteam_api.dylib to my app packages dir.
but, still same error?

thanks :)


skidracer(Posted 2015) [#38]
Godra, please post some code, specifically your imports.


Arska(Posted 2015) [#39]
Any way to get players SteamID with current functions?


Godra25(Posted 2015) [#40]
@skidracer: problem solved.. just my mistake.. wrong place to put libsteam_api.dylib file


Godra25(Posted 2015) [#41]
first, sorry if this wrong place to asked about linux.

i use steamstub.cpp above in linux (ubuntu 14.04).. and got this error

Segmentation fault (core dumped)


anyone can help me?

thanks


Derron(Posted 2015) [#42]
Segfaults usually mean you try to access a null-object.

You might be able to track it down when using a debug-build in your MaxIDE.


bye
Ron


Brucey(Posted 2015) [#43]
... and a backtrace from gdb (to show if the error occurred in the library or your code).


Arska(Posted 2015) [#44]
Asking again.. Any way to get steamID with current functions? I have no knowledge about .dll and C++. Also can i test achievements without my own AppID?

When i tested this i see in steam that i am playing "Spacewar", but Steam overlay always tells me that i have 0 minute game time.

I am running Windows and hopefully getting my project ready for Greenlight soon.


skidracer(Posted 2015) [#45]
Arska, the stub is only for people who have been given an AppID and are legally entitled to be using the steam SDK.


Gabriel(Posted 2015) [#46]
The Steam SDK is publicly available to all now, but it's of very little practical use until you're greenlit. You can do little more than just initialize and shutdown the sdk without your own AppID. It's annoying, because naturally, you want to get the code done in advance to avoid problems later, but that's how it is. (That's nothing to do with the wrapper. That's the way the SDK is.)

And no, you definitely cannot test achievements without your own AppID. Achievements have to be added through the Steamworks control panel and that is not possible until the game has been Greenlit.


skidracer(Posted 2015) [#47]
Wow, good to know. Signing up now.


Godra25(Posted 2015) [#48]
@Derron: my MaxIDE debug window is empty (blank), nothing info in there

@Brucey: i try to use gdb, here the result:

for run my program:
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/godra25/Documents/LatihanLinux/TestLinux/steamtest.debug 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
steam stub 1.7

Program received signal SIGSEGV, Segmentation fault.
0xb67db824 in ?? ()
   from /home/godra25/.local/share/Steam/linux32/steamclient.so


for backtrace my program:
(gdb) backtrace
#0  0xb67db824 in ?? ()
   from /home/godra25/.local/share/Steam/linux32/steamclient.so
#1  0xb69bae86 in ?? ()
   from /home/godra25/.local/share/Steam/linux32/steamclient.so
#2  0xb685d47b in ?? ()
   from /home/godra25/.local/share/Steam/linux32/steamclient.so
#3  0xb6860a11 in ?? ()
   from /home/godra25/.local/share/Steam/linux32/steamclient.so
#4  0xb7d75587 in ?? () from /usr/lib/libsteam_api.so
#5  0x08051843 in ?? ()
#6  0x0810d11b in ?? ()
#7  0x0810d095 in ?? ()
#8  0x0810b4ce in ?? ()
#9  0x08050ba1 in ?? ()
#10 0xb7a6ea83 in __libc_start_main (main=0x8050b5d, argc=1, argv=0xbffff024, 
    init=0x810b3b0, fini=0x810b420, rtld_fini=0xb7fed180 <_dl_fini>, 
    stack_end=0xbffff01c) at libc-start.c:287
#11 0x08050a81 in ?? ()



so, the problem is 'libsteam_api.so' right?
anyone know the solution?


Derron(Posted 2015) [#49]
that explains why maxide does not display debug info ... it segfaults in the external lib (the .so file).

bye
Ron


Brucey(Posted 2015) [#50]
so, the problem is 'libsteam_api.so' right?

Well, the problem could be that you are passing bad data to the library, or there is a bug in the wrapper...

Very hard to tell from here what may be going wrong.


Godra25(Posted 2015) [#51]
yes, i think the problem is in SteamAPI_Init()
but, i don't know how to fix it.. because, i'm not that good in C :(

i hope anyone can help me


skidracer(Posted 2015) [#52]
Godra25, are you on linux32 or 64?

Are you using latest steam sdk?

Which .so are you using, where are you putting it and what does the relevant .bmx source look like that you are using to test?

I assume you have Steam installed and other steam games are running fine on your rig?


skidracer(Posted 2015) [#53]
Godra25, are you on linux32 or 64?

Are you using latest steam sdk?

Which .so are you using, where are you putting it and what does the relevant .bmx source look like that you are using to test?

I assume you have Steam installed and other steam games are running fine on your rig?


Godra25(Posted 2015) [#54]
@skidracer:

i on linux 32-bit

yes, i get libsteam_api.so from here /sdk/redistributable_bin/linux32/
then i put ini /sdk/public/steam/

i also make soft link for that .so to /usr/lib/

i used .bmx (and also .cpp) from your post here

hmmm.. i never test other steam games.. ok, i will do it first. and report the result here soon

EDIT:
i've tested other steam game.. it is fine.. work perfectly


skidracer(Posted 2015) [#55]
Thanks,

OK, will be back on Linux this week, will let you know how I get on.


Godra25(Posted 2015) [#56]
@skidracer: thanks, you are so nice :)


and for additional information, maybe this is helping.

now for windows i use steam_api.dll version 7.9.87.40 (from steamstub4a) . my game work good.

then i try to use steam_api.dll version 2.37.91.26 (from the latest SDK, Steamworks SDK v1.31). my game not work.


Godra25(Posted 2015) [#57]
hello skidracer, how about the linux version, have you check it ? :)


skidracer(Posted 2015) [#58]
I was able to reproduce the problem but was unable to fix it.

I'm currently busy on a monkey project but when I get some time I will have another look.


Godra25(Posted 2015) [#59]
@skidracer: ok, thank you for check it.. hope you can finish your monkey project soon :D


Grey Alien(Posted 2015) [#60]
Just wanted to add that I got it working on Mac today, thanks Skid!

I had to comment out this line from the .cpp file:
n=_snprintf( buffer, 128, "%d:%d:%d:",entry.m_nScore,entry.m_nGlobalRank,entry.m_steamIDUser);


The compiler is expecting and int but isn't getting one, so probably m_steamIDUser is struct or something? It's in the leaderboard section which I'm not using but it's probably worth getting fixed (if the rest of leaderboards works too)


Devlin(Posted 2016) [#61]
I got this working on linux(i know this is the Mac thread yada but whatevs) by doing the following:

Copied the headers in the Steamworks SDK (/sdk/public/steam) to a folder called "include"

Copying libsteam_api.so to /usr/lib (a symlink might work?) once you're done building you should make sure libsteam_api.so is actually in your game folder because Steam will look there to find libsteam_api.so when launching from Steam (this has been confirmed by testing)

Adding the following Imports to the test code up above in http://www.blitzbasic.com/Community/post.php?topic=96950&post=1123715 that post

?Linux
Import "-lsteam_api"
Import "steamstub.cpp"
?


This is a lazy ass hack job of a way of doing it but it worked in my Linux Mint installation so hopefully folks can extrapolate and make it work a bit more globally. I don't think I can offer any additional help but I imagine that skid can.