LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-09-2002, 10:01 PM   #1
DiscoStoo
LQ Newbie
 
Registered: Mar 2002
Distribution: Slackware 10.1
Posts: 24

Rep: Reputation: 15
How to find the directory of a binary (in C)


I've been working on this game, and I need to know exactly what directory the binary is in so I know where to find the graphics directory (which is relative to the binary). I figure there must be a function or something to do this, it's such a common thing. I can't just use argv[0] (which was suggested to me elsewhere) because if the user makes a SymLink argv[0] will give me the name and path of the SymLink, not the actual binary. Just let me know if I'm not making sense and I'll try to be more clear.
 
Old 03-22-2002, 03:29 PM   #2
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 30
there's probably an easier way to do this, but have you tried using the stat(3) commands.

Read the stat man page for more info. You can test for a symlink, but I do not know how a hard link will affect you.

The simple option is to have the graphics library configured by the user or detected at build time or detected at run tim even.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I find what directory is on what partition? mijohnst Linux - Newbie 2 10-05-2005 04:16 PM
find size of directory naijaguy Linux - Newbie 3 03-04-2005 11:11 AM
How do I find out when a directory was created? gumpish Linux - Newbie 1 09-29-2004 08:12 PM
Where can i find KDE Binary Packages for Mandrake 9.1? kromatic Mandriva 1 12-26-2003 03:25 PM
where can I find binary xmx abd_bela Linux - Software 1 12-28-2002 01:19 PM


All times are GMT -5. The time now is 11:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration