www.digitalmars.com         C & C++   DMDScript  

D.gnu - Compile X Window Manager

reply "Samms" <matesax gmail.com> writes:
Hi,
I found X.d and Xlib.d replacement for X11 library of C language. 
But it returned many errors when compiling. Some problems was in 
non-static declaration, but how can I resolve this problems:

gdc ./main.d -o Refuja
/tmp/ccysZHrg.o: In function `_Dmain':
main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
main.d:(.text+0x75): undefined reference to 
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
main.d:(.text+0x85): undefined reference to `XStringToKeysym'
main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
main.d:(.text+0xd8): undefined reference to `XGrabKey'
main.d:(.text+0xe6): undefined reference to 
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
main.d:(.text+0x155): undefined reference to `XGrabButton'
main.d:(.text+0x163): undefined reference to 
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
main.d:(.text+0x1d2): undefined reference to `XGrabButton'
main.d:(.text+0x20a): undefined reference to `XNextEvent'
main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
main.d:(.text+0x29d): undefined reference to 
`XGetWindowAttributes'
main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'

collect2: ld returned 1 exit status

Thank you.
May 19 2013
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 19 May 2013 20:58, Samms <matesax gmail.com> wrote:

 Hi,
 I found X.d and Xlib.d replacement for X11 library of C language. But it
 returned many errors when compiling. Some problems was in non-static
 declaration, but how can I resolve this problems:

 gdc ./main.d -o Refuja
 /tmp/ccysZHrg.o: In function `_Dmain':
 main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
 main.d:(.text+0x75): undefined reference to `_**
 D3std1c5linux3X114Xlib17Defaul**tRootWindowFPS3std1c5linux3X11**
 4Xlib7DisplayZm'
 main.d:(.text+0x85): undefined reference to `XStringToKeysym'
 main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
 main.d:(.text+0xd8): undefined reference to `XGrabKey'
 main.d:(.text+0xe6): undefined reference to `_**
 D3std1c5linux3X114Xlib17Defaul**tRootWindowFPS3std1c5linux3X11**
 4Xlib7DisplayZm'
 main.d:(.text+0x155): undefined reference to `XGrabButton'
 main.d:(.text+0x163): undefined reference to `_**
 D3std1c5linux3X114Xlib17Defaul**tRootWindowFPS3std1c5linux3X11**
 4Xlib7DisplayZm'
 main.d:(.text+0x1d2): undefined reference to `XGrabButton'
 main.d:(.text+0x20a): undefined reference to `XNextEvent'
 main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
 main.d:(.text+0x29d): undefined reference to `XGetWindowAttributes'
 main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'

 collect2: ld returned 1 exit status

 Thank you.
By linking in Xlib into your program. Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
May 19 2013
parent reply "Samms" <matesax gmail.com> writes:
But what option do I use? I cannot find in the manual classical 
-l... And path - absolute or relative?
May 19 2013
parent reply "Samms" <matesax gmail.com> writes:
On Sunday, 19 May 2013 at 20:28:13 UTC, Samms wrote:
 But what option do I use? I cannot find in the manual classical 
 -l... And path - absolute or relative?
And - Xlib.h or Xlib.d or...?
May 19 2013
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On May 19, 2013 9:30 PM, "Samms" <matesax gmail.com> wrote:
 On Sunday, 19 May 2013 at 20:28:13 UTC, Samms wrote:
 But what option do I use? I cannot find in the manual classical -l...
And path - absolute or relative?
 And - Xlib.h or Xlib.d or...?
You seem to be going about this the illogical way. Do you have experience writing X applications in C or C++? Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
May 19 2013
parent reply "Samms" <matesax gmail.com> writes:
Yes (I'm programmer for 7 years.), but this is not work... (-l 
Xlib.h)
May 19 2013
next sibling parent reply "Samms" <matesax gmail.com> writes:
Paths:

import std.c.linux.X11.Xlib;
import std.c.linux.X11.X;

/usr/include/d2/4.6/std/c/linux/X11
May 19 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Monday, 20 May 2013 at 03:54:47 UTC, Samms wrote:
 Paths:

 import std.c.linux.X11.Xlib;
 import std.c.linux.X11.X;

 /usr/include/d2/4.6/std/c/linux/X11
if you do such imports with 3rd party modules you could just add import search location for top level path(which in this case is /usr/include/d2/4.6), then import system find modules by packages path, also with dmd(which is at least uses gcc linker,though i might be wrong on this) you link like this "dmd file.d -L/path/to/lib.a" p.s. don't blame if this doesn't work for you as i don't use gdc, just dmd and ldc(once or so)
May 20 2013
parent reply "Samms" <matesax gmail.com> writes:
But why this command:

gdc ./main.d -o Refuja -L /usr/include/d2/4.6/std/c/linux/X11/ -l 
Xlib

not work?
May 20 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Monday, 20 May 2013 at 07:28:42 UTC, Samms wrote:
 But why this command:

 gdc ./main.d -o Refuja -L /usr/include/d2/4.6/std/c/linux/X11/ 
 -l Xlib

 not work?
i don't know gdc, but dmd is frontend so u work with frontend which pass linker flags with -L, that means if you need to tell linker "-L /some/path" try doing something like this "-L-L/some/path"(single string) or "-LL(or -L-L?) -L/some/path" may be someone more experienced can tell you the details about gdc linker options.
May 20 2013
parent reply "Samms" <matesax gmail.com> writes:
Yes - some library working with -L-L - but it not resolve 
"undefined reference to" Error,...

Are you sure, that "undefined reference to" is problem only in 
linker?
May 20 2013
parent "evilrat" <evilrat666 gmail.com> writes:
On Monday, 20 May 2013 at 08:32:44 UTC, Samms wrote:
 Yes - some library working with -L-L - but it not resolve 
 "undefined reference to" Error,...

 Are you sure, that "undefined reference to" is problem only in 
 linker?
yes. just remember if you build lib A which uses lib B and in your app you use lib A you still need link B. if you use some D lib and it complains about unresolved references there maybe a chance you miss build script for that lib which produces static lib. so, what exactly you are trying to do?
May 20 2013
prev sibling parent reply Alexandr Druzhinin <drug2004 bk.ru> writes:
20.05.2013 10:51, Samms пишет:
 Yes (I'm programmer for 7 years.), but this is not work... (-l Xlib.h)
Hmm... you ask unusual questions for a programmer with 7 year expirience. :) Try read gcc man about -l option - it says that after -l should be lib name without lib prefix (depends on OS) and .lib/.a/.so/etc suffix, IIRC. In other words just try -lxlib like: gdc ./main.d -lXlib -o Refuja
May 19 2013
parent reply "Samms" <matesax gmail.com> writes:
gdc ./main.d -o Refuja -L /usr/include/X11/ -l Xlib

Not work...
May 19 2013
parent reply "Samms" <matesax gmail.com> writes:
gdc ./main.d -o Refuja -lXlib/usr/bin/ld: cannot find -lXlib
collect2: ld returned 1 exit status

Etc. Nothing works...
May 19 2013
parent reply "Samms" <matesax gmail.com> writes:
I can really work with the linker, but here it just does not work 
... :) That is why I'm asking for such stupid things...
May 19 2013
parent reply Alexandr Druzhinin <drug2004 bk.ru> writes:
20.05.2013 12:32, Samms пишет:
 I can really work with the linker, but here it just does not work ... :)
 That is why I'm asking for such stupid things...
I didn't use gdc, so I don't know what would I do myself in this situation. :) didn't using -L-L/path/to/Xlib -L-lXlib help?
May 20 2013
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On May 20, 2013 9:45 AM, "Alexandr Druzhinin" <drug2004 bk.ru> wrote:
 20.05.2013 12:32, Samms =D0=BF=D0=B8=D1=88=D0=B5=D1=82:

 I can really work with the linker, but here it just does not work ... :)
 That is why I'm asking for such stupid things...
I didn't use gdc, so I don't know what would I do myself in this
situation. :)
 didn't using -L-L/path/to/Xlib -L-lXlib help?
H'm... gdc uses gcc style switches. So that would be -L/path/to/Xlib -lXlib. Samms, do you have the correct xlib dev packages installed? Regards --=20 Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';
May 20 2013
parent reply "Samms" <matesax gmail.com> writes:
I not have installed Xlib.d - it is overwrite of Xlib.h for D 
language...

"in your app you use lib A you still need link B"

I'm not idiot...

"Samms, do you have the correct xlib dev packages installed?"

I'm not idiot...

"So that would be -L/path/to/Xlib -lXlib."

gdc ./main.d -o Refuja -L/usr/include/X11/ -lXlib
/usr/bin/ld: cannot find -lXlib
collect2: ld returned 1 exit status

And last:

gdc ./main.d -o Refuja -L-L/usr/include/X11/ -L-lXlib
/tmp/ccN5ul41.o: In function `_Dmain':
main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
main.d:(.text+0x75): undefined reference to 
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
main.d:(.text+0x85): undefined reference to `XStringToKeysym'
main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
main.d:(.text+0xd8): undefined reference to `XGrabKey'
main.d:(.text+0xe6): undefined reference to 
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
main.d:(.text+0x155): undefined reference to `XGrabButton'
main.d:(.text+0x163): undefined reference to 
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
main.d:(.text+0x1d2): undefined reference to `XGrabButton'
main.d:(.text+0x20a): undefined reference to `XNextEvent'
main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
main.d:(.text+0x29d): undefined reference to 
`XGetWindowAttributes'
main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
collect2: ld returned 1 exit status

"so, what exactly you are trying to do?"

Title this post: "Compile X Window Manager"

That I would want to create X Window Manager?
May 20 2013
next sibling parent reply Alexandr Druzhinin <drug2004 bk.ru> writes:
20.05.2013 22:29, Samms пишет:
 I not have installed Xlib.d - it is overwrite of Xlib.h for D language...

 "in your app you use lib A you still need link B"

 I'm not idiot...

 "Samms, do you have the correct xlib dev packages installed?"

 I'm not idiot...

 "So that would be -L/path/to/Xlib -lXlib."

 gdc ./main.d -o Refuja -L/usr/include/X11/ -lXlib
 /usr/bin/ld: cannot find -lXlib
 collect2: ld returned 1 exit status

 And last:

 gdc ./main.d -o Refuja -L-L/usr/include/X11/ -L-lXlib
 /tmp/ccN5ul41.o: In function `_Dmain':
 main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
 main.d:(.text+0x75): undefined reference to
 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'

 main.d:(.text+0x85): undefined reference to `XStringToKeysym'
 main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
 main.d:(.text+0xd8): undefined reference to `XGrabKey'
 main.d:(.text+0xe6): undefined reference to
 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'

 main.d:(.text+0x155): undefined reference to `XGrabButton'
 main.d:(.text+0x163): undefined reference to
 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'

 main.d:(.text+0x1d2): undefined reference to `XGrabButton'
 main.d:(.text+0x20a): undefined reference to `XNextEvent'
 main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
 main.d:(.text+0x29d): undefined reference to `XGetWindowAttributes'
 main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
 collect2: ld returned 1 exit status

 "so, what exactly you are trying to do?"

 Title this post: "Compile X Window Manager"

 That I would want to create X Window Manager?
You should build Xlib.d also and use correct path to library (your is wrong) like: gdc ./main.d path/to/Xlib.d -o Refuja -L-L/usr/lib/X11/ -L-lXlib /usr/include/Xlib point to headers, not to libraries it would be better to use something like above - I'm on windows now, can't say exactly.
May 20 2013
next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 20 May 2013 17:00, Alexandr Druzhinin <drug2004 bk.ru> wrote:
 20.05.2013 22:29, Samms =D0=BF=D0=B8=D1=88=D0=B5=D1=82:

 I not have installed Xlib.d - it is overwrite of Xlib.h for D language..=
.
 "in your app you use lib A you still need link B"

 I'm not idiot...

 "Samms, do you have the correct xlib dev packages installed?"

 I'm not idiot...

 "So that would be -L/path/to/Xlib -lXlib."

 gdc ./main.d -o Refuja -L/usr/include/X11/ -lXlib
 /usr/bin/ld: cannot find -lXlib
 collect2: ld returned 1 exit status

 And last:

 gdc ./main.d -o Refuja -L-L/usr/include/X11/ -L-lXlib
 /tmp/ccN5ul41.o: In function `_Dmain':
 main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
 main.d:(.text+0x75): undefined reference to

 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7Disp=
