Page 1 of 1

Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executable

Posted: Fri Jun 21, 2024 9:15 pm
by skinkairewalker
Loading steamlib.so on Ubuntu 22, it works when running in the PB IDE, but when generating the executable and run, it gives an error when importing the library.


Ubuntu 22.04.2 x64
Source PB + Libraries Linux64 : https://filebin.net/25ye4q13vvb7b8iw

What could be happening that doesn't find steamlib.so in the same folder?

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Sat Jun 22, 2024 11:12 am
by mk-soft
If the lib is not in the standard folder, but in the same folder as program, you must also specify the path.

Code: Select all

Macro GetProgramPath()
  GetPathPart(ProgramFilename())
EndMacro

libPath.s = GetProgramPath() + "steamlib.so"

Debug libPath

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Mon Jun 24, 2024 2:40 am
by skinkairewalker
mk-soft wrote: Sat Jun 22, 2024 11:12 am If the lib is not in the standard folder, but in the same folder as program, you must also specify the path.

Code: Select all

Macro GetProgramPath()
  GetPathPart(ProgramFilename())
EndMacro

libPath.s = GetProgramPath() + "steamlib.so"

Debug libPath

I tested it on 2 Linux operating systems and it still can't read steamlib.so: ubuntu and zorim

code used below:

Code: Select all


Global SteamIDv.i
Global SteamNamev.s = ""

Macro GetProgramPath()
  GetPathPart(ProgramFilename())
EndMacro

libPath.s = GetProgramPath() + "steamlib.so"

Debug libPath
Debug GetCurrentDirectory()

