PDA

View Full Version : Missing X Library for Cimg



dejay703
December 20th, 2007, 05:15 AM
Hi everyone,

I'm fairly new to programming in ubuntu. Anyway, I am trying to work with Cimg, and I'm having problems compiling my own programs. It seems like I can compile their examples perfectly fine (running 'make linux' in their examples folder completes fine). However, when I try to compile my program, I get a lot of errors that look like the following:

main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0xe6): undefined reference to `XDestroyWindow'
main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0x15c): undefined reference to `XFreeColormap'
main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0x184): undefined reference to `XSync'
main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0x32a): undefined reference to `pthread_cancel'
main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0x354): undefined reference to `pthread_join'
main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0x3b7): undefined reference to `XSync'
main.cpp:(.text._ZN12cimg_library11CImgDisplay6ass ignEv[cimg_library::CImgDisplay::assign()]+0x3ca): undefined reference to `XCloseDisplay'

It looks like I am missing some sort of x library, but I have gone through synaptics and installed everything that I think I need. Does anyone have any suggestions?

Thanks
Jason

fulgencio
January 24th, 2008, 02:48 AM
I am having the same problems please post any solutions you can find.

Thanks

fulgencio
January 29th, 2008, 10:51 PM
I believe its a problem with the ImageMagick package but I dont know how to solve it...:(

ILoveBobbyMarley
June 19th, 2008, 02:48 PM
Had the same problem,

try

g++ -o test main.cpp -lpthread -lX11

or better still add

test_LDFLAGS = -lpthread -lX11

to your Makefile.am, so you have something like

bin_PROGRAMS = test
test_LDFLAGS = -lpthread -lX11
test_SOURCES = main.cpp

I have seen additional switches used by some, eg

g++ -o test main.cpp -O2 -L/usr/X11R6/lib -lm -lpthread -lX11

but for me the above was minimal for the hello world app.

PEACE X

JHSaunders
July 30th, 2008, 01:49 PM
Ths worked for me, thanks.

in_rainbow
August 12th, 2008, 12:08 PM
thanks so much. This worked for me too. It was driving me crazy.

ariismail
October 5th, 2008, 07:21 PM
Thank you very much!

AWittyUserName
September 6th, 2009, 05:26 PM
Very helpful. Thanks!