layZm'
 main.d:(.text+0x85): undefined reference to `XStringToKeysym'
 main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
 main.d:(.text+0xd8): undefined reference to `XGrabKey'
 main.d:(.text+0xe6): undefined reference to

 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7Disp=
layZm'
 main.d:(.text+0x155): undefined reference to `XGrabButton'
 main.d:(.text+0x163): undefined reference to

 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7Disp=
layZm'
 main.d:(.text+0x1d2): undefined reference to `XGrabButton'
 main.d:(.text+0x20a): undefined reference to `XNextEvent'
 main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
 main.d:(.text+0x29d): undefined reference to `XGetWindowAttributes'
 main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
 collect2: ld returned 1 exit status

 "so, what exactly you are trying to do?"

 Title this post: "Compile X Window Manager"

 That I would want to create X Window Manager?
You should build Xlib.d also and use correct path to library (your is wro=
ng)
 like:
 gdc ./main.d path/to/Xlib.d -o Refuja -L-L/usr/lib/X11/ -L-lXlib
 /usr/include/Xlib point to headers, not to libraries it would be better t=
o
 use something like above - I'm on windows now, can't say exactly.
Why are people so obsessed with -L-L and -L-l switches? Oh wait... dmd... -- Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';
May 20 2013
prev sibling parent reply "Samms" <matesax gmail.com> writes:
It resolved only small part of errors:

gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja 
-L-L/usr/include/X11/ -L-lXlib
/tmp/ccFcEKHG.o: In function `_Dmain':
main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
main.d:(.text+0x85): undefined reference to `XStringToKeysym'
main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
main.d:(.text+0xd8): undefined reference to `XGrabKey'
main.d:(.text+0x155): undefined reference to `XGrabButton'
main.d:(.text+0x1d2): undefined reference to `XGrabButton'
main.d:(.text+0x20a): undefined reference to `XNextEvent'
main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
main.d:(.text+0x29d): undefined reference to 
`XGetWindowAttributes'
main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
collect2: ld returned 1 exit status
May 20 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Monday, 20 May 2013 at 16:28:09 UTC, Samms wrote:
 It resolved only small part of errors:

 gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o 
 Refuja -L-L/usr/include/X11/ -L-lXlib
 /tmp/ccFcEKHG.o: In function `_Dmain':
 main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
 main.d:(.text+0x85): undefined reference to `XStringToKeysym'
 main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
 main.d:(.text+0xd8): undefined reference to `XGrabKey'
 main.d:(.text+0x155): undefined reference to `XGrabButton'
 main.d:(.text+0x1d2): undefined reference to `XGrabButton'
 main.d:(.text+0x20a): undefined reference to `XNextEvent'
 main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
 main.d:(.text+0x29d): undefined reference to 
 `XGetWindowAttributes'
 main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
 collect2: ld returned 1 exit status
as Iain said above now you need to link x11 also
May 20 2013
parent reply "Samms" <matesax gmail.com> writes:
Hooray! :)

gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja 
-L-L/usr/include/X11/ -L-lXlib -lX11
May 20 2013
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
 Hooray! :)

 gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja
 -L-L/usr/include/X11/ -L-lXlib -lX11
Though why on earth are you still using -L-L and -L-l ? -Ldir Add directory dir to the list of directories to be searched for -l. All you are doing is adding '-L/usr/include/X11/' and '-lXlib' as search directories (hint: they very likely don't exist). Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
May 20 2013
parent reply "eles" <eles eles.com> writes:
On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
Basically, the command line should be: gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -L/usr/include/X11/ -lXlib -lX11 with the "-L/usr/include/X11/" part being almost useless (more probably, you wanted to write: "-L/usr/lib", but that should be taken into account by default. Samms, try this: gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lXlib -lX11
May 21 2013
parent reply "Samms" <matesax gmail.com> writes:
On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
Basically, the command line should be: gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -L/usr/include/X11/ -lXlib -lX11 with the "-L/usr/include/X11/" part being almost useless (more probably, you wanted to write: "-L/usr/lib", but that should be taken into account by default. Samms, try this: gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lXlib -lX11
This problem is resolved...
Hooray! :)
gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o 
Refuja -L-L/usr/include/X11/ -L-lXlib -lX11
May 21 2013
parent reply "eles" <eles eles.com> writes:
On Tuesday, 21 May 2013 at 12:36:27 UTC, Samms wrote:
 On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
This problem is resolved...
I know. I was offering a simpler solution (command line), that's all.
May 21 2013
next sibling parent "Samms" <matesax gmail.com> writes:
On Tuesday, 21 May 2013 at 12:46:35 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 12:36:27 UTC, Samms wrote:
 On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
This problem is resolved...
I know. I was offering a simpler solution (command line), that's all.
OK - thank you very much! :)
May 21 2013
prev sibling parent reply "Samms" <matesax gmail.com> writes:
On Tuesday, 21 May 2013 at 12:46:35 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 12:36:27 UTC, Samms wrote:
 On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
This problem is resolved...
I know. I was offering a simpler solution (command line), that's all.
But your code is wrong... gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lXlib -lX11 /usr/bin/ld: cannot find -lXlib collect2: ld returned 1 exit status
May 21 2013
parent reply Mike Wey <mike-wey example.com> writes:
On 05/21/2013 03:06 PM, Samms wrote:
 On Tuesday, 21 May 2013 at 12:46:35 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 12:36:27 UTC, Samms wrote:
 On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
This problem is resolved...
I know. I was offering a simpler solution (command line), that's all.
But your code is wrong... gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lXlib -lX11 /usr/bin/ld: cannot find -lXlib collect2: ld returned 1 exit status
Thats because there is no libXlib only libX11. gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lX11 Should work without any errors. -- Mike Wey
May 21 2013
next sibling parent "eles" <eles eles.com> writes:
On Tuesday, 21 May 2013 at 17:20:37 UTC, Mike Wey wrote:
 On 05/21/2013 03:06 PM, Samms wrote:
 On Tuesday, 21 May 2013 at 12:46:35 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 12:36:27 UTC, Samms wrote:
 On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
Thats because there is no libXlib only libX11.
good catch
May 21 2013
prev sibling parent reply "Samms" <matesax gmail.com> writes:
On Tuesday, 21 May 2013 at 17:20:37 UTC, Mike Wey wrote:
 On 05/21/2013 03:06 PM, Samms wrote:
 On Tuesday, 21 May 2013 at 12:46:35 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 12:36:27 UTC, Samms wrote:
 On Tuesday, 21 May 2013 at 08:35:09 UTC, eles wrote:
 On Tuesday, 21 May 2013 at 06:59:55 UTC, Iain Buclaw wrote:
 On 21 May 2013 04:58, Samms <matesax gmail.com> wrote:
This problem is resolved...
I know. I was offering a simpler solution (command line), that's all.
But your code is wrong... gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lXlib -lX11 /usr/bin/ld: cannot find -lXlib collect2: ld returned 1 exit status
Thats because there is no libXlib only libX11. gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o Refuja -lX11 Should work without any errors.
You were right.
May 21 2013
parent reply "Samms" <matesax gmail.com> writes:
Oh - no! :) Compilation is OK - but Manager not work. It is only 
overwrite od TinyWM:

import std.c.linux.X11.Xlib;
import std.c.linux.X11.X;

/* gdc ./main.d /usr/include/d2/4.6/std/c/linux/X11/Xlib.d -o 
refuja -lX11 */

int main()
{
	Display *dpy;
	XWindowAttributes attr;
	XButtonEvent start;
	XEvent ev;

	dpy = XOpenDisplay(cast(char*)0);

	if(!dpy)
		return 1;

	XGrabKey(dpy, XKeysymToKeycode(dpy, 
XStringToKeysym(cast(char*)"F1")), KeyMask.Mod1Mask, 
DefaultRootWindow(dpy),  cast(Bool)true, GrabMode.GrabModeAsync, 
GrabMode.GrabModeAsync);
	XGrabButton(dpy, 1, KeyMask.Mod1Mask, DefaultRootWindow(dpy),  
cast(Bool)true, 
EventMask.ButtonPressMask|EventMask.ButtonReleaseMask|EventMas
.PointerMotionMask, 
GrabMode.GrabModeAsync, GrabMode.GrabModeAsync, None, None);
	XGrabButton(dpy, 3, KeyMask.Mod1Mask, DefaultRootWindow(dpy), 
cast(Bool)true, 
EventMask.ButtonPressMask|EventMask.ButtonReleaseMask|EventMas
.PointerMotionMask, 
GrabMode.GrabModeAsync, GrabMode.GrabModeAsync, None, None);

	start.subwindow = None;
	
	while(true)
	{
		XNextEvent(dpy, &ev);
		
		if(ev.type == EventType.KeyPress && ev.xkey.subwindow != None)
			XRaiseWindow(dpy, ev.xkey.subwindow);
		else if(ev.type == EventType.ButtonPress && 
ev.xbutton.subwindow != None)
		{
			XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
			start = ev.xbutton;
		}
		else if(ev.type == EventType.MotionNotify && start.subwindow != 
None)
		{
			int xdiff = ev.xbutton.x_root - start.x_root,
			ydiff = ev.xbutton.y_root - start.y_root;
			
			XMoveResizeWindow(dpy, start.subwindow,
				attr.x + (start.button==1 ? xdiff : 0),
				attr.y + (start.button==1 ? ydiff : 0),
				Max(1, attr.width + (start.button==3 ? xdiff : 0)),
				Max(1, attr.height + (start.button==3 ? ydiff : 0)));
		}
		else if(ev.type == EventType.ButtonRelease)
			start.subwindow = None;
	}
}

int Max(int a, int b)
{
	return (a > b ? a : b);
}

What is the problem?
Thank you.
May 22 2013
parent reply "evilrat" <evilrat666 gmail.com> writes:
On Wednesday, 22 May 2013 at 19:07:17 UTC, Samms wrote:
 Oh - no! :) Compilation is OK - but Manager not work. It is 
 only overwrite od TinyWM:
 ...
 What is the problem?
 Thank you.
there is a little chance anyone from community used this "manager", but maybe someone skilled with x11 would help if you describe what exactly doesn't work.
May 23 2013
parent "Samms" <matesax gmail.com> writes:
The transcript of the C language immediately turns back into 
greeter screen after logging. (it show a black screen and 
immediately is closed)
May 23 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 20 May 2013 16:29, Samms <matesax gmail.com> wrote:
 "So that would be -L/path/to/Xlib -lXlib."

 gdc ./main.d -o Refuja -L/usr/include/X11/ -lXlib

 /usr/bin/ld: cannot find -lXlib
 collect2: ld returned 1 exit status
This only tells you that Xlib.so (or other name) does not exist on your system.
 And last:

 gdc ./main.d -o Refuja -L-L/usr/include/X11/ -L-lXlib
 /tmp/ccN5ul41.o: In function `_Dmain':
I've already said that gdc uses gcc switch syntax, not dmd.
 main.d:(.text+0x75): undefined reference to
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
 main.d:(.text+0xe6): undefined reference to
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
 main.d:(.text+0x163): undefined reference to
`_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
This tells you that you are not linking in the library for Xlib.d are you instead supposed to compile X.d / Xlib.d with your application?
 main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
 main.d:(.text+0x85): undefined reference to `XStringToKeysym'
 main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
 main.d:(.text+0xd8): undefined reference to `XGrabKey'
 main.d:(.text+0x155): undefined reference to `XGrabButton'
 main.d:(.text+0x1d2): undefined reference to `XGrabButton'
 main.d:(.text+0x20a): undefined reference to `XNextEvent'
 main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
 main.d:(.text+0x29d): undefined reference to `XGetWindowAttributes'
 main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
 collect2: ld returned 1 exit status
This tells you that you are not linking in the X11 library. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; On 20 May 2013 16:29, Samms <matesax gmail.com> wrote:
 I not have installed Xlib.d - it is overwrite of Xlib.h for D language...


 "in your app you use lib A you still need link B"

 I'm not idiot...


 "Samms, do you have the correct xlib dev packages installed?"

 I'm not idiot...


 "So that would be -L/path/to/Xlib -lXlib."

 gdc ./main.d -o Refuja -L/usr/include/X11/ -lXlib

 /usr/bin/ld: cannot find -lXlib
 collect2: ld returned 1 exit status

 And last:

 gdc ./main.d -o Refuja -L-L/usr/include/X11/ -L-lXlib
 /tmp/ccN5ul41.o: In function `_Dmain':

 main.d:(.text+0x3f): undefined reference to `XOpenDisplay'
 main.d:(.text+0x75): undefined reference to
 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
 main.d:(.text+0x85): undefined reference to `XStringToKeysym'
 main.d:(.text+0x9c): undefined reference to `XKeysymToKeycode'
 main.d:(.text+0xd8): undefined reference to `XGrabKey'
 main.d:(.text+0xe6): undefined reference to
 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
 main.d:(.text+0x155): undefined reference to `XGrabButton'
 main.d:(.text+0x163): undefined reference to
 `_D3std1c5linux3X114Xlib17DefaultRootWindowFPS3std1c5linux3X114Xlib7DisplayZm'
 main.d:(.text+0x1d2): undefined reference to `XGrabButton'
 main.d:(.text+0x20a): undefined reference to `XNextEvent'
 main.d:(.text+0x24c): undefined reference to `XRaiseWindow'
 main.d:(.text+0x29d): undefined reference to `XGetWindowAttributes'
 main.d:(.text+0x3f2): undefined reference to `XMoveResizeWindow'
 collect2: ld returned 1 exit status

 "so, what exactly you are trying to do?"

 Title this post: "Compile X Window Manager"

 That I would want to create X Window Manager?
-- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
May 20 2013
prev sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 20 May 2013 16:29, Samms <matesax gmail.com> wrote:
 I not have installed Xlib.d - it is overwrite of Xlib.h for D language...


 "in your app you use lib A you still need link B"

 I'm not idiot...


 "Samms, do you have the correct xlib dev packages installed?"

 I'm not idiot...
I've RTFM. http://www.dsource.org/projects/bindings/browser/trunk/X11/README --- How I use Xlib binding ? -------------------------- - add "import std.c.linux.Xlib;" to your code. - use Xlib functions like in C with some minor change: this bindings is more strongly typed than C version,it use D features when it can. so instead of writing: GC gc=XCreateGC(display,window,GCForeground | GCBackground,&values); you while need to write: GC gc=XCreateGC(display,window,GCMask.GCForeground | GCMask.GCBackground,&values); For example you will compile your code like this if you're using dmd: dmd yourfile.d Xlib.d X.d -L-lX11 (don't forget -L-lX11 ;) ) For a complete example read example.d --- So... s/dmd/gdc and you get: gdc yourfile.d Xlib.d X.d -lX11 -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
May 20 2013