Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:46:12+00:00 2026-06-06T19:46:12+00:00

I am attempting to load some images into a very basic C++/SDL based program.

  • 0

I am attempting to load some images into a very basic C++/SDL based program. The images are loaded using SDL_LoadBMP. I have the image loading and everything seems to work perfectly. My problem is that the image is loaded relative to where I call the program from.

So I have a directory structure that goes something like this.

project/
    src/
        source.cpp
    assets/
        image.bmp
    bin/
        program

When I execute the program from the project directory (./bin/program) it has to use a path of assets/image.bmp to load the image. Is there any way I can use a relative path of ../assets/image.bmp so the program can be executed from anywhere?

I think I need something that provides the absolute path to the program that I can then append my paths to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:46:14+00:00Added an answer on June 6, 2026 at 7:46 pm

    On Linux, /proc/self/exe is a symbolic link to the executable of the current process. So you can use readlink to find its path. From there you can use usual path manipulation to find your resources. Perhaps you should cater for the case where the program executable is again a symlink to the location where your binary lies, i.e. do some more realink as long as the current path is a symlink.

    There once was a question about finding current executable’s path without /proc/self/exe which also asked about a portable interface, but no single solution that caters for all needs was given in the accepted answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to load document files into a document library in SharePoint using
I have an image that I am attempting to load, and then reload. Here
I am attempting to load some json data into a custom JQuery function. There
I am attempting to load multiple images in AS3 and I'm exploring different options
I'm attempting to load JSON (from php's json_encode) into a Backbone JS collection. I've
So I have been attempting to integrate captions and links into the Envato FlexSlider
I have recently set up a website using MODx Revolution. I am attempting to
I'm attempting to load the Highcharts library using a shim in RequireJS. However, when
I'm attempting to use selenium to automate some browser-based data entry. The target URL
I have access to some images that can be gathered like this: http://www.example.com/imageGetter.php?a=0001 If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.