Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting LD_LIBRARY_PATH environment variable #616

Closed
dhiraj113 opened this issue Apr 7, 2017 · 11 comments
Closed

Setting LD_LIBRARY_PATH environment variable #616

dhiraj113 opened this issue Apr 7, 2017 · 11 comments
Labels
debugger more info needed The issue report is not actionable in its current state

Comments

@dhiraj113
Copy link

dhiraj113 commented Apr 7, 2017

I am unable to set LD_LIBRARY_PATH environment variable on Ubuntu 16.04 for executable run through vscode. I am using the below launch.json configuration for setting the environment variable.

"environment": [
                {
                    "name": "LD_LIBRARY_PATH",
                    "value": "<path>"
                }
            ],
@pieandcakes
Copy link
Contributor

@dhiraj113 can you paste your entire launch.json please?

@dhiraj113
Copy link
Author

Below is my launch.json file

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/dhiraj/opt/sst-core/bin/sst",
            "args": ["/home/dhiraj/Code/SST/sst-elements/src/sst/elements/memHierarchy/tests/sdl5-1-ramulator"],
            "stopAtEntry": true,
            "cwd": "/home/dhiraj/Run/vscode",
            "environment": [
                {
                    "name": "LD_LIBRARY_PATH",
                    "value": "/home/dhiraj/Code/SST/sst-elements/external/ramulator"
                }
            ],
            "externalConsole": true,
            "linux": {
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        },
        {
            "name": "C++ Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "enter program name, for example ${workspaceRoot}/a.out",
            "processId": "${command.pickProcess}",
            "linux": {
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        }
    ]
}

@shoutrain
Copy link

@dhiraj113 just want to know have you solved this or not and how?

@Elemental239
Copy link

Have same problem with Visual Studio 2017 and open-folder feature. Any solution?

@pieandcakes
Copy link
Contributor

pieandcakes commented Oct 11, 2018

@Elemental239 if you enable logging, you should be able to see that we send the command to gdb using -interpreter-exec console "set env <name> <value> during the start up.

To see logging in Visual Studio 2017, go to the Command Window and enter Debug.MIDebugLog /On /OutputWindow and you'll see it all in the output window.

In VS Code it is done by adding "logging": { "engineLogging": true } in launch.json

@duzeev
Copy link

duzeev commented Mar 20, 2020

relative path example

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) mtclient",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/mtclient/obj-linux/debug/mtclient",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}/mtclient",
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${LD_LIBRARY_PATH}:${workspaceFolder}/libbase/obj-linux/debug:${workspaceFolder}/lib1/obj-linux/debug"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

asialasr pushed a commit to asialasr/vscode-cpptools that referenced this issue Mar 12, 2021
)

* Fix for hang with VS on gdb error message

* Hang was because gdb on MinGW/Cygwin would send ^error but not flush.
Fix is to send additional newline at the end of every command if we are
running local launch on gdb on windows

* Fix for error messages during continue or step showing useless message
in VS. Fix is to catch the exceptions instead of letting it go through,
return the actual exception's message and send E_ABORT

* Code review Feedback
@aleksas
Copy link

aleksas commented May 14, 2021

At least for debugger the only way I was able to set LD_LIBRARY_PATH was by passing it to gdb via cmake.debugConfig.setupCommands:

"setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            },
            {
                "description": "Additional libs for gdb",
                "text": "set environment LD_LIBRARY_PATH=${workspaceFolder}/<rel_path>:${workspaceFolder}/<other_rel_path>:$LD_LIBRARY_PATH",
                "ignoreFailures": false
            }
        ]

@CoeusK
Copy link

CoeusK commented Jun 29, 2021

I have tried like this in tcsh
{
"name": "LD_LIBRARY_PATH",
"value": "/library/path:${DUMMYNAME}"
}
It works with an setenv warning. You could verify this in gdb with "set env“ command.

@Osyotr
Copy link

Osyotr commented Dec 16, 2021

If anyone found this while searching on how to set LD_LIBRARY_PATH for gdbserver in Visual Studio, here you go:
"preDebugCommand": "export LD_LIBRARY_PATH=/home/me/.vs/MyProject/vcpkg_installed/x64-linux/debug/lib:$LD_LIBRARY_PATH"

@callahanp
Copy link

callahanp commented Dec 25, 2021

I found that the "environment" section of launch.json on Lubuntu 21.10 worked differently than on 21.04.
In 21.04 I had LD_LIBRARY_PATH defined relative to the location of the executable. I had to change this in 21.10 to locate built shared libraries relative to the workspace folder of the project containing the executable.

The following is what I am using.

"environment": [
            {
                "name": "FG_ROOT",
                "value": "${workspaceFolder}/../fgdata"
            },
            {
                "name": "LD_LIBRARY_PATH",
                "value": "${workspaceFolder}/../install/simgear/lib:${workspaceFolder}/../install/openscenegraph/lib"
            }

I'm filing this one under "Go Figure".

@Rick1Chen
Copy link

This way worked after change default terminal from tcsh to bash
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${LD_LIBRARY_PATH}:${workspaceFolder}/libbase/obj-linux/debug:${workspaceFolder}/lib1/obj-linux/debug"
}
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debugger more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

10 participants