EDIT: I finally figured how to get steam working. Check this thread for Instructions:
https://forum.thegamecreators.com/thread/222679
I misunderstood the -shared flag in g++
-------------------------------------------------------------------------------------------------------------
Has anyone been able to get the steam API working with the agk linux template? I'm getting an error that wants libAGKLinux.a to be recompiled with the "-fPIC" flag.
This is what I've done so far.
1> Make sure Steam is running and you are logged into the account where you paid your Product Submission Fee.
2> Download the steam sdk and extract it into your template folder. It should add a folder called "sdk".
3> Edit MakeFile
Change:
INC = -I../../common/include -I../../common -I../interpreter -I../../bullet -I../../bullet/BulletCollision/CollisionShapes
To:
INC = -I./sdk/public/steam -I../../common/include -I../../common -I../interpreter -I../../bullet -I../../bullet/BulletCollision/CollisionShapes
Change:
CFLAGS = -02
To:
CFLAGS = -02 -fPIC
Change:
# link the .o files
Executable: | $(OBJS)
$(CC) $(OBJS) -o build/LinuxApp$(ARCH) $(LDFLAGS) -Wl,-Bstatic -lAGKLinux -lglfw3 -Wl,-Bdynamic -lGL -lXt -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lXinerama -lXcursor -lcurl -lopenal -ludev -ldl
To:
# link the .o files
Executable: | $(OBJS)
$(CC) $(OBJS) -o build/LinuxApp$(ARCH) $(LDFLAGS) -Wl,-Bstatic -lAGKLinux -lglfw3 -Wl,-Bdynamic -lGL -lXt -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lXinerama -lXcursor -lcurl -lopenal -ludev -ldl -shared libsteam_api.so
4>Add "libsteam_api.so" in the template directory. It is located in "sdk\redistributable_bin\linux64"
5>Create a text file called "steam_appid.txt" and type your app id number. Save this file and place it in the directory that will contains the complied executable file.
6>Edit template.c to the following:
// Includes
#include "template.h"
#include "steam_api.h"
#include <string>
// Namespace
using namespace AGK;
using namespace std;
app App;
bool bResult = false;
void app::Begin(void)
{
agk::SetVirtualResolution (1024, 768);
agk::SetClearColor( 151,170,204 ); // light blue
agk::SetSyncRate(60,0);
agk::SetScissor(0,0,0,0);
bResult = SteamAPI_Init();
}
int app::Loop (void)
{
if (bResult)
{
agk::Print("Success...");
string sSteamName = SteamFriends()->GetPersonaName();
CSteamID steamId = SteamUser()->GetSteamID();
int iSteamID = steamId.GetAccountID();
agk::Print(sSteamName.c_str());
agk::Print(iSteamID);
}
else agk::Print("Failed...");
agk::Sync();
return 0; // return 1 to close app
}
void app::End (void)
{
SteamAPI_Shutdown();
}
My MAKEFILE:
MAKEFILE:
# discover if this is a 32 or 64 bit machine
ARCH := $(shell getconf LONG_BIT)
CC = g++
ODIR = build/obj$(ARCH)
INC = -I./sdk/public/steam -I../../common/include -I../../common -I../interpreter -I../../bullet -I../../bullet/BulletCollision/CollisionShapes
CFLAGS = -O2 -fPIC
LDFLAGS32 = -L../../platform/linux/Lib/Release32
LDFLAGS64 = -L../../platform/linux/Lib/Release64
LDFLAGS = $(LDFLAGS$(ARCH)) -static-libstdc++ -static-libgcc
# list of dependencies so that changes to these files cause a rebuild of source files
DEPS = template.h
# list of object files to compile, they will be placed in the $(ODIR) folder
# matching .cpp files will be searched for below
_OBJS = Core.o \
template.o
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
# entry point, create folders, compile source files, and link the executable
all: setup $(OBJS) Executable
# make sure the build folders exist
setup:
mkdir -p build/obj$(ARCH)
# compile a source file, first search path is the template folder
$(ODIR)/%.o: %.cpp $(DEPS)
$(CC) -DIDE_LINUX -static -c $(INC) -o $@ $< $(CFLAGS)
# second search path is the interpreter folder, used as an example, not used
$(ODIR)/%.o: ../interpreter/%.cpp $(DEPS)
$(CC) -DIDE_LINUX -static -c $(INC) -o $@ $< $(CFLAGS)
# link the .o files
Executable: | $(OBJS)
$(CC) $(OBJS) -o build/LinuxApp$(ARCH) $(LDFLAGS) -Wl,-Bstatic -lAGKLinux -lglfw3 -Wl,-Bdynamic -lGL -lXt -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lXinerama -lXcursor -lcurl -lopenal -ludev -ldl -shared libsteam_api.so
# delete compiled files
clean:
rm -rf build/obj$(ARCH)/*
rm -f build/LinuxApp$(ARCH)
ERROR:
cd '/home/master/.steam/steam/steamapps/common/App Game Kit 2/Tier2/apps/SteamTest'
/usr/bin/make -f Makefile clean
rm -rf build/obj64/*
rm -f build/LinuxApp64
CLEAN SUCCESSFUL (total time: 64ms)
cd '/home/master/.steam/steam/steamapps/common/App Game Kit 2/Tier2/apps/SteamTest'
/usr/bin/make -f Makefile
mkdir -p build/obj64
g++ -DIDE_LINUX -static -c -I./sdk/public/steam -I../../common/include -I../../common -I../interpreter -I../../bullet -I../../bullet/BulletCollision/CollisionShapes -o build/obj64/Core.o Core.cpp -O2 -fPIC
g++ -DIDE_LINUX -static -c -I./sdk/public/steam -I../../common/include -I../../common -I../interpreter -I../../bullet -I../../bullet/BulletCollision/CollisionShapes -o build/obj64/template.o template.cpp -O2 -fPIC
g++ build/obj64/Core.o build/obj64/template.o -o build/LinuxApp64 -L../../platform/linux/Lib/Release64 -static-libstdc++ -static-libgcc -Wl,-Bstatic -lAGKLinux -lglfw3 -Wl,-Bdynamic -lGL -lXt -lX11 -lXxf86vm -lXrandr -lpthread -lXi -lXinerama -lXcursor -lcurl -lopenal -ludev -ldl -shared libsteam_api.so
/usr/bin/ld: ../../platform/linux/Lib/Release64/libAGKLinux.a(uString.o): relocation R_X86_64_32 against `_ZN3AGK26g_iCaseFoldingReplacementsE' can not be used when making a shared object; recompile with -fPIC
../../platform/linux/Lib/Release64/libAGKLinux.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:38: recipe for target 'Executable' failed
make: *** [Executable] Error 1
BUILD FAILED (exit value 2, total time: 2s)