Beginners plugin compile problems

Questions or HOWTOs about the above? Post 'em here...
Post Reply
Beardy
Private First Class
Private First Class
Posts: 50
Joined: Tue Nov 22, 2011 2:33 pm

Beginners plugin compile problems

Post by Beardy » Thu Feb 23, 2012 3:25 pm

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

User avatar
blast
General
General
Posts: 4672
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Beginners plugin compile problems

Post by blast » Thu Feb 23, 2012 4:33 pm

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.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image

Beardy
Private First Class
Private First Class
Posts: 50
Joined: Tue Nov 22, 2011 2:33 pm

Re: Beginners plugin compile problems

Post by Beardy » Thu Feb 23, 2012 5:55 pm

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") ?

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5172
Joined: Fri Dec 13, 2002 4:11 am
Location: [Redacted]
Contact:

Re: Beginners plugin compile problems

Post by JeffM » Thu Feb 23, 2012 5:59 pm

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.

User avatar
blast
General
General
Posts: 4672
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Beginners plugin compile problems

Post by blast » Thu Feb 23, 2012 6:02 pm

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.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image

User avatar
SkillDude
Private First Class
Private First Class
Posts: 336
Joined: Sun Apr 01, 2007 4:50 pm
Location: United States

Re: Beginners plugin compile problems

Post by SkillDude » Thu Feb 23, 2012 8:21 pm

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.

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5172
Joined: Fri Dec 13, 2002 4:11 am
Location: [Redacted]
Contact:

Re: Beginners plugin compile problems

Post by JeffM » Thu Feb 23, 2012 8:23 pm

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.

Beardy
Private First Class
Private First Class
Posts: 50
Joined: Tue Nov 22, 2011 2:33 pm

Re: Beginners plugin compile problems

Post by Beardy » Thu Feb 23, 2012 9:14 pm

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.

Beardy
Private First Class
Private First Class
Posts: 50
Joined: Tue Nov 22, 2011 2:33 pm

Re: Beginners plugin compile problems

Post by Beardy » Thu Feb 23, 2012 9:26 pm

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.

User avatar
JeffM
Staff Sergeant
Staff Sergeant
Posts: 5172
Joined: Fri Dec 13, 2002 4:11 am
Location: [Redacted]
Contact:

Re: Beginners plugin compile problems

Post by JeffM » Thu Feb 23, 2012 10:34 pm

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.

Beardy
Private First Class
Private First Class
Posts: 50
Joined: Tue Nov 22, 2011 2:33 pm

Re: Beginners plugin compile problems

Post by Beardy » Sat Feb 25, 2012 5:24 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest