User forums > Using Code::Blocks

commandline build with no gui

(1/3) > >>

devd:
Im using putty on a remote ubuntu box. I work on a project which is using codeblocks project/workspace files.

Im trying to get codeblocks to work in console mode, is there a way not to display the gui build-log window ? So it will
compile on a machine without x-windows ?

so far this is what I get :
codeblocks --rebuild --target="Debug" test.workspace --no-splash-screen

Regards 

Jenna:
No.

cacb:
This would in fact be extremely useful if it worked.

In the past I used to use Visual Studio with large workspaces/many projects with interdependencies. We always did the nightly build as command line builds without IDE GUI, using the workspace file. Something similar would be nice with Code::Blocks in my opinion.... as Code::Blocks is now my preferred IDE   :D

thomas:
It won't work in the foreseeable future, though. The application uses wxWidgets components which depend on other components that require the whole GUI stuff. While it is theoretically possible to build wxWidgets without GUI, it is not possible to build Code::Blocks with such a build.
I remember we tried (maybe 2 years ago) to implement a console-only mode with normal wxWidgets linkage that simply didn't create any windows, hoping it might just work. However, this was not successful. I forgot the actual reason why it didn't work, but the complications were of such nature that we dropped the idea entirely.

cacb:

--- Quote from: thomas on December 11, 2008, 12:27:57 pm ---It won't work in the foreseeable future, though. The application uses wxWidgets components which depend on other components that require the whole GUI stuff. While it is theoretically possible to build wxWidgets without GUI, it is not possible to build Code::Blocks with such a build.
I remember we tried (maybe 2 years ago) to implement a console-only mode with normal wxWidgets linkage that simply didn't create any windows, hoping it might just work. However, this was not successful. I forgot the actual reason why it didn't work, but the complications were of such nature that we dropped the idea entirely.

--- End quote ---

I realise the original poster asked for a build without GUI, and I appreciate that it may not be easy to do.

However, there are situations such as this where it would be desirable to run C::B as if it was a console application, even though it is obviously a full-blown GUI application. I just did a small experiment using a wxWidgets dialog based GUI app, to see if I could make it behave like a console application when command line parameters were provided, and I could do it quite easily. I realise the code below is Windows only, but I imagine it wouldn't be impossible to do the same thing on Linux?


--- Code: ---#include "DateTimeApp.h"

//(*AppHeaders
#include "DateTimeMain.h"
#include <wx/image.h>
//*)

#include <iostream>
#include <fstream>
using namespace std;

IMPLEMENT_APP(DateTimeApp);

bool DateTimeApp::OnInit()
{
   bool wxsOK = true;
   if(wxApp::argc > 1) {

      // If command line arguments are given, we run as if we are in console mode
      // Example is MSW specific

      AttachConsole(ATTACH_PARENT_PROCESS);  // <== MS WINDOWS API CALL
      ifstream conin("con"); //input/output to the console
      ofstream conout("con");
      cout.rdbuf(conout.rdbuf()); //attach standard stream objects to console
      cerr.rdbuf(conout.rdbuf()); //(if you don't use cerr and clog you can of course leave them out)
      clog.rdbuf(conout.rdbuf());
      cin.rdbuf(conin.rdbuf());

      //now you can use regular cout/cin I/O as if in a console
      std::cout << "Hello GUI World" << std::endl;

      FreeConsole(); // <== MS WINDOWS API CALL
      wxsOK = false;
   }
   else {

       //(*AppInitialize
       wxInitAllImageHandlers();
       if ( wxsOK )
       {
         DateTimeDialog Dlg(0);
         SetTopWindow(&Dlg);
         Dlg.ShowModal();
         wxsOK = false;
       }
   }

   //*)
   return wxsOK;

}
--- End code ---

So what you have above, is a small example of a wxWidgets GUI application that behaves as a GUI application when no command line parameters are present, and as a console application when command line parameters are present. Obviously, it could be made to react to a certain command line parameter for console mode use.

So a suggestion might be to consider this technique for the standard C::B GUI build, so that we could build workspaces from the command line without starting the GUI.

Again, I realise this may be slightly different that what the OP asked for, but anyway.

Navigation

[0] Message Index

[#] Next page

Go to full version