philippj / SteamworksPy

A working Python API system for Valve's Steamworks.
MIT License
214 stars 40 forks source link

Can't run basic demos #5

Closed Sasszem closed 7 years ago

Sasszem commented 7 years ago

I can't run a basic example, found on https://coaguco.tumblr.com/post/128240756897/steamworks-for-python-tutorial-linux. I downloaded this repo, used the pre-compiled .so library, and installed libsteam to /usr/lib cuz steam forgot it.
In the test folder I've got game.py, steam_appid.txt(480), SteamworksPy.so, also steamworks.pyc. The contents of game.py:

# -*- coding: utf-8 -*-
from steamworks import *

Steam.Init()

NAME = SteamFriends.GetPlayerName()
print(NAME)
Gramps commented 7 years ago

They might be outdated. What error are you getting?

Sasszem commented 7 years ago

Updated comment Error:

Traceback (most recent call last):
  File "game.py", line 7, in <module>
    Steam.Init()
  File "/home/laci/Dokumentumok/SteamworksForPython-master/tg/steamworks.py", line 51, in Init
    Steam.cdll = CDLL(os.path.join(os.getcwd(), "SteamworksPy.so"))
  File "/usr/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/laci/Dokumentumok/SteamworksForPython-master/tg/SteamworksPy.so: undefined symbol: SteamUserStats
Gramps commented 7 years ago

Hmm. Did you compile the .so file yourself or use the one in the zip?

Sasszem commented 7 years ago

I used the premade one cuz compiling failed.

Sasszem commented 7 years ago

... Now I tried to compile again, and it worked by adding -std=c++0x to the makefile. I tried this B4, but it failed... Anyway, it looks like working! Please:

Gramps commented 7 years ago

Actually the instructions as I have them work fine for me and I've not heard anyone say they don't work so far.

What do you mean "install libsteam"?

Sasszem commented 7 years ago

I had to install libsteam_api.so to /usr/lib to let it work. Else it didn't found it. With the default makefile, I got the following error:

laci@lacigepe:~/Dokumentumok/SteamworksForPython-master$ make
g++ -o SteamworksPy.so -shared -fPIC SteamworksPy.cpp -lsteam_api
SteamworksPy.cpp: In member function ‘void Workshop::OnWorkshopItemCreated(CreateItemResult_t*, bool)’:
SteamworksPy.cpp:200:33: error: ‘nullptr’ was not declared in this scope
   if (_pyItemCreatedCallback != nullptr) 
                                 ^
SteamworksPy.cpp: In member function ‘void Workshop::OnItemUpdateSubmitted(SubmitItemUpdateResult_t*, bool)’:
SteamworksPy.cpp:208:33: error: ‘nullptr’ was not declared in this scope
   if (_pyItemUpdatedCallback != nullptr)
                                 ^
Makefile:2: recipe for target 'makeall' failed
make: *** [makeall] Error 1
Gramps commented 7 years ago

Ah, OK. This version contains functions added by a pull request that I didn't write and, clearly, didn't check first before merging. I thought that Workshop stuff seemed odd. I presumed their code was fine as it is used in a working game.

I haven't used the wrapper in a while as I've moved from my Python engine to Godot. But I'll check it out and make some changes right now.

Sasszem commented 7 years ago

OK then

Gramps commented 7 years ago

Thanks for bringing this to my attention though! Don't want to leave unworking code just lying about.

UPDATED: appropriate changes have been made. Apparently they added some C++ 11 pointers that didn't work without specifying with "-std=c++0x" or such. I added that to the makefile, changed the readme, and updated the Linux pre-build. Thanks again!