• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Linux - how to create an executable?

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,597
Hi folks,

getting my feet wet in Linux Mint so I can create a distribution myself.
So far I am able to compile and run any app within Cerberus X on Linux Mint. The problem I have is....
I can not start the apps on their own via a double click in the desktop "finder aka explorer".
The file type says unknown and the icon is different from the apps that shipped with CX.
The permissions state that their are able to executed.

So I am missing a step but I don't know which one.
 
So I am missing a step but I don't know which one.
You're going to have to pass the -no-pie options flag to gcc to get it to work via the file browser. It a know issue for third-party applications that don't use desktop launchers.
 
Thanks, and I here I thought that the rebuildall.sh script does that. And so the make scripts for GLFW.
 
From GCC 6 on wards the default is to build all executable's as Position Independent Executable's, which are not detected by the current file browsers. So either a open desktop launcher has to be created, or a bash launch script, or use the -no-pie option on the gcc command line.

File browsers usually see PIE's as shared libraries.
 
Does the -no-pie option preserves this?
No. It builds them as normal executable's without address space layout randomisation.

Are apps runable on other peoples machines?
As long as they use the current versions of the standard run times they should run just fine, albeit without the extra security that you get with PIE compiled code.
 
I thought I would do a bit of checking on the Ubuntu side of things and came across an article from last year that the maintainers of the Nautilus file browser are dropping the ability to launch binaries and scripts. So for Ubuntu the end user would have to use the command line to launch Cerberus unless they use one of the alternative file browsers.
 
So for Ubuntu the end user would have to use the command line to launch Cerberus unless they use one of the alternative file browsers.
Ouch, I guess they would love to go back to terminal days. Why use a gui at all?!?! :oops:
 
Ouch, I guess they would love to go back to terminal days. Why use a gui at all?!?! :oops:
I use linux fedora 28, then I installed Cerberus, I was running Cerberus through the terminal, but then, I was researching how to create those menus for the application to appear in the linux start menu, I discovered that you create a file with the extension * .desktop and in my case, they are in the folder "/ usr / share / applications"
What I did was in this case, copy the contents of this file and create a file named cerberus.desktop and changed the data to point to my executable file.
See, for example, the file that I changed to point to my Cerberus executable:
[fabiuz@fedora curso_reactjs]$ cat /usr/share/applications/cerberus-x.desktop [Desktop Entry] Version=1.0 Name=cerberus GenericName=Integrated Development Environment GenericName[pt]="Ambiente de Desenvolvimento Integrado" Comment=Desenvolva aplicativos pra Android, IOS, Flash e Desktop usando Cerberus-X Exec=/opt/Cerberus/Cerberus %F TryExec=/opt/Cerberus/Cerberus Icon=Cerberus StartupNotify=true Terminal=false Type=Application Categories=Development X-Desktop-File-Install-Version=0.23
To create those menus, there is a specification to create such menus, in my case, I simply copy a file with the extension * .desktop and changed the data, I did not have time to read it to you how it works, the link is:
 
Ouch, I guess they would love to go back to terminal days. Why use a gui at all?!?!
GUI's are a bit of an after thought on Linux, the real money is in the server side where a GUI isn't always required.

The general trend for Canonical was to make Ubuntu usable for a number of devices. I think that they got the idea that they were going to corner the market with the emerging notebook and touch screen frenzy a few years back. They tried to simplify the user interface for users who could barely use a mouse. The problem was they built it on top of all the baggage and problems that Linux has and forced you have to use the command line to install the tools to fix it.

Note: freedesktop is only supported on the major distributions with full desktop environments, such as Ubuntu, Mint, Debian, Fedora and SUSE.

The guide I wrote for Monkey has info on how to create a desktop entry, associate files and icons.
 
Last edited:
But the last distribution you provided doesn't have these, right?
The last official Cerberus X build for Linux I did was just the standard tar.gz file with no additional files for deployment set up.
When it comes to deploying on Linux it can get complicated when trying to support a number of distributions. But for distributions with freedesktop specs, the section in the guide called fun stuff will still work.

I'll have a go at porting over a tool that I wrote in bash script over to python that should make creating self extracting deployment files. It's original purpose was to distribute precompiled applications.
 
I was just trying to replicate your stuff. But the files I compiled turned out to be shared-libs instead of programs. The -no-pie option helped.
Still have to tackle Ted and Qt5. It complains about missing webengine, but I will get there. Eventually :)
 
I've looked into a possible launcher solution on Linux that should work regardless if an application was created as a PIE.
It uses six files:
  1. A couple of 48x48 icons in png format and the same icons in svg format.
  2. A small set up script
  3. A desktop entry file
You will need two 48x48 png image files placed into the bin directory. Name them
cerberus-app-icon.png for the one to represent the launcher
cerberus-file-icon.png for the one to represent a Cerberus source file.
cerberus-app-icon.svg for the one to represent the launcher
cerberus-file-icon.svg for the one to represent a Cerberus source file.

