Board index FlightGear Support Installation Mac

Cannot get Fightgear GUI launched from terminal on my mac  Topic is solved

Installing FlightGear, scenery, aircraft etc. on Mac.

Cannot get Fightgear GUI launched from terminal on my mac

Postby kerryS » Sun Sep 08, 2019 9:06 pm

Hi there,

My mac info:
Macbook Pro 13-inch, 2019 (bought in August 2019)
version 10.14.6
Mojave
I have xcode, qt (when type
Code: Select all
brew info qt
, it gives "qt: stable 5.13.1 (bottled), HEAD [keg-only]")installed now.


My Flightgear won't launch with the following command:
Code: Select all
fgfs

and I get error:

(base) Kerrys-MacBook-Pro:Simulation kerry$ fgfs
0.00 [INFO]:general FlightGear: Version 2019.1.1
0.00 [INFO]:general FlightGear: Build Type Release
0.00 [INFO]:general Built with GNU C++ version 4.2
0.00 [INFO]:general Jenkins number/ID 590:590
0.01 [POPU]:gui This application failed to start because it could not find or load the Qt platform plugin "cocoa"
in "/Applications/FlightGear.app/Contents/Plugin".

Reinstalling the application may fix this problem.
Abort trap: 6


But if i have directory under:
cd /Applications/FlightGear.app/Contents/MacOS/

Then I can launch it with the following:
Code: Select all
 ./fgfs


I found this thread has the similar problem, but I couldn't follow the last direction (viewtopic.php?f=21&t=36280&p=353544#p353544)... I need a step by step procedure unfortunately. :oops:

The end goal is to launch a shell with all configuration built-in already in the terminal. The shell file looks like this:

DIR=$(dirname $0)

nice fgfs \
--fg-aircraft="$DIR/aircraft" \
--aircraft=$1 \
--fdm=null \
--native-fdm=socket,in,50,,59500,tcp \
--lat=44.725801 \
--lon=-93.075866 \
--heading=90 \
--altitude=285.3 \
--disable-real-weather-fetch \
--wind=0@0 \
--turbulence=0.0 \
--disable-horizon-effect \
--timeofday=noon \
--disable-random-objects \
--disable-ai-models \
--fog-disable \
--disable-specular-highlight \
--disable-terrasync \


If I run this .sh code right now, when it hit the line with "fgfs", then it would give me the same error.

I don't know what to do.
kerryS
 
Posts: 5
Joined: Sun Sep 08, 2019 8:44 pm

Re: Cannot get Fightgear GUI launched from terminal on my ma

Postby enrogue » Sun Sep 08, 2019 9:26 pm

In the Mac App, all you need for FlightGear to work comes with it - you should just be able to double click on the app icon

It uses by default the QT libraries that come with the application
User avatar
enrogue
 
Posts: 168
Joined: Mon May 19, 2014 6:40 pm
Location: London (UK)
Callsign: enrogue
OS: OS X, Ubuntu

Re: Cannot get Fightgear GUI launched from terminal on my ma

Postby enrogue » Sun Sep 08, 2019 9:32 pm

OK, running from a shell script is a bit different - as the libraries (QT etc) are in the Application package subdirectories, you need to set some variables in the script

something like the following to start with:

Code: Select all
RUN_DIR="/Applications/FlightGear.app/Contents" # or wherever you have it installed
DYLD_LIBRARY_PATH="$RUN_DIR/Frameworks" exec $RUN_DIR/MacOS/fgfs --fg-root="$RUN_DIR/Resources/data"
User avatar
enrogue
 
Posts: 168
Joined: Mon May 19, 2014 6:40 pm
Location: London (UK)
Callsign: enrogue
OS: OS X, Ubuntu

Re: Cannot get Fightgear GUI launched from terminal on my ma

Postby kerryS » Sun Sep 08, 2019 10:35 pm

Hi enrogue,

I don't know what you mean...
So under this directory I'm currently working with, I have a file called fgfs_JSBSim.sh. This file meant to open Flightgear and be ready to talk to JSBSim. I already attached the code in my first post, but for convenience, here it is again:

Code: Select all
DIR=$(dirname $0)

