YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Compile Squirrel as a shared library
henry4k
#1 Posted : Saturday, April 09, 2011 5:17:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/1/2011(UTC)
Posts: 9
Location: Germany

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
I really can't figure out how to compile it as a shared library without modifing the source.
The problem is afaik, that all the api functions are declared in cpp-Files (without extern "C").

Could some clever guy give me a hint how to solve this?
fagiano
#2 Posted : Saturday, April 09, 2011 6:28:19 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 825

Thanks: 0 times
Was thanked: 36 time(s) in 29 post(s)
what about redefining SQUIRREL_API?

Alberto
henry4k
#3 Posted : Saturday, April 09, 2011 9:32:10 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/1/2011(UTC)
Posts: 9
Location: Germany

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
That was also my first approach, but since the definition is in a cpp-file it doesn't works.
At least for gcc/mingw. Since I have no VC++ on my machine, I had no chance trying it with their compiler.
fagiano
#4 Posted : Sunday, April 10, 2011 8:00:38 AM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 825

Thanks: 0 times
Was thanked: 36 time(s) in 29 post(s)
This makefile works for me

Code:


INCZ= -I$(SQUIRREL)/include -I. -Iinclude

SRCS= \
    sqapi.cpp \
    sqbaselib.cpp \
    sqfuncstate.cpp \
    sqdebug.cpp \
    sqlexer.cpp \
    sqobject.cpp \
    sqcompiler.cpp \
    sqstate.cpp \
    sqtable.cpp \
    sqmem.cpp \
    sqvm.cpp \
    sqclass.cpp
sqdll:
  gcc -O2 -shared -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing -c $(SRCS) $(INCZ) -D"SQUIRREL_API=__declspec(dllexport)"
  g++ -shared -s -o squirrel.dll *.o


ciao
Alberto
henry4k
#5 Posted : Tuesday, April 12, 2011 2:15:05 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/1/2011(UTC)
Posts: 9
Location: Germany

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Huh, okay I didn't knew that it should be done like this.
On the internet I've read about the 'problem' with libstdc++ in C-DLLs, but somehow I utterly failed to write a working makefile.

Thanks, you helped me alot! :D

Btw. I want to use this for a module system, much like the one by Toji.
In the last time I've already written some modules like a FastCGI interface or a irc client/bot.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.079 seconds.