Author Topic: Code::Blocks command line requires to export DISPLAY  (Read 11066 times)

Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Code::Blocks command line requires to export DISPLAY
« on: June 19, 2008, 04:57:02 pm »
I am using Code::Blocks to develop programs that run on both Win32 and Linux.
Then I have two developpment environment, both with Code::Blocks, so that I can switch from one to the other depending on the developpement/debugging issues.
This is perfect, really :-)

Now the bad point...
Sometimes, I just do a simple change on the windows environment, and just want to recompile on the Linux one. I could move to the linux box and log in, but I would rather SSH to it, and do a command-line build. It is far easier and, if I don't need to edit the code, I don't need the graphical environement either.
BUT when I do it, Code::Blocks returns an error saying :

ERROR: Unable to iitialize gtk, is DISPLAY set properly ?

And I cannot go further.

If I use the exact same command line on windows, or on the linux box after login in the X server, then no problem, the build is done. But it opens the build log window, which is probably why I had the error.
Finally, if I install cygwin's X server on my windows box and export the display to it, the build can be done...

This is a problem for me, because my team is preparing to use a build server for the team work, and this build server will not have an X server installed. Then this mean I would not be able to make it build my Code::Blocks projects.
Would it be possible to add an option on command line that says : "I don't want ANY window to get opened" or something like that ?

Regards,
LittleJawa

Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Re: Code::Blocks command line requires to export DISPLAY
« Reply #1 on: July 07, 2008, 11:27:39 am »

 I have retrieved C::B source code and looked at it.
 It seems that separating the graphical part from the build part of C::B is really complicated... All the main classes of C::B are derived from wxWidget classes, so it is not possible to load a small subset of the application without having to load/initialize a graphical display of some sort...
 Then having the batch build work on command line though SSH (without X export) is impossible with the current shape of the project.

 I am in the process of locating what part of C::B I would need to get an external build executable that could interprete C::B project files and do the exact same build... Not sure it is feasable :-(
 The next option is to export my projects settings to Makefiles, but this is something that must be automated anyway.
 If anyone can give me advice or ideas, you're welcome.

Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Re: Code::Blocks command line requires to export DISPLAY
« Reply #2 on: October 27, 2009, 11:17:23 am »

 I am raising this toppic again, because I have a real need for a "unattended" build.

 My problem actually appears on both Linux and Windows. When I want to use a build software to make scheduled, unattended build, the build process (that calls codeblocks on commandline) is launched by a service. This service have no display (neither on Windows or Linux). On Linux, this makes the process exit. On windows, it just hangs.

 I have tried to set the commandline option that removes the splash screen, but it doesn't help : CodeBlocks' batch process tries to display the log in a new window whatever you do, and it seems to be the cause of the problem.
 On Linux, I was able to cheat by creating a fake X server (using Xvfb) and redirecting the session's DISPLAY to it, but on Windows, I have no clue of what I can do to make the unattended build :-(

 Does anyone have done this successfully ? Do you have any idea I should try ?
 I really appreciate the use of CodeBlocks, but if I fail to use it for builds, I'll have to return to Makefile and the like, with different behavior/setup for each OS, and I really don't want it anymore :-(

 Any help is appreciated.

 Regards,
 Little Jawa

zabzonk

  • Guest
Re: Code::Blocks command line requires to export DISPLAY
« Reply #3 on: October 27, 2009, 11:32:16 am »
Couldn't you simply run an X server on your Windows box? I've been doing that for years. There are a lot of such servers available - google for "windows x server" for a list.

Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Re: Code::Blocks command line requires to export DISPLAY
« Reply #4 on: October 27, 2009, 12:41:00 pm »
Couldn't you simply run an X server on your Windows box? I've been doing that for years. There are a lot of such servers available - google for "windows x server" for a list.

How do you make CodeBlocks use an X server on the windows host ?
The windows version of CodeBlocks uses Windows display, how do you change that ?
All the X servers that I've seen on Windows allow you to get the remote display of a linux/unix machine, but I don't remember seeing them display the GUI of a windows app...

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code::Blocks command line requires to export DISPLAY
« Reply #5 on: October 27, 2009, 01:03:08 pm »
It's not an easy task to change this, because of the use of wxwidgets-classes that are not in wxbase.

I just created a patch that makes it work (only tested on linux), but it was/is an ugly hack with tons of ifdefs and nearly not to maintain.

Splitting C::B in a gui- and a non-gui-part is a really hard job, even if it would be good to have it.

It's still in my mind, but there are so many other things to do.
« Last Edit: October 27, 2009, 01:05:39 pm by jens »

zabzonk

  • Guest
Re: Code::Blocks command line requires to export DISPLAY
« Reply #6 on: October 27, 2009, 01:21:47 pm »
> How do you make CodeBlocks use an X server on the windows host ?

Set the DISPLAY variable on the Linux box to the IP address or name of the Windows box running the X server.

> The windows version of CodeBlocks uses Windows display, how do you change that ?

I wasn't suggesting you do that - I suggested you allowed the Linux CB instance  to use the Windows display via an X server.

> All the X servers that I've seen on Windows allow you to get the remote display of a linux/unix machine.

It actually works the other way round - the X client (i.e CB) on the Linux box uses the Windows X server.


Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Re: Code::Blocks command line requires to export DISPLAY
« Reply #7 on: October 27, 2009, 01:30:42 pm »
> How do you make CodeBlocks use an X server on the windows host ?

Set the DISPLAY variable on the Linux box to the IP address or name of the Windows box running the X server.

> The windows version of CodeBlocks uses Windows display, how do you change that ?

I wasn't suggesting you do that - I suggested you allowed the Linux CB instance  to use the Windows display via an X server.

> All the X servers that I've seen on Windows allow you to get the remote display of a linux/unix machine.

It actually works the other way round - the X client (i.e CB) on the Linux box uses the Windows X server.




Well... Ok, but that is already solved. I'm using Xvfb on the linux box. This is a "fake" X server. I just redirect the linux box's DISPLAY to it, and CodeBlocks is fine.

My problem here is that the Windows version of CodeBlocks hangs when I run it from a service (typically: a build software).
This makes unattended builds on the WINDOWS host impossible to make...
And I can't redirect the windows' display to anything else, as far as I can tell.

Thanks for the suggestion anyway.

Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Re: Code::Blocks command line requires to export DISPLAY
« Reply #8 on: October 27, 2009, 01:33:54 pm »
It's not an easy task to change this, because of the use of wxwidgets-classes that are not in wxbase.

I just created a patch that makes it work (only tested on linux), but it was/is an ugly hack with tons of ifdefs and nearly not to maintain.

Splitting C::B in a gui- and a non-gui-part is a really hard job, even if it would be good to have it.

It's still in my mind, but there are so many other things to do.

Well... I had a look at CodeBlocks' code and came to the same conclusion : lot of work, and probably not something that I could try by myself since I know nothing on CodeBlocks internals :-(
I just hoped someone would have found a workaround on this, or could come with a great idea that I did not already have...

Could you provide me your patch, just so that I can try it on Windows ?
I understand it should not make it to your development's trunk, but if it can solve my problem today, it would at least buy me some time to find another workaround...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks command line requires to export DISPLAY
« Reply #9 on: October 27, 2009, 01:40:09 pm »
I understand it should not make it to your development's trunk, but if it can solve my problem today, it would at least buy me some time to find another workaround...
Notice that this patch solves the "issue" (it's not really an issue though for an IDE) that Code::Blocks needs an X-Server, e.g. when run remotely. It does not solve the issue if the app you are developing needs an X-Server to run. Which is IMHO the case for you.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline LittleJawa

  • Single posting newcomer
  • *
  • Posts: 7
Re: Code::Blocks command line requires to export DISPLAY
« Reply #10 on: October 27, 2009, 02:29:05 pm »

 My app does not need an X server.
 My problem is that CodeBlocks needs a display (X or not) when I use it on command line for a batch build.
 Under Linux, I can work around that, so I do not need a specific build for that.
 My problem is on Windows, where I don't know any workaround that would help me make CodeBlocks batch build work when launched from a service that runs outside of a logged user's session.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code::Blocks command line requires to export DISPLAY
« Reply #11 on: October 27, 2009, 02:44:42 pm »
Could you provide me your patch, just so that I can try it on Windows ?

The patch is against a much older version then actual trunk, so it will most likely not apply out of the box.
But I can have a look into it.