Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Compiling problem  (Read 2251 times)

0 Members and 2 Guests are viewing this topic.

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Compiling problem
« on: August 20, 2014, 04:02:05 pm »
So, when I compile file in Linux whenever I try to run it by double clicking it opens, but no fonts, images nor sounds are loaded. I can run it via terminal ./[file name] and everything works fine. Is that normal?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Compiling problem
« Reply #1 on: August 20, 2014, 04:14:52 pm »
"Normal" depends; intended yes.
Your file manager set a different working directory when you start an application through it.
What OS and file manager are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Compiling problem
« Reply #2 on: August 20, 2014, 06:59:01 pm »
"Normal" depends; intended yes.
Your file manager set a different working directory when you start an application through it.
What OS and file manager are you using?
Elementary OS and i think its called pantheon files.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Compiling problem
« Reply #3 on: August 20, 2014, 07:18:13 pm »
As has already been pointed out; your problem is related to your programs cwd (current working directory).
There are ways on all OS's that I've worked with (except for AiX) to discover the directory where your current executable is located -so you can use that to change your working directory in your app to somewhere relative to that, so you know where to find your resources.
On Linux you can read /proc/self/exe and on Windows you can call GetModuleFileName(). OS X, FreeBSD, Solaris, and others, have similar facilities.
Also look up the functions getcwd() and chdir().

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Compiling problem
« Reply #4 on: August 20, 2014, 10:17:48 pm »
Made bug report to the eOS team. Using nautilus file manager solved my problem.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Compiling problem
« Reply #5 on: August 20, 2014, 10:30:11 pm »
Why do you believe there's a bug in the file manager???

I'd say the bug is in your application not being able to deal with an unexpected cwd when launched.
The same problem could be shown by simply doing:
cd /tmp && /path/to/your/app. Nothing to do with the environment; everything to do with your app not dealing properly with the cwd not being what it expects - which is easy to overcome and a quite basic thing about launching a process.
« Last Edit: August 20, 2014, 10:41:09 pm by Jesper Juhl »

paupav

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • Email
Re: Compiling problem
« Reply #6 on: August 20, 2014, 10:36:20 pm »
Thats a missing feature.
He said that I should still report it.
https://plus.google.com/101997050734870587600/posts/W75TzUnjEAy