From: neil on
I am wanting to work through Francis Glassborow book to learn c++. I am
restricted to using a unix machine (Freebsd)and codeblocks IDE.

I am configuring my system and have compiled the fgw library etc.

This is the simple playpen program that I tried to do first:

-----------------------
#include "playpen.h"
#include <iostream>

int main(){
fgw::playpen blank;
std::cout << "Please press the 'ENTER' key";
std::cin.get();
}

It compiles with no errors or warnings. The problem comes it seems when
its time to 'build' and link - this is the error stream I get:

-----------------------------------
Linking console executable: bin/Release/helloworld
/usr/local/lib/libX11.a(ClDisplay.o)(.text+0xbd): In function
`XCloseDisplay':
: undefined reference to `xcb_disconnect'
/usr/local/lib/libX11.a(OpenDis.o)(.text+0x3f9): In function
`OutOfMemory':
: undefined reference to `xcb_disconnect'
/usr/local/lib/libX11.a(OpenDis.o)(.text+0x7aa): In function
`XOpenDisplay':
: undefined reference to `xcb_get_setup'
/usr/local/lib/libX11.a(OpenDis.o)(.text+0xd4c): In function
`XOpenDisplay':
: undefined reference to `xcb_get_maximum_request_length'
/usr/local/lib/libX11.a(xcb_disp.o)(.text+0xa4): In function
`_XConnectXCB':
: undefined reference to `xcb_parse_display'
/usr/local/lib/libX11.a(xcb_disp.o)(.text+0x161): In function
`_XConnectXCB':
: undefined reference to `xcb_connect_to_display_with_auth_info'
/usr/local/lib/libX11.a(xcb_disp.o)(.text+0x17f): In function
`_XConnectXCB':
: undefined reference to `xcb_get_file_descriptor'
/usr/local/lib/libX11.a(xcb_disp.o)(.text+0x1a6): In function
`_XConnectXCB':
: undefined reference to `xcb_generate_id'
/usr/local/lib/libX11.a(xcb_disp.o)(.text+0x1e7): In function
`_XConnectXCB':
: undefined reference to `xcb_connection_has_error'
/usr/local/lib/libX11.a(xcb_disp.o)(.text+0x213): In function
`_XConnectXCB':
: undefined reference to `xcb_connect'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x393): In function
`require_socket':
: undefined reference to `xcb_take_socket'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x40c): In function
`wait_or_poll_for_event':
: undefined reference to `xcb_wait_for_event'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x46d): In function
`wait_or_poll_for_event':
: undefined reference to `xcb_poll_for_event'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x55a): In function
`process_responses':
: undefined reference to `xcb_poll_for_reply'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x669): In function
`process_responses':
: undefined reference to `xcb_connection_has_error'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x7cc): In function `_XAllocIDs':
: undefined reference to `xcb_generate_id'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0x83d): In function `_XIDHandler':
: undefined reference to `xcb_generate_id'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0xa73): In function `_XSend':
: undefined reference to `xcb_writev'
/usr/local/lib/libX11.a(xcb_io.o)(.text+0xc2b): In function `_XReply':
: undefined reference to `xcb_wait_for_reply'
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 0 warnings
____________________________________

My linker settings are:
/home/neil/tutorial/fgw_headers/libfgw.a
/usr/local/lib/libX11a
/usr/lib/libpthread.a

for what its worth i just added to compiler search directories
/usr/local/include/
/home/neil/tutorial/fgw_headers

but it does not seem to make a difference.

Please help me.
From: neil on


I have fixed the problem now. I added to the linker - all of the
libraries in /usr/local/lib and it compiled and built and ran. the only
problem was that the program ended up as 3mb - when its only a few lines.
It also took a long time to compile. I then started to eliminate - by
guess the libraries that i thought were not needed.

basically these are the six paths that are in my linker: (im not sure
that all of them are necessary, but at least it works now)
/home/neil/tutorial/fgw_headers
/usr/local/lib/libX11.a
/usr/lib/libpthread.a
/usr/local/lib/libX11.so
/usr/local/lib/libX11-xcb.a
/usr/local/lib/libX11-xcb.so

also under the 'search directories' I have
/usr/local/include/
/home/neil/tutorial/fgw_headers

It would still be nice if I could cut linked libraries down to the bare
essentials. It would be even nicer if i could understand all this.
From: Geoff on
On Fri, 25 Jun 2010 11:28:23 +0000 (UTC), neil <invalid(a)invalid.net>
wrote:

>
>
>I have fixed the problem now. I added to the linker - all of the
>libraries in /usr/local/lib and it compiled and built and ran. the only
>problem was that the program ended up as 3mb - when its only a few lines.
>It also took a long time to compile. I then started to eliminate - by
>guess the libraries that i thought were not needed.
>
>basically these are the six paths that are in my linker: (im not sure
>that all of them are necessary, but at least it works now)
>/home/neil/tutorial/fgw_headers
>/usr/local/lib/libX11.a
>/usr/lib/libpthread.a
>/usr/local/lib/libX11.so
>/usr/local/lib/libX11-xcb.a
>/usr/local/lib/libX11-xcb.so
>
>also under the 'search directories' I have
>/usr/local/include/
>/home/neil/tutorial/fgw_headers
>
>It would still be nice if I could cut linked libraries down to the bare
>essentials. It would be even nicer if i could understand all this.

It would appear that Glassborow's header file, playpen.h is bringing
in a lot of other stuff your short program doesn't need. I've never
played with his code so this is about as far as I can help.
From: Francis Glassborow on
Geoff wrote:
> On Fri, 25 Jun 2010 11:28:23 +0000 (UTC), neil <invalid(a)invalid.net>
> wrote:
>
>>
>> I have fixed the problem now. I added to the linker - all of the
>> libraries in /usr/local/lib and it compiled and built and ran. the only
>> problem was that the program ended up as 3mb - when its only a few lines.
>> It also took a long time to compile. I then started to eliminate - by
>> guess the libraries that i thought were not needed.
>>
>> basically these are the six paths that are in my linker: (im not sure
>> that all of them are necessary, but at least it works now)
>> /home/neil/tutorial/fgw_headers
>> /usr/local/lib/libX11.a
>> /usr/lib/libpthread.a
>> /usr/local/lib/libX11.so
>> /usr/local/lib/libX11-xcb.a
>> /usr/local/lib/libX11-xcb.so
>>
>> also under the 'search directories' I have
>> /usr/local/include/
>> /home/neil/tutorial/fgw_headers
>>
>> It would still be nice if I could cut linked libraries down to the bare
>> essentials. It would be even nicer if i could understand all this.
>
> It would appear that Glassborow's header file, playpen.h is bringing
> in a lot of other stuff your short program doesn't need. I've never
> played with his code so this is about as far as I can help.

Please keep in mind that playpen is a very basic graphics facility
entirely designed to make learning more enjoyable. It is not intended to
be efficient just simple to use. The original implementation was for
Windows based machines but made as portable as possible/reasonable. The
Unix version (sitting on top of X11) was provided by a friend (actually
the original was done by another friend). Note that the application is
multi-threaded even though the reader need know nothing about that.
From: neil on
Out of curiousity what does multi threading mean here?