Jump to content

Code::Blocks integration?


Recommended Posts

I've just started using the Code::Blocks IDE on my netbook, as it seems to run best while also leaving screen space for the actual code, and I was wondering if anyone here uses C::B for working on 0AD and would know how to set up the code as a project within it. Philip`, on IRC, mentioned the possibility of using premake to output a Code::Blocks importable makefile, but I haven't been able to find much on the subject.

Alternatively, if there's another resource-light IDE out there that would be a better fit/easier implementation of the codebase that I simply haven't checked out, suggestions are welcome.

[Note: I absolutely refuse to use Eclipse. Takes forever to load anything.]

Link to comment
Share on other sites

I've just started using the Code::Blocks IDE on my netbook, as it seems to run best while also leaving screen space for the actual code, and I was wondering if anyone here uses C::B for working on 0AD and would know how to set up the code as a project within it. Philip`, on IRC, mentioned the possibility of using premake to output a Code::Blocks importable makefile, but I haven't been able to find much on the subject.

Alternatively, if there's another resource-light IDE out there that would be a better fit/easier implementation of the codebase that I simply haven't checked out, suggestions are welcome.

[Note: I absolutely refuse to use Eclipse. Takes forever to load anything.]

Premake4 supports Code::Blocks in theory, but I doubt anyone has tested that with our build system. Basically you want to run premake4 with the "codeblocks" option to generate the workspace (see build\workspaces\update-workspaces.* for an example of how premake is invoked). I don't know what OS you're using, but in Windows I suspect you'll need to use the MSVC toolchain (not GCC which is what Premake seems to be configuring by default, I think our source makes the assumption you will only use MSVC for Windows and GCC for other OSes). I've tested opening the workspace in Code::Blocks and it looks properly structured, but the build options are configured for GCC - maybe it will work in Linux.

Link to comment
Share on other sites

I had a quick look and you can easily generate a project using premake4.

You could add a line to update-workspaces.sh (around line 69):

premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake codeblocks failed"

(If you are using windows you could add an equivalent line to update-workspaces.bat)

Edit: I just tried building and it didn't work correctly. It threw quite a lot of errors when linking.

Edited by quantumstate
Link to comment
Share on other sites

I had a quick look and you can easily generate a project using premake4.

[...]

That could work, but we had to make some changes to premake to get the other environments working and it's likely that there will be some gliches for Code::Blocks too.

If you test it, please tell us if it works.

Link to comment
Share on other sites

I had a quick look and you can easily generate a project using premake4.

You could add a line to update-workspaces.sh (around line 69):

premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake codeblocks failed"

(If you are using windows you could add an equivalent line to update-workspaces.bat)

Edit: I just tried building and it didn't work correctly. It threw quite a lot of errors when linking.

I did that and it worked perfectly for me. Granted, the project hierarchy is a bit iffy, but other than that, it works.

EDIT: When I say "perfectly", I mean it imports "perfectly" and doesn't give any errors. Compiling is another issue altogether. See the attached text file.

error.txt

Edited by mindsystem
Link to comment
Share on other sites

I seem to have figured out what the issue is, seemingly fixed by adding "/usr/lib" under "Compiler" after [Right-click pyrogenesis] > "Build options..." > "Search directories".

See the image below:

http://db.tt/aBS1eXjM

If someone running Linux can confirm this, things should be all well and good.

Edit: Turns out it only worked because I accidentally compiled most of it via terminal, so when I tried to recompile via Code::Blocks, it gave me the same errors again.

Edited by mindsystem
Link to comment
Share on other sites

Good news: (y)

I was able to successfully build using the Code::Blocks IDE.

Some manual tweaks were required, but it looks like it won't be hard to integrate them into the premake scripts.

From what I see until now, Code::Blocks looks promising and I'm going to give it a try.

Link to comment
Share on other sites

Yes, I didn't check it on Windows yet.

I guess this will be more difficult and for me it does not have priority because most Windows developers use Visual Studio anyway.

Yeah I wouldn't worry about it, the odds are that even if someone wants to use Code::Blocks as their IDE in Windows, they'd still need MSVC installed to compile, and getting all the options correct looks like a pain (I do think it's possible).

Link to comment
Share on other sites

You could also use MinGW.

If we tried to support it we would have to decide if the options in Code::Blocks should be for MinGW (GCC) or Visual Studio compiler.

I don't think there's a way to support both. Maybe I'll do some tests on Windows, but I won't finish it if It's too much work and if there's no one who actually uses it.

Link to comment
Share on other sites

If someone would like to test it or has any feedback, here's a patch for Code::Blocks support on Linux.

As yet I've only done some quick tests.

Works great on Ubuntu w/ Code::Blocks 10.05. I tried building both release and debug config, and tested the debugger feature, with no problems.

I went ahead and tested on OS X Lion too, as a possible Xcode alternative. It gives the following error when building the engine project:


/Users/Ben/0ad/source/ps/XML/RelaxNG.cpp|26|error: libxml/relaxng.h: No such file or directory

Which is strange, somehow it's not finding libxml2 includes? "locate relaxng.h" shows:


/Developer/SDKs/MacOSX10.6.sdk/usr/include/libxml2/libxml/relaxng.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/libxml2/libxml/relaxng.h
/Users/Ben/0ad/libraries/libxml2/include/libxml/relaxng.h
/usr/include/libxml2/libxml/relaxng.h
/usr/share/doc/libxml2-2.7.3/html/html/libxml-relaxng.html

This is probably a separate issue, I think you could commit your patch :)

Link to comment
Share on other sites

...

I went ahead and tested on OS X Lion too, as a possible Xcode alternative. It gives the following error when building the engine project:


/Users/Ben/0ad/source/ps/XML/RelaxNG.cpp|26|error: libxml/relaxng.h: No such file or directory

Which is strange, somehow it's not finding libxml2 includes?

...

It's a bit weird. It does not find pkg-config because /opt/local/bin is not in the PATH of the shell used to execute commands inside C::B.

There are some setting for the environment under Settings>Environment... but they don't seem to have any effect on that.

It finally worked after starting C::B from the terminal. Somehow it got the right PATH that way.

The question is how I could solve this with premake. I don't think I should use a full path to pkg-config because it could be installed elsewhere.

The only other solution I see would be executing pkg-config from premake and inserting the output directly. That's how I had to do it for Xcode.

EDIT: Committed - http://trac.wildfiregames.com/changeset/10521

Link to comment
Share on other sites

  • 3 weeks later...

I generally use Eclipse IDE with Java, C and C++ and the plugin Subclipse to work with SVN (I had to reinstall my windows because of problems with TortoiseSVN, so i'll never use it again). Eclipse has a very friendly (and configurable) interface, detects semantic and sintax errors within the code in real time, supports both windows, linux and Mac and is totally free. http://www.eclipse.o...nents/indigosr1

Edited by Pedro Falcão
Link to comment
Share on other sites

It finally worked after starting C::B from the terminal. Somehow it got the right PATH that way.

Confirmed that this works, but then it won't run the app bundle, it thinks it has never been built :(

Also Code::Blocks seems really buggy on OS X, not only the UI, but it freezes occasionally, crashes when closing, the settings don't save, etc. So I think it's not worth spending too much effort on, probably much more important to get Xcode working properly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...