If OpenLibrary(0, libPath) <> 0
  
  *SteamInit_ = GetFunction(0, "SteamAPI_Init")
  If *SteamInit_
    Debug "meu cu"
    *SteamInit_Call = CallCFunctionFast(*SteamInit_)
    If *SteamInit_Call
      
      *GetPersonaName_ = GetFunction(0, "GetPersonaName")
      If *GetPersonaName_
        *GetPersonaName_Call = CallCFunctionFast(*GetPersonaName_)
        SteamNamev = PeekS(*GetPersonaName_Call,-1,#PB_UTF8|#PB_ByteLength)
        
      EndIf
      
      *GetSteamID_ = GetFunction(0, "GetSteamID")
      If *GetSteamID_
        *GetSteamID_Call = CallFunctionFast(*GetSteamID_)
        SteamIDv = *GetSteamID_Call;PeekI(*GetSteamID_Call)
      EndIf
      
      *GetAppID_ = GetFunction(0, "GetAppID")
      If *GetAppID_
        *GetAppID_Call = CallFunctionFast(*GetAppID_)
        Debug *GetAppID_Call;PeekI(*GetSteamID_Call)
      EndIf
      
      *GetAppInstallDir_ = GetFunction(0, "GetAppInstallDir")
      If *GetAppInstallDir_
        *GetAppInstallDir_Call = CallCFunctionFast(*GetAppInstallDir_)
        Debug PeekS(*GetAppInstallDir_Call,-1,#PB_UTF8|#PB_ByteLength)
      EndIf
      
      *GetAppOwner_ = GetFunction(0, "GetAppOwner")
      If *GetAppOwner_
        *GetAppOwner_Call = CallCFunctionFast(*GetAppOwner_)
        Debug *GetAppOwner_Call
      EndIf
      
      *GetSteamUILanguage_ = GetFunction(0, "GetSteamUILanguage")
      If *GetSteamUILanguage_
        *GetSteamUILanguage_Call = CallCFunctionFast(*GetSteamUILanguage_)
        Debug PeekS(*GetSteamUILanguage_Call,-1,#PB_UTF8|#PB_ByteLength)
      EndIf
      
      *IsAppInstalled_ = GetFunction(0, "IsAppInstalled")
      If *IsAppInstalled_
        *IsAppInstalled_Call = CallCFunctionFast(*IsAppInstalled_)
        Debug *IsAppInstalled_Call
      EndIf
      
      *IsSteamRunning_ = GetFunction(0, "IsSteamRunning")
      If *IsSteamRunning_
        *IsSteamRunning_Call = CallCFunctionFast(*IsSteamRunning_)
        Debug *IsSteamRunning_Call
      EndIf
      
      *IsSubscribed_ = GetFunction(0, "IsSubscribed")
      If *IsSubscribed_
        *IsSubscribed_Call = CallCFunctionFast(*IsSubscribed_)
        Debug *IsSubscribed_Call
      EndIf
      
      *IsSubscribedApp_ = GetFunction(0, "IsSubscribedApp")
      If *IsSubscribedApp_
        *IsSubscribedApp_Call = CallCFunctionFast(*IsSubscribedApp_)
        Debug *IsSubscribedApp_Call
      EndIf
;       
;       *IsOverlayEnabled_ = GetFunction(0, "IsOverlayEnabled")
;       If *IsOverlayEnabled_
;         *IsOverlayEnabled_Call = CallCFunctionFast(*IsOverlayEnabled_)
;         Debug *IsOverlayEnabled_Call
;       EndIf
      
    EndIf
    
  EndIf
  
  CloseLibrary(0)
Else
  MessageRequester("Library Error","Error on loadingn library")
EndIf

  If OpenWindow(0, 0, 0, 350, 250, "SteamWorks", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ListViewGadget(0, 0, 0, 350, 250)
    
    AddGadgetItem (0, -1, "Baitola Name : "+SteamNamev)
    AddGadgetItem (0, -1, "Baitola SteamID : "+SteamIDv)
      
    
    Repeat
      Event = WaitWindowEvent()
      
      If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
        Quit = 1
      EndIf
      
    Until Quit = 1
   
    
  EndIf 

End
screenshots :
Running Fine on PB IDE : https://prnt.sc/AkQ3I6cQj-PX
Trying Run with released executable : https://prnt.sc/RGfF5V5XjQDC
[2] : https://prnt.sc/8R0FdnNaczUA

What could be happening?

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Mon Jun 24, 2024 7:59 am
by mk-soft
Strange ...

I'll have to test it tonight.
What if the files are on the Linux drive and not on the Parallels shared folder?

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Mon Jun 24, 2024 5:51 pm
by mk-soft
I have localised the problem.

When the program is started from the PureBasic IDE, the debugger creates its own environment with the search path of the executable.

Without the debugger there is not this path.
but the steamlib.so has a dependency to the libsteam_api.so and does not find it.

Terminal:
ldd steamlib.so
linux-vdso.so.1 (0x00007fffc2beb000)
libsteam_api.so => not found
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007df8dda00000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007df8ddddb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007df8dd600000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007df8ddcf4000)
/lib64/ld-linux-x86-64.so.2 (0x00007df8dde24000)
If you put the libsteam_api.so in the path /usr/lib the programme works, because the steamlib.so then finds the library libsteam_api.so.

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Mon Jun 24, 2024 8:57 pm
by freak
You can try adding the directory with the libraries to the LD_LIBRARY_PATH environment variable before loading the lib. This might help.

The IDE modifies this variable too but it only adds the PB compiler directory to it nothing else so I am not sure if this is what makes the difference.

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Tue Jun 25, 2024 2:32 pm
by skinkairewalker
mk-soft wrote: Mon Jun 24, 2024 5:51 pm I have localised the problem.

When the program is started from the PureBasic IDE, the debugger creates its own environment with the search path of the executable.

Without the debugger there is not this path.
but the steamlib.so has a dependency to the libsteam_api.so and does not find it.

Terminal:
ldd steamlib.so
linux-vdso.so.1 (0x00007fffc2beb000)
libsteam_api.so => not found
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007df8dda00000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007df8ddddb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007df8dd600000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007df8ddcf4000)
/lib64/ld-linux-x86-64.so.2 (0x00007df8dde24000)
If you put the libsteam_api.so in the path /usr/lib the programme works, because the steamlib.so then finds the library libsteam_api.so.
So the problem is with SteamworksPy https://github.com/philippj/SteamworksPy, which is forcibly searching in the /usr/lib folder?

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Tue Jun 25, 2024 2:33 pm
by skinkairewalker
freak wrote: Mon Jun 24, 2024 8:57 pm You can try adding the directory with the libraries to the LD_LIBRARY_PATH environment variable before loading the lib. This might help.

The IDE modifies this variable too but it only adds the PB compiler directory to it nothing else so I am not sure if this is what makes the difference.
using command : SetEnvironmentVariable(Name$, Value$) ??

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Tue Jun 25, 2024 4:48 pm
by freak

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Tue Jun 25, 2024 6:51 pm
by mk-soft
Not work with set 'LD_LIBRARY_PATH'

where created the steamlib.so ?

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Tue Jun 25, 2024 7:06 pm
by skinkairewalker
mk-soft wrote: Tue Jun 25, 2024 6:51 pm Not work with set 'LD_LIBRARY_PATH'

where created the steamlib.so ?
I compiled it as the documentation instructs.
Could it be something directly in the SteamworksPy code?

Source Code used : https://github.com/philippj/SteamworksP ... /tag/1.6.5
compile documentation [Linux] : https://philippj.github.io/SteamworksPy/

Re: Loading steamlib.so in Ubuntu 22, works well in PB IDE, but gives an error when running through the released executa

Posted: Tue Jun 25, 2024 7:30 pm
by skinkairewalker
Looks like I found something that might help. https://github.com/philippj/SteamworksPy/issues/61
If it works, my theory was correct, which was something with the code/compilation xD


UPDATE : fixed that with adding to the end of makefile: -Wl,-rpath=. :
g++ -std=c++11 -o SteamworksPy.so -shared -fPIC SteamworksPy.cpp -l steam_api -L. -Wl,-rpath=.


Thank you so much for your help, mk-soft & freak. You guys are awesome!