0
votes
  1. I downloaded the Steamworks SDK.

  2. There is a Steamworks example inside. When I execute command make in steamworksexample folder it fails with errors:

    steam/sdk/steamworksexample$ make steam/sdk/steamworksexample/../tools/linux/bin/g++ -g -DPOSIX -DSDL -I/home/steam/sdk/steamworksexample/../tools/linux/runtime/i386/usr/include/SDL2 -D_REENTRANT -DGNUC -O0 -I/home/steam/sdk/steamworksexample/../public -DDEBUG   -c Inventory.cpp -o debug/Inventory.o -MD -MF debug/Inventory.dep
    

    Inventory.cpp: In member function 'void CSpaceWarLocalInventory::OnSteamInventoryFullUpdate(SteamInventoryFullUpdate_t*)': Inventory.cpp:61:61: error: 'nullptr' was not declared in this scope Inventory.cpp: In member function 'void CSpaceWarLocalInventory::OnSteamInventoryResult(SteamInventoryResultReady_t*)': Inventory.cpp:131:62: error: 'nullptr' was not declared in this scope Inventory.cpp: In member function 'void CSpaceWarLocalInventory::DoExchange()': Inventory.cpp:218:18: error: 'nullptr' was not declared in this scope Inventory.cpp: In member function 'void CSpaceWarLocalInventory::GrantTestItems()': Inventory.cpp:243:35: error: 'nullptr' was not declared in this scope Inventory.cpp: In member function 'const CSpaceWarItem* CSpaceWarLocalInventory::GetItem(SteamItemInstanceID_t) const': Inventory.cpp:254:9: error: 'nullptr' was not declared in this scope Inventory.cpp: In member function 'const CSpaceWarItem* CSpaceWarLocalInventory::GetInstanceOf(SteamItemDef_t) const': Inventory.cpp:276:9: error: 'nullptr' was not declared in this scope Inventory.cpp: In member function 'void CSpaceWarLocalInventory::RefreshFromServer()': Inventory.cpp:283:33: error: 'nullptr' was not declared in this scope make: *** [debug/Inventory.o] Error 1

  3. I'm using Ubuntu 14.04.3 LTS.

1

1 Answers

1
votes

I just got the steamworks example to build and run on my Ubuntu 14.04 computer. I don't have a great fix, but a few hacky solutions.

The short solution was to run (you'll need to modify the include paths here to whatever directory you have this code in):

make CFLAGS="-std=c++0x -include /home/bbales2/sdk/public/steam/steamtypes.h -I/home/bbales2/sdk/tools/linux/runtime-release/amd64/usr/include/SDL2/ -DSDL=1"

This will compile some things, but will fail to compile "glew.c". To compile this file you need to remove the steamtypes include from that make and run it again like so:

make CFLAGS="-std=c++0x -I/home/bbales2/sdk/tools/linux/runtime-release/amd64/usr/include/SDL2/ -DSDL=1"

After glew.c compiles, the make will fail again. Re-run the first make command and eventually things should finish. Run the example with "debug/SteamworksExample.sh"


In more detail, the errors I came across are listed here. We can fix them all with CFLAGS:

error: 'nullptr' was not declared in this scope

To fix this you need to tell your compiler to be C++11. This is the "-std=c++0x" flag

GameEngine.h:129:52: error: 'uint32' has not been declared
GameEngine.h:129:67: error: 'uint32' has not been declared
GameEngine.h:132:52: error: 'byte' has not been declared
GameEngine.h:132:65: error: 'uint32' has not been declared
GameEngine.h:132:80: error: 'uint32' has not been declared
GameEngine.h:135:52: error: 'DWORD' has not been declared

There is a header, sdk/public/steam/steamtypes.h that defines these. It's not getting included by default for some reason. This is the "-include /home/bbales2/sdk/public/steam/steamtypes.h" flag.

gameenginesdl.h:18:17: fatal error: SDL.h: No such file or directory

The SDL headers are missing. Valve includes them in sdk/tools/linux/runtime-release/amd64/usr/include/SDL2/ but the Makefile isn't detecting and adding them. This is the "-I/home/bbales2/sdk/tools/linux/runtime-release/amd64/usr/include/SDL2/" flag.

In file included from <command-line>:0:0:
/home/bbales2/sdk/public/steam/steamtypes.h:107:15: error: variably modified 'Salt_t' at file scope
/home/bbales2/sdk/public/steam/steamtypes.h:123:1: error: initializer element is not constant
make: *** [debug/glew.o] Error 1

We get this error because we can't include steamtypes.h while compiling this file (using the -include flag to force includes like this is not a great idea). Just removing the steamtypes include, re-running make to compile this file, and then adding the steamtypes include back (for the rest of the compile) seems to work.

And

Main.cpp:248:2: error: #error Need CreateGameEngine()
... (bunch of Warnings)
Main.cpp: In function 'int RealMain(const char*, HINSTANCE, int)':
Main.cpp:251:2: error: expected primary-expression before 'if'
Main.cpp:251:2: error: expected ',' or ';' before 'if'
make: *** [debug/Main.o] Error 1

Main.cpp seems to want us to define the SDL macro. We do that with "-DSDL=1"