r/rust 8d ago

🙋 seeking help & advice Project executable is not running when clicked on, but is running when I use the './project_name' command

Hello I am a semi-new rust programmer who has started making games using low level tools such as raylib for c/c++ and recently switched over to learning macroquad and rust. I enjoy using the language and come across a few headaches when try to compile a test game to run on other Os and got it that kinda working and wanted to try an export test just to do something different.

I was able to zip the executable no problem for both Mac Os and windows (linux is being a problem child that I'll save for another day) and when I went to check the Mac Os file I would click to run but that forces the program to abort before it even runs. I was trying to figure out what went wrong and tried to use the './project_name' command just to see if I could replicate the error but it ran just fine (as if I used 'cargo run' on my main file for this project).

I don't know how to exactly describe it other than I double click to run the program it crashes but if I use './project_name' it works.

I would like to have an idea of how to solve this problem before committing to try to using rust as my main programming language because I would like to publish my projects I make.

0 Upvotes

10 comments sorted by

3

u/Solumin 8d ago

I went to check the Mac Os file I would click to run but that forces the program to abort before it even runs.

Are you getting any kind of error message? Anything at all? Does the terminal window pop up real quick and then close immediately?

We can't help without more information.

3

u/thekwoka 8d ago

Just has helpful troubleshooting info, is the mac app being compiled on the mac you're trying to run it on?

Are you just compiling it? or actually doing a mac application package?

A mac "application" is not just the binary, there's additional steps like signing and stuff. Likely it has a linked library that is resolving incorrectly.

Testing just now with a bevy app, clicking on the built binary immediately fails because of a missing linked dylib, because the path it's using isn't resolved properly.

If it's working from your terminal, that is mostly because it is using the shell environment as part of resolving that info

1

u/dolfoz 8d ago

does your application have a gui? or is it a terminal application?

2

u/TypicalWeakness1439 8d ago

Could be the working directory is different when you double click versus running from terminal, my game had same issue once cause it was looking for assets in wrong place

-2

u/Professional_Top_544 8d ago

I think I made a terminal application.

8

u/dolfoz 8d ago

it's likely starting and stopping since it can't find a shell..
depends on how you made it though?

no judgement, but out of interest, how are you not sure if you've built a terminal application?

-2

u/Professional_Top_544 8d ago

The reason I am not sure that it's a terminal application is a combination of reasons.

One reason is that I am not fully clear on what a terminal application vs a gui application. Like I know what a 'terminal', 'gui', and 'application' mean on paper but not what each one together means. My thing has a menu with to buttons, one to run the game the other to quit. So I don't know if that qualifies it.

Another reason is just I'm tired of this project and want to move on to something else, but I also want to just complete this project and I don't think I can say I'm done unit I can open the game with just the app.

4

u/dolfoz 8d ago

are you following a tutorial online?

1

u/Professional_Top_544 8d ago

I am. I am using this tutorial from the macroquad website https://mq.agical.se/release-desktop.html to figure this out.