nice fgfs \
    --fg-aircraft="$DIR/aircraft" \
    --aircraft=$1 \
    --fdm=null \
    --native-fdm=socket,in,50,,59500,tcp \
    --lat=44.725801 \
    --lon=-93.075866 \
    --heading=90 \
    --altitude=285.3 \
    --disable-real-weather-fetch \
    --wind=0@0 \
    --turbulence=0.0 \
    --disable-horizon-effect \
    --timeofday=noon \
    --disable-random-objects \
    --disable-ai-models \
    --fog-disable \
    --disable-specular-highlight \
    --disable-terrasync \


I also have fgfs executable available under this directory (or any directory) using the following:

Code: Select all

sudo ln -s /Applications/FlightGear.app/Contents/MacOS/fgfs /usr/local/bin



Now, when I type fgfs in this directory, it would crash. If I type:

Code: Select all
 ./fgfs_JSBSim.sh


It would also crash and give me the same error. I'm not sure where I put the code you mentioned in my sh file. Another question is that why can't I just run fgfs to open Flightgear?

Thanks!
kerryS
 
Posts: 5
Joined: Sun Sep 08, 2019 8:44 pm

Re: Cannot get Fightgear GUI launched from terminal on my ma  

Postby enrogue » Mon Sep 09, 2019 9:12 am

The flightgear 'application' on macOS is a directory with the binaries, supporting libraries (including openscenegraph & qt), and the data needed for things internal to FG. When you double click on the icon, all of the environment is setup for you.

If you run the binary from the bash shell (terminal/command line), none of this is done for you - you have to tell it where to find the libraries that came with it

You don't need to symlink fgfs into the path for instance - you should reference the correct binary path in your shell script, and similar to how you have told it where to find the aircraft directory, you need to tell it where to find the supporting libraries, and the data it needs (usually called FGDATA)

In your script above you are referencing an environment variable DIR, which is generated from dirname $0 which is the directory that the running script is in, which if you are running it with ./ is the current working directory

My additions to your script above do the following:

Code: Select all
RUN_DIR="/Applications/FlightGear.app/Contents"


Assign a variable containing the path to the Contents directory of the flightgear installation

Code: Select all
DYLD_LIBRARY_PATH="$RUN_DIR/Frameworks"


Assign a special macOS variable that tells fgfs where to the find dynamic libraries it is linked to (including OSG, QT etc) - it's using the previously assigned variable to make it shorter

Code: Select all
exec $RUN_DIR/MacOS/fgfs


execute fgfs from it's installed directory (using the variable), and replace the shell, so that it's not left running in the background - calling a binary with it's full installed path rather than relying on path variable search is good security practise for shell scripts (old habit)

Code: Select all
--fg-root="$RUN_DIR/Resources/data"


Tell fgfs where to find the FGDATA resources (it won't work without these)

So, to combine your script with my additions:

Code: Select all
RUN_DIR="/Applications/FlightGear.app/Contents"
DIR=$(dirname $0)

DYLD_LIBRARY_PATH="$RUN_DIR/Frameworks" nice exec $RUN_DIR/MacOS/fgfs \
    --fg-root="$RUN_DIR/Resources/data" \
    --fg-aircraft="$DIR/aircraft" \
    --aircraft=$1 \
    --fdm=null \
    --native-fdm=socket,in,50,,59500,tcp \
    --lat=44.725801 \
    --lon=-93.075866 \
    --heading=90 \
    --altitude=285.3 \
    --disable-real-weather-fetch \
    --wind=0@0 \
    --turbulence=0.0 \
    --disable-horizon-effect \
    --timeofday=noon \
    --disable-random-objects \
    --disable-ai-models \
    --fog-disable \
    --disable-specular-highlight \
    --disable-terrasync \
User avatar
enrogue
 
Posts: 168
Joined: Mon May 19, 2014 6:40 pm
Location: London (UK)
Callsign: enrogue
OS: OS X, Ubuntu

Re: Cannot get Fightgear GUI launched from terminal on my ma

Postby kerryS » Mon Sep 09, 2019 4:09 pm

Omg, it worked!!! Thank you so much!!!! I can open FG from sh file now.
kerryS
 
Posts: 5
Joined: Sun Sep 08, 2019 8:44 pm


Return to Mac

Who is online

Users browsing this forum: No registered users and 3 guests