Compiling submodule example on SB 4.1

Questions and information about using Lua scripting with Storyboard

Moderator: jamiev

Compiling submodule example on SB 4.1

Postby ScotSutherland » Mon Aug 24, 2015 2:50 pm

Building a Lua plugin with a c library.
I am using the standard gcc on OS X 10.10.5 (Xcode 6.4 Installed).

I am starting with the Makefile for the sbmodule.
http://www.cranksoftware.com/forums/download/file.php?id=100

Crashes when attempting to link to libsblua.so.

I have checked the path and it seems to be right.

Makefile:

Code: Select all
TARGET=sbmodule.so
SRCS=sbmodule.c
OBJS=${SRCS:.c=.o}

SB_INSTALL=/Applications/Crank_Software/Storyboard_Engine/4.1.201506290435

# If building on MacOS
CFLAGS += -fPIC
LDFLAGS+= -shared -flat_namespace -undefined suppress -install_name $(TARGET)

SB_ROOT=$(SB_INSTALL)/macos-x86-opengles_2.0-obj
# End MacOS

SB_INC=-I$(SB_ROOT)/include -I$(SB_ROOT)/include/lua
SB_LIB=-L$(SB_ROOT)/lib -libsblua

$(TARGET) : $(OBJS)
   $(CC) $(CFLAGS) $(LDFLAGS) $(SB_INC) -o $@ $^ $(SB_LIB)

%.o:%.c
   $(CC) $(CFLAGS) $(SB_INC) -c -o $@ $^

clean:
   rm -fr $(OBJS)
   rm -fr $(TARGET)

xfer:
   #cp $(TARGET) /Users/thomas/test/lua_module/project/lua_module_test/scripts/macos-x86
   cp $(TARGET) /Users/Sutherland/workspaceC/Mac/macos-x86


Terminal output:

Code: Select all
Scots-MacBook-Pro:c_src Sutherland$ make
cc -fPIC -shared -flat_namespace -undefined suppress -install_name sbmodule.so -I/Applications/Crank_Software/Storyboard_Engine/4.1.201506290435/macos-x86-opengles_2.0-obj/include -I/Applications/Crank_Software/Storyboard_Engine/4.1.201506290435/macos-x86-opengles_2.0-obj/include/lua -o sbmodule.so sbmodule.o -L/Applications/Crank_Software/Storyboard_Engine/4.1.201506290435/macos-x86-opengles_2.0-obj/lib -llibsblua
ld: library not found for -llibsblua
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sbmodule.so] Error 1
Scots-MacBook-Pro:c_src Sutherland$
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm

Re: Compiling submodule example on SB 4.1

Postby MikeMarchand » Thu Aug 27, 2015 2:09 pm

Hi Scot,

Though we've already solved this through our support channels, it's probably a good idea for me to comment here on this topic as well.

To get this to compile we had to make an adjustment to the makefile.
We swapped this line:
SB_LIB=-L$(SB_ROOT)/lib -libsblua

With this line:
SB_LIB=-L$(SB_ROOT)/lib -lsblua

Some compilers only require -l and the base name of the library. The compiler will prefix sblua with lib and append it with .so. This results in the compiler looking to link against libsblua.so
MikeMarchand
 
Posts: 31
Joined: Wed Jan 21, 2015 3:33 pm

Re: Compiling submodule example on SB 4.1

Postby ScotSutherland » Thu Oct 01, 2015 12:10 pm

To complete this thread. The libraries in question have been compiled successfully against sblua.so. Thanks for your help.
ScotSutherland
 
Posts: 23
Joined: Mon Jul 13, 2015 3:53 pm


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron