DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 3rd June 2009
SunSpyda SunSpyda is offline
Port Guard
 
Join Date: Mar 2009
Posts: 20
Thanked 0 Times in 0 Posts
Default Xlib - Strange location?

My *second* C library question today

So as well as checking out socket programming on OpenBSD, I was looking at X programming. I wanted to test a few examples on the net, all of which tell me to include this files -

Code:
#include <X11/Xlib.h>
On OpenBSD however, it's located -
Code:
/usr/X11R6/include
Is this the standard location for these libraries, or has OpenBSD located them in a non standard location?

I don't mind using the OpenBSD locations, but wouldn't this make the source unportable to other *nixes that have the xlibs in the standard directory?
Reply With Quote
  #2   (View Single Post)  
Old 3rd June 2009
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

Quote:
Originally Posted by SunSpyda View Post
Is this the standard location for these libraries, or has OpenBSD located them in a non standard location?
Well, no, since the part that's in your code: #include <X11/Xlib.h>
is portable.

The path where X11 resides can be either part of the build setting/environment or can be specified as a gcc option (-I).
Reply With Quote
  #3   (View Single Post)  
Old 3rd June 2009
SunSpyda SunSpyda is offline
Port Guard
 
Join Date: Mar 2009
Posts: 20
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by ephemera View Post
Well, no, since the part that's in your code: #include <X11/Xlib.h>
is portable.
Yeah, but OpenBSD doesn't work with that - Sorry if I didn't explain that. That's what I would like to use - but that isn't where OpenBSD puts it, so it won't work.

To get it to work under OpenBSD it would have to be instead -

Code:
#include "/usr/X11R6/include"
Which isn't, to my knowledge, portable.
Reply With Quote
  #4   (View Single Post)  
Old 3rd June 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

#include <X11/Xlib.h> is portable, the local version of GCC simply doesn't look in /usr/X11R6, which was the default path on all Unix-like systems prior to the modularization of Xorg R7, OpenBSD retains this for portability reasons!

Developers can utilize pkg-config(1) or simply pass the proper -I, -L and -l arguments to GCC.

Please do a little more research before posting.
Reply With Quote
  #5   (View Single Post)  
Old 3rd June 2009
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

Leave the #include <X11/Xlib.h> as it is and add this option to gcc when compiling:

gcc -I /usr/X11R6/include -L /usr/X11R6/lib prog.c -lX11

Last edited by ephemera; 3rd June 2009 at 08:12 PM.
Reply With Quote
  #6   (View Single Post)  
Old 3rd June 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

It's also possible to do things like: #include <Xlib.h> and gcc -I/usr/X11R6/include/X11 .... or where ever the path to Xlib.h and friends are.

If <X11/Xlib.h> is portable enough when adjusted for the correct paths, then it's likely better to use that; as you've been directed.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange lib problem mururoa FreeBSD General 3 1st August 2009 07:34 AM
The location of Backup files from portupgrade paul-lkw FreeBSD Ports and Packages 4 21st September 2008 05:53 PM
Location for CVSup supfile. bsdnewbie999 OpenBSD General 5 26th June 2008 11:32 AM
location for wpi-firmware-.tgz bsdnewbie999 OpenBSD General 1 18th June 2008 04:20 AM
Both versions installing in same location, & can't delete jaymax FreeBSD General 5 9th June 2008 06:25 PM


All times are GMT. The time now is 07:54 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick