| |
Compiling Lightwave-Plugins with
Dev-C++ 5(beta)
(last updated: 30. Jun 2004)
content:
Introduction
First step: Building the library
Second step: Setting up the plugin
project
Third step: Creating a project template
Introduction:
This tutorial will hopefully help you getting started at compiling
plugins with Bloodshed Dev-C++, a free IDE for Windows using GCC
(in the form MinGW or Cygwin). I could've written it with fewer
words, but i hope it becomes easier to understand it with more details.
A probably easier way is described in >this
tutorial by Carl Looper<. However, it produces lots of object
files that can be avoided, and for some reason the dll.h and dllmain.c
won't load correctly with the template (bug?), hence this tutorial.
First step: Building the
library
Sounds complicated, but actually consists of just a few lines of
code to startup and shutdown the plugins that are the same for all
plugins. We could just throw in those .c files in every project
and compile them anew, but that's a little less concise.
Since we are actually using MinGW (that's what comes with Dev-C++
by default) we can basically use the instructions of the SDK. I'll
just add some details.
Open a command line window (run "CMD.exe" in Windows 2000
and XP) and set your path to the directory where gcc.exe is, e.g.
by typing:
"path=f:\programs\devcpp\bin"
(without quotation marks of course...and use your correct path,
not mine)
now come the SDK instructions:
- cd to the SDK source directory.
- Compile the library sources.
gcc -c -D_WIN32 -D_X86_ -O6 -I$(LWSDK_INCL)
servmain.c servdesc.c username.c startup.c shutdown.c
- Assemble the library.
ar r libserver.a servdesc.o username.o
startup.o shutdown.o
The "-I$(LWSDK_INCL)" should
actually be "-I../include"
(happy mix forward and backslashes...GNU meets Windows *g*) unless
you changed the paths. On a side note, that "$(LWSDK_INCL)"
would be typically used in a Makefile (a bit more on that in a second)
where you would define in a previous line for example "LWSDK_INCL
= ../include", but we're not going to compile this more
than once...hopefully.
Oh and the line below "gcc -c..." belongs to the same
command, just too long for one line here.
I actually used MSYS to do these two steps instead of window's CMD.exe.
It mimics the Linux console, if you like using "make"
and the "./configure" shell scripts the Linux-way (usefull
on many cross-platform Open Source projects) you should check it
out, at www.mingw.org!
I also downloaded a newer GCC from there.
Dev-C++ also creates and uses Makefiles for projets (like in step
2 of this tut) since it is based on the GNU binutils. If you rename
the created "Makefile.win" to just "Makefile"
you could just go to the directory and type "make"
(CMD or MSYS, provided the paths to gcc and binutils are set) to
recompile the whole plugin, and use your favourite geeky text editor
to make code-changes. "make clean"
deletes the old objects and resulting binaries. But GNU "make"
can do much more, we're just scratching the surface of programming
history here...
Oh and the "-O6" is obsolete, "-O3" is the highest
optimize level for the latest GCC generations, but AFAIK it won't
make a difference, even if you wrote "-O9" wich never
existed, it will just use O3.
Ok, now there are several new files, the ones we will need are servmain.o
and libserver.a.
|
|