Page 1 of 1

Beginners plugin compile problems

Posted: Thu Feb 23, 2012 3:25 pm
by Beardy
Hey,

I'm on Ubuntu 11.04 using BZFlag 2.4.0 , and have a problem: I have no idea to how I can compile a single plugin ...

I've create a new plugin using "newplug.sh", but that is about as far as I got. Going into the plugin-directory and type "make" does not do much.

Beardy

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 4:33 pm
by blast
When you ran newplug.sh, it told you this:

Code: Select all

New plug-in "SomePlugin" is ready.  A directory for your plug-in was created.

To add SomePlugin to the build system, you need to edit two files:
  Edit plugins/Makefile.am and add a line for your plugin to the SUBDIRS list
  Edit configure.ac and add a line for the plugins/SomePlugin/Makefile near the end

You then need to rerun autogen.sh and configure just once to enable your
new plugin with the build system.

Get started coding here: ./SomePlugin
It already attempts to do the Makefile.am step automatically, so that part is probably done. Just do the rest of what it says.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 5:55 pm
by Beardy
blast wrote:Just do the rest of what it says.
I'm afraid you misunderstood.
beardy wrote:I have no idea to how I can compile a SINGLE plugin
(emphasis mine)

I know that I can re-compile everything (server, client, bzadmin, all plugins) again and again, but I think that would be an unneccessary waste of time.

It looks to me that as I'm only changing the "testplug.cxx" file only the plugin needs to be re-compiled (into an .so). Wouldn't it be possible to put a new make-file into the plugins directory and have that one executed (by "make") ?

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 5:59 pm
by JeffM
On linux plugins must be built with the rest of the system, you can't build a single one and just link to export libs like you can do on windows. Our build system just isn't set up that way.

The system will cache what didn't change so when you build the entire thing it will only build and link your plugin.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 6:02 pm
by blast
Beardy wrote:
blast wrote:Just do the rest of what it says.
I'm afraid you misunderstood.
beardy wrote:I have no idea to how I can compile a SINGLE plugin
(emphasis mine)

I know that I can re-compile everything (server, client, bzadmin, all plugins) again and again, but I think that would be an unneccessary waste of time.

It looks to me that as I'm only changing the "testplug.cxx" file only the plugin needs to be re-compiled (into an .so). Wouldn't it be possible to put a new make-file into the plugins directory and have that one executed (by "make") ?
Yes, by doing what it says to do. Editing the configure.ac file and running autogen.sh creates a new configure script and creates the Makefile.in files from the Makefile.am files. Then when you run configure it creates the Makefile files from the Makefile.in files. Then you run 'make' and it will compile anything that needs to be compiled. If bzfs/bzadmin/etc have already been built, it won't recompile them. It will just compile what has changed.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 8:21 pm
by SkillDude
When compiling, you may also choose to compile this way:

Code: Select all

g++ -I /path/to/bzflag/include -shared -o plugin.so plugin.cpp
Place required header files in /path/to/bzflag/include and the plugin should compile if all dependencies are there. Usually I copy over the plugin_utils headers as those are useful.

I can only say that this is the easiest way to compile a plugin, however it does have some issues and requires more understanding of the g++ utility to function in more advanced environments. Simple one file plugins should compile easily this way though.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 8:23 pm
by JeffM
You would also need additional commands if you need to link in other libraries such as our plugin_utils.

But yes it is totally possible, just not the default way for our build system.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 9:14 pm
by Beardy
sigonasr2 wrote:When compiling, you may also choose to compile this way:

Code: Select all

g++ -I /path/to/bzflag/include -shared -o plugin.so plugin.cpp
Place required header files in /path/to/bzflag/include and the plugin should compile if all dependencies are there.
You mean the same ones as are named at the top of the source-file on the "#include" lines, or are there more that absolutily need to be there ?
sigonasr2 wrote:Simple one file plugins should compile easily this way though.
Thats all I'm currently looking for, so thank you. :-)

Beardy.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 9:26 pm
by Beardy
JeffM wrote:You would also need additional commands if you need to link in other libraries such as our plugin_utils.
Any chance you might tell me which commands those are ? Remember, I'm a novice at both Linux as well as GCC ...
JeffM wrote:But yes it is totally possible, just not the default way for our build system.
Thanks. A default method is OK als long as it works. In my case it doesnt quite do that (small test-changes causing long compile-times), so I do think an alternate method is called for.

Re: Beginners plugin compile problems

Posted: Thu Feb 23, 2012 10:34 pm
by JeffM
I do not know the exact commands, I am not a fan of makefiles. I believe it uses the -l switch but you'd have to check on that.

The builds should not be long doing the normal way, since it should only build your plugin after a full build. Is it actually building more then just your plugin after a full build? If so let us know because that is possibly a bug in the build system, or something missing on your compiler install.

Re: Beginners plugin compile problems

Posted: Sat Feb 25, 2012 5:24 pm
by Beardy
JeffM wrote:I do not know the exact commands, I am not a fan of makefiles. I believe it uses the -l switch but you'd have to check on that.
OK, thanks.
JeffM wrote:The builds should not be long doing the normal way, since it should only build your plugin after a full build.
It does. Its just that all that checking takes quite a while, especially on a single-core , 1GHz (read: slow) machine I'm doing it on. Apart from that, (small) temporary test-changes do not need to be propagated to the rest of the code until I'm ready for it.
Is it actually building more then just your plugin after a full build?
That ofcourse depends. If I'm only changing the plugins .cxx file than no, only the plugin gets actualy rebuild. But if-and-when I add something to an include-file (which only affects my plugin) due to dependencies a lot more is (unnecessarily) rebuild.
JeffM wrote:If so let us know because that is possibly a bug in the build system,
As far as I can see there is no bug in the reuild-system, its just that it rebuils several things when I, as a human, know its not needed.
JeffM wrote:or something missing on your compiler install.
:-) Thats something I will probably never know I'm afraid.