Search code examples
cexecutablesdl-2double-click

Can't run SDL2 executable by double-click


Hello :)

I am presently learning SDL2, and I made several programs with it. With these programs, when I double-click on the executable, the program launches, and everything is okay. On the last program I made, it doesn't work anymore. With this one, I can only launch from terminal. The exe has the permissions, so theres no reason for this to happen...

The only thing I changed is that the old generic function file I used (for things like "loadTextureFromImage()"...) to a dynamic library I created. Here's a link to the entire project (just a white window for now) -> RightHere.

I'm currently running Ubuntu 14.04.

If you have any idea on why it doesn't work just for THIS project, tell me please!

Thank you in advance ;)

PS : Here's a project that actually works -> RightHere

PS2 : The projects are in c


Okay, so I did ldd ./myprog, and the libraries linked are where I put them, in "${HOME}/lib". If I understood well, you are telling me that because these libraries aren't in "/usr/lib and so on...", they won't be found, and I should write a script. There's a little thing I forgot to tell : I had to add an environment variable in my .bashrc -> export LD_LIBRARY_PATH=${HOME}/lib, so that the libraries are found at compile-time. Because of what you said, I think that this variable is only loaded in terminals, isn't it? So I tried two scripts :

#!/bin/bash

LD_LIBRARY_PATH=$PWD

./myprog

(like you told) and

#!/bin/bash

LD_LIBRARY_PATH=${HOME}/lib

./myprog

(like I made in my .bashrc).

When I run them by double-clicking on them, neither work. But, when I run them from terminal, only the second one works.

Thank you for the answer, hope it'll help...

EDIT : I confirm that the variable set in .bashrc are only loaded in terminals : I tested this script ->

#!/bin/bash

echo $LD_LIBRARY_PATH > Run.log

LD_LIBRARY_PATH=${HOME}/lib

echo $LD_LIBRARY_PATH >> Run.log

./Pong

and, when I run it from terminal, Run.log contains this :

/home/yohan/lib /home/yohan/lib,

but, when I run it from double-click, it only contains

*newline* /home/yohan/lib


Solution

  • Add export before your variable setting. – keltar

    Okay so thank you VERY much, it works now, with this script :

    #!/bin/bash
    
    export LD_LIBRARY_PATH=${HOME}/lib
    
    ./myprog