Create a shell script with the name given and set it's execute permission.
Code:
#!/bin/bash

# A SIMPLE SETUP SCRIPT FOR CERBERUS X ON LINUX DISTRIBUTIONS THAT SUPPORT THE FREE DESKTOP SPECIFICATIONS

# Set come constants
# GET THIS SCRIPST DIRECTORY
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
APP_ICON_FILE="cerberus-app-icon"
MIME_ICON_FILE="cerberus-file-icon"
DESKTOP_NAME="com.krautapps.cerberus.desktop"

# These are for the mime type entry
MIME_COMMENT="Cerberus-X File"
MIME_GLOB="*.cxs"

# Default locations in the users home directory
USER_APP_DIR="$HOME/.local/share/applications"
USER_ICON_DIR="$HOME/.local/share/icons/hicolor"
USER_MIME_DIR="$HOME/.local/share/mime"
USER_SCALABLE_DIR="$HOME/.local/share/icons/hicolor/scalable"

MIME_FILE_TYPE="application/x-CerberusX"

# Maksure that the executable permission is set for the desktop entry file
chmod +x "$DIR/$DESKTOP_NAME"

# message function
function msg(){
    echo "$1"
    echo
}

function update(){
    # Check and run each database tool
    if hash "$1" 2>/dev/null; then
        echo "Running $1 $2"
        $1 "$2"
    fi
}

function install(){
# Set up the launchers for the menu and desktop
msg "Updating MimeType and Icon for $DIR/$DESKTOP_NAME"
sed -i "s,^MimeType=.*,MimeType="$MIME_FILE_TYPE\;,g"" "$DIR/$DESKTOP_NAME"
sed -i "s,^Icon=.*,Icon="$APP_ICON_FILE,g"" "$DIR/$DESKTOP_NAME"

msg "Making directory $USER_APP_DIR"
mkdir -p "$USER_APP_DIR"

msg "copying $DIR/$DESKTOP_NAME to $USER_APP_DIR/$DESKTOP_NAME"
cp "$DIR/$DESKTOP_NAME" "$USER_APP_DIR/$DESKTOP_NAME"

msg "Updating Exec for $USER_APP_DIR/$DESKTOP_NAME"
sed -i "s,Exec=.*,Exec="$DIR/Cerberus",g" "$USER_APP_DIR/$DESKTOP_NAME"

if [ -d "$HOME/Desktop" ]; then
    msg "copying $USER_APP_DIR/$DESKTOP_NAME to $HOME/Desktop/$DESKTOP_NAME"
    cp "$USER_APP_DIR/$DESKTOP_NAME" "$HOME/Desktop/$DESKTOP_NAME"
fi

# Copy over the icons
msg "Making directory $USER_ICON_DIR"
mkdir -p "$USER_ICON_DIR/48x48/apps"
mkdir -p "$USER_SCALABLE_DIR/apps"
mkdir -p "$USER_SCALABLE_DIR/mimetypes"

# PNG
msg "$DIR/bin/$APP_ICON_FILE.png to $USER_ICON_DIR/48x48/apps/$APP_ICON_FILE.png"
cp "$DIR/bin/$APP_ICON_FILE.png" "$USER_ICON_DIR/48x48/apps/$APP_ICON_FILE.png"

msg "copying $DIR/bin/$MIME_ICON_FILE.png to $USER_ICON_DIR/48x48/apps/$MIME_ICON_FILE.png"
cp "$DIR/bin/$MIME_ICON_FILE.png" "$USER_ICON_DIR/48x48/apps/$MIME_ICON_FILE.png"

# SVG
msg "$DIR/bin/$APP_ICON_FILE.svg to $USER_SCALABLE_DIR/apps/$APP_ICON_FILE.svg"
cp "$DIR/bin/$APP_ICON_FILE.svg" "$USER_SCALABLE_DIR/apps/$APP_ICON_FILE.svg"

msg "copying $DIR/bin/$MIME_ICON_FILE.svg to $USER_SCALABLE_DIR/mimetypes/$MIME_ICON_FILE.svg"
cp "$DIR/bin/$MIME_ICON_FILE.svg" "$USER_SCALABLE_DIR/mimetypes/$MIME_ICON_FILE.svg"

# Add a mime xml file
msg "Making directory $USER_MIME_DIR/packages"
mkdir -p "$USER_MIME_DIR/packages"

# NOTE: cat not have any tab character in front of the EOT block.
msg "Adding mime file type package"
cat<<EOT > "$USER_MIME_DIR/packages/user-extension-cerberusx.xml"
<?xml version="1.0"?>
    <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
        <mime-type type="$MIME_FILE_TYPE">
        <icon name="$MIME_ICON_FILE"/>
        <comment>$MIME_COMMENT</comment>
        <comment xml:lang="en">$MIME_COMMENT</comment>
        <glob pattern="$MIME_GLOB"/>
    </mime-type>
</mime-info>
EOT

# Check and update or create the mimeapps.list file
# NOTE: cat not have any tab character in front of the EOT block.
if [ ! -f "$USER_APP_DIR/mimeapps.list" ]; then
msg "Adding new mimapps.list"
cat <<EOT > "$USER_APP_DIR/mimeapps.list"
[Default Applications]
$MIME_FILE_TYPE=$DESKTOP_NAME

[Added Associations]
$MIME_FILE_TYPE=$DESKTOP_NAME;
EOT
else
    if ! grep -q $DESKTOP_NAME "$USER_APP_DIR/mimeapps.list"; then
        msg "Adding [Default Applications] mime types to mimeapps.list"
        sed -i "/^\[Default Applications\]/a $MIME_FILE_TYPE=$DESKTOP_NAME" "$USER_APP_DIR/mimeapps.list"

        if ! grep -q "$USER_APP_DIR/mimeapps.list" -e "\[Added Associations\]"; then
            msg "Adding [Added Associations]  mime types to mimeapps.list"
            echo >> "$USER_APP_DIR/mimeapps.list"
            echo "[Added Associations]" >> "$USER_APP_DIR/mimeapps.list"
        fi
        sed -i "/^\[Added Associations\]/a $MIME_FILE_TYPE=$DESKTOP_NAME;" "$USER_APP_DIR/mimeapps.list"
    fi
fi

# Update any database
update update-mime-database "$USER_MIME_DIR"
}

