Sierra Chart Linux Development Environment Setup

Setting up a Linux development environment for Sierra Chart was never more easier. 2020 is upon us and Linux matured even further while there are plenty of tools out there to assist us!

Scroll to the end of this page if you want to watch a detailed video of the setup or go directly to youtube.

Install VSCodium

Easiest code editor to use that comes packed with everything we need is Microsoft’s Visual Code, due to privacy concerns though and specifically the telemetry features it has by default, I switched to VScodium which is a “clean” build of Visual Code delivered by the community. You can use either of them if you follow this howto.

If you are on Ubuntu enter the following commands on your terminal, otherwise just follow the instructions on their website on how to install it.

wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | sudo apt-key add -
echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' | sudo tee --append /etc/apt/sources.list.d/vscodium.list
sudo apt update && sudo apt install codium

Install Compiler & Debugger

In order to compile a C++ DLL that then we can use either on a native Windows installation or for our example, under WINE, we will use the compiler provided by the MinGW project. On Ubuntu install compiler and debugger by using the following command

sudo apt install gdb-mingw-w64 g++-mingw-w64-x86-64

The question that comes to mind now is how we will debug a Windows program running under WINE while we are back on our Linux desktop environment.

I tested several solutions and I came down to use a Windows 64 bit build of the gdbserver.exe that listens for remote connections. This way we can connect to that instance even if it is running on a remote computer, also this solution was the most stable on my tests.

Fetch the binaries directly from win-builds.org and extract them into a directory that you will create inside the Sierra Chart WINE bottle.

DLL Compile Script

For automating the compile process and unloading/loading of a DLL into an already running Sierra Chart instance I created sc_build_dll.bash a simple bash script, there are no other dependencies for this script to run. Make sure to edit and modify the variables for your own specific setup.

VSCodium configuration

You are going to need to install the Microsoft C/C++ Extension.

Next you need to open Sierra Chart source directory and create/update the following files under .vscode directory. Make sure to change the paths to match your environment.

file: c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/cpp",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        },
        {
            "name": "SierraChart",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/x86_64-w64-mingw32/include/**",
                "/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/include/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/cpp",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

file: launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
        "name": "WINE debugging",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerServerAddress": "127.0.0.1:8888",
            "miDebuggerPath": "/usr/bin/x86_64-w64-mingw32-gdb",
            "program": "/home/unixmaniac/Bottles/SierraChart/drive_c/SierraChart/SierraChart_64.exe",
            "cwd": "${workspaceFolder}",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },
    ]
}

file: tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "SC Build",
            "command": "/home/unixmaniac/Documents/sierrachart-misc-files/sc_build_dll.bash",
            "args": [
                "build",
                "${file}",
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
        {
            "type": "shell",
            "label": "SC Debug Build",
            "command": "/home/unixmaniac/Documents/sierrachart-misc-files/sc_build_dll.bash",
            "args": [
                "build_debug",
                "${file}",
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

Start Debug Server Inside WINE

Open a windows command prompt using your WINE Prefix where Sierra Chart is installed. Execute taskmgr to open the Windows task manager to help your find the process ID of Sierra Chart by checking the PID Column, exit the task manager and locate the gdbserver.exe file and run the following command to start it up

gdbserver.exe --multi :8888 --attach <PID number>

gdbserver is now listening for incoming connections on port 8888. You can now switch back to VSCodium and start debugging.

Watch the whole process of setting up a Linux development environment for Sierra Chart