Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a dylib file on MacOS for use with Python wrapper of Steamworks API

I am a hobbyist programmer trying to integrate the SteamworksForPython API into a Python-based game. This API is a Python wrapper of the Steamworks API, which only officially supports C++. I am working on MacOS Sierra 10.12.6.

Blindly following the documentation, I have done the following:

  1. I have downloaded the SteamworksForPython repo.
  2. I have added the steam header directory from the Steamworks SDK (/sdk/public/steam) to that repo.
  3. I have added to that repo the Steam API file appropriate to my operating system (in my case, libsteam_api.dylib from /sdk/redistributable_bin/osx32).

The next step listed in the documentation is to create a new dylib file. Unfortunately, the steps to do this haven't been described for MacOS yet.

Looking at the process for Linux and Windows, it seems like I need to create this dynamic library file using the repo's SteamworksPy.cpp file and the steam_api.h header file from the Steamworks SDK.

I have researched how to create a dylib file using Xcode and am currently trying to do it. The process seems similar to the one described by the documentation for Windows using Visual Studio.

I have done the following:

  1. I have created a new Xcode project of type plain C++ dynamic library.
  2. I have added SteamworksPy.cpp into the Compile Sources list.
  3. I have added steam_api.h to the Headers list (under public, not private or project).
  4. I have added libsteam_api.dylib to the Link Binary With Libraries section.

I am getting an error when I try to build, however. Here is a screenshot:

enter image description here

And here is a more explicit screenshot of the linker error:

enter image description here

After reading this, this, and this, I think the problem is that Xcode doesn't know where to look for the library I'm trying to link to, so I need to tell it where to look. This should be simple, but I can't manage to do it.

Can anyone give me advice on how to proceed?


Similar questions that were helpful, but didn't lead me to a solution:

  • How do I create a dynamic library (dylib) with Xcode?
  • Building and Using a DYLIB in Xcode
  • ld: library not found
  • ld: library not found for -lgsl
  • xcode library not found
like image 618
DyingIsFun Avatar asked Dec 04 '17 23:12

DyingIsFun


1 Answers

I managed to solve this problem.

Xcode couldn't find the location of the library I was trying to link to.

I noticed that under Build Settings I could specify Path to Link Map File. I tried to hardcode the path to where my library (libsteam_api.dylib) resided, but I got the same error described above.

Then I did something that worked.

I deleted the reference to the library in the Link Binary With Libraries section.

Then I moved the library from its original location into my Xcode project directory.

Then I used the file selection pane in the Link Binary With Libraries section to reselect the library from the Xcode directory.

When I built, everything worked fine.

like image 80
DyingIsFun Avatar answered Oct 12 '22 15:10

DyingIsFun