Compile Plugin for Linux

Hi, I have a plugin with some functions compiled and tested for Windows (Visual Studio Express) and OSX (Xcode), and I want to compile an application that use these plugin for Linux, how to compile my C / C++ code in Linux, so I can generate my Plugin for Linux too?

Have you got any of the dev tools installed on Linux ?

You’ll need gcc then compile a shared library so you generate a .so file as the linux portion of the plugin

Yes, I have gcc installed on Linux, but, my question is: PluginMain is c++ code. So, I think gcc won’t work with it, am I wrong? What do I have to include (.h) to my sources? Do I have to make some kind of changes on my code, or set some kind of environment variables? (on Windows, I had to set IGNOREQT on Visual Studio).

Thanks for Your help!

Is there any readme for Linux, like the one for Visual Studio, present on the examples?

you could start and check the examples coming with SDK. you compile with makefile and there you can define something. I define LINUX=1 for linux, so I can use #if LINUX there.

GCC have a CPP frontend. Check the Eye Control example. Here is the make file (you can notice the g++ there):

[code]# Makefile_Linux | Sep 08 2011

This is the Linux makefile for the EyeControl plugin.

Document Author: William Yu

Document Contributor(s):

Revision History

CC = g++
BASEDIR = …/…/…
PLUGINSDKDIR = $(BASEDIR)/Plugins\ SDK
SDKGLUECODEDIR = $(PLUGINSDKDIR)/Glue\ Code
SDKINCLUDEDIR = $(PLUGINSDKDIR)/Includes

INCLUDE = -I$(SDKINCLUDEDIR)

PREFIXHEADER = $(SDKINCLUDEDIR)/LinuxHeader.h
CFLAGS = -s -O2 -DIGNOREQT -D__INTEL__ -DLINUX=1 -D__GCC__ $(INCLUDE) -include $(PREFIXHEADER)
LIBS =
BUILDOBJDIR = BuildLinux

OBJS = $(BUILDOBJDIR)/EyeControlPlugin.o \
$(BUILDOBJDIR)/PluginMain.o

all: CreateBuildObjDir $(OBJS)
$(CC) $(CFLAGS) -shared -o EyeControl.so $(OBJS) $(LIBS)

CreateBuildObjDir:
mkdir -p $(BUILDOBJDIR)

$(BUILDOBJDIR)/EyeControlPlugin.o: EyeControlPlugin.cpp
$(CC) $(CFLAGS) EyeControlPlugin.cpp -c -o $@

$(BUILDOBJDIR)/PluginMain.o: $(SDKGLUECODEDIR)/PluginMain.cpp
$(CC) $(CFLAGS) $(SDKGLUECODEDIR)/PluginMain.cpp -c -o $@

clean:
rm $(BUILDOBJDIR)/*.o -f
rm EyeControl.so
[/code]

Ok, now I’ve got it!

Thank You all!!!

Hi, I’ve compiled the plugin and maked the .rbx successfully, but when I build my application and try to run on a Linux machine, it returns this error:

Runtime Error
Please report what caused this error along with the information below.
Common/plugin.cpp: 5327
Failure Condition: 0
The application cannot continue because a needed file cannot be installed. /home/sandro/MyApplication/MyApplication Libs/libbds.so: undefined symbol: mod10

Any ideas?

Try adding the --no-undefined flag here:
$(CC) $(CFLAGS) -shared -Wl,–no-undefined -o EyeControl.so $(OBJS) $(LIBS)

Basically you’re referencing a function that does not exist in your library. That flag will tell you where you’re using it and flag it as a compile error.