--
________________________
Yes, I use Debian GNU/L
wolf python london(WPL)
Do as you soul should do !
________________________
> My command is:
> g++ -L/usr/pkg/X11R6/lib -lX11 -I/usr/pkg/X11R6/include main2.cpp
>
> Where -lX11 is lower-case L and -I/usr/pkg/X11R6/include is upper-case
> i.
L/usr/pkg/X11R6 --- L to tell compiler(Gcc here) to look the library
to link in this dirs;
-l/X11 --- l to tell compiler to link the libX11.a library
-I/usr/pkg/X11R6 -- I to tell compiler look the header file in this dir
You can also try pkg-config and upgrade all your packages to latest.
$g++ -o main3 main3.cpp `pkg-config --cflags --libs x11`
Here is the screenshot(http://picpaste.com/test-uZrWS14H.png)
> On Apr 21, 5:21 pm, wolf python london <lyh19901...@gmail.com> wrote:
>> On 21 April 2012 18:22, PolGraphic <polgrap...@interia.pl> wrote:> I have tried 'nm /usr/pkg/X11R6/lib/libX11.a > res.txt' and then 'grep
>> > -i "XOpenDisplay" ./res.txt' and got:
>> > 00000458 T XOpenDisplay
>> > U XOpenDisplay
>>
>> > So now I think there is XOpenDisplay in libX11.a. So why I get
>> > "undefined reference"?
>>
>> I'm not sure: it may be the problem of combination programming of c and c++.
>> It seems that c++ use a different symbol in object file.
>> My advice is:
>> 1)use gcc to compile it and better change the source file extension
>> (I mean .c). Or
>> 2) use extern "C" in the cpp source file and use g++ to compile it
>> If two ways doesn't help, plz attach your main.cpp , let's see how to
>> fix it together :-)
>>
>> > My command is:
>> > g++ -L/usr/pkg/X11R6/lib -lX11 -I/usr/pkg/X11R6/include main2.cpp
>>
>> > Where -lX11 is lower-case L and -I/usr/pkg/X11R6/include is upper-case
>> > i.
>>
>> L/usr/pkg/X11R6 --- L to tell compiler(Gcc here) to look the library
>> to link in this dirs;
>> -l/X11 --- l to tell compiler to link the libX11.a library
>> -I/usr/pkg/X11R6 -- I to tell compiler look the header file in this dir
>
int XCloseDisplay(Display *display);
ARGUMENTS
display Specifies the connection to the X server.
display_name
Specifies the hardware display name, which determines the
display and communications domain to be used. On a POSIX-
conformant system, if the display_name is NULL, it defaults
to the value of the DISPLAY environment variable.
********************
XOpenDisplay with a NULL parameter should return the pointer to a
Display structure which is the value of
the DISPLAY environment variable. So set the variable manually may not
work. I have little experience in
xlib programming . It's just a simply analysis.
BTW, this tiny code builds and works in NetBSD and Debian.
> For more options, visit this group at http://groups.google.com/group/minix3?hl=en.