Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am on a brand new 5.1 NetBSD box.

I copied the "Hello World" code from here rosettacode.org

The code compiles with this command:

cc -I /usr/X11R7/include -L /usr/X11R7/lib -lX11 helloworld.c

When I run a.out, I get the following error:

Shared object "libX11.so.6" not found

I confirmed that /usr/X11R7/lib/libX11.so.6 does exist.

ldd output:

    -lX11.6 => not found
    -c.12 => /usr/lib/libc.so.12

How do I properly link against X11 on NetBSD?

share|improve this question
up vote 2 down vote accepted

The official NetBSD answer is to use RPATH. Crazy.

share|improve this answer
I should have mentioned I am still a C novice. I had come across that link before posting my question, but wasnt quite sure what I was looking at. Appending -R /usr/X11R7/lib worked, thanks man! – Mad Rapper X May 8 '12 at 5:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.