function remove(){
    if [ -f "$1" ]; then
        echo "Removing $1"
        rm "$1"
    fi
}

function uninstall(){
    # Remove the icons
    remove "$USER_ICON_DIR/48x48/apps/$APP_ICON_FILE.png"
    remove "$USER_ICON_DIR/48x48/apps/$MIME_ICON_FILE.png"
    remove "$USER_SCALABLE_DIR/apps/$APP_ICON_FILE.svg"
    remove "$USER_SCALABLE_DIR/mimetypes/$MIME_ICON_FILE.svg"

    # Remove the desktop entry files
    remove "$USER_APP_DIR/$DESKTOP_NAME"
    remove "$HOME/Desktop/$DESKTOP_NAME"

    # Remove the MIME association
    remove "$USER_MIME_DIR/packages/user-extension-cerberusx.xml"

    # Remove any related info in the mimeapp.list
    if [ -f "$USER_APP_DIR/mimeapps.list" ]; then
        sed -i "/$DESKTOP_NAME/d" "$USER_APP_DIR/mimeapps.list"
    fi
    echo ""
    update update-mime-database "$USER_MIME_DIR" "$USER_APP_DIR/mimeapps.list"
}

# Stub.
if [ "$1" = "uninstall"  ]; then
    echo "Un-installing"
    uninstall
else
    echo "Installing"
    install
fi

Create a .desktop file in the Cerberus root directory with the name given and set it's execute permission.
Code:
#!/usr/bin/env xdg-open

[Desktop Entry]

Version=1.0
Type=Application
Encoding=UTF-8
Terminal=false
Exec=bash -c '_PWD="$PWD"; cd "`echo $0 | sed s/com.krautapps.cerberus.desktop$//`"; ./setup.sh; ./Cerberus %F; cd "_PWD"' %k
Icon=cerberus-app-icon
Name=Cerberus X
MimeType=application/x-CerberusX;
Categories=Development
Comment[en_GB.UTF-8]=Cerberus X Integrated Development Environment
GenericName[en_GB.UTF-8]=Create Games for HTML5 web browsers, PC desktop, Abdobe Flash and Android.
Name[en_GB]=Cerberus X

How it should work.
You navigate the the Cerberus root directory and if desktop launching is allowed in the browser, you just double click the icon named Cerberus X (the desktop entry file). It runs the setup.sh script that installs:
  • A desktop entry file to .local/share/applications and updates the execute path
  • A desktop entry file to the users desktop
  • Creates or updates the .local/share/applications/mimeapps.list
  • Creates a mime entry in .local/share/mime/packages
  • Copies the icon images to ./local/share/icons/hicolor/48x48/apps
  • Installs the mime type into the mime type database
When finished, the IDE start and you should have a desktop icon, a menu icon under the programming category, icons and launch associated with Cerberus source files. If not, just log out and back in for the changes to take affect.

If there is no way to launch from a file browser, open a terminal and navigate to the Cerberus root directory and execute the setup.sh file.

You can remove the basic set up by using the setup.sh file via the command line and passing uninstall as a parameter.

EDIT: I've updated the file as I missed something out. And I will be trying it out on a few distributions and making changes where required.
 
Last edited:
@MikeHart : If you have got the time and you have a svg version of the IDE icon. Can you update the logo resource file to include it. I can then update the the script to use scalable svg's which are supported by the free desktop specifications.
Thanks
 
Back
Top Bottom