Difference Between Environment Variables set in Cmake build and 'CMake Application' Configuration

已回答

Hello,

I have two questions, if you would bear with me.

Question 1:

I am using CLion, and I would set some extra directories in LD_LIBRARY_PATH to provide locations for .so libraries that my binary uses during runtime. In the 'File' menu under 'Build, Execution, Deployment > CMake > (selecting a profile, eg. debug) > Environment, I am able to export a certain LD_LIBRARY_PATH. However, that does not provide the binaries with the correct library paths to find .so files in.

On the other hand, under 'Edit Configurations' on the right side of the UI I am able to export LD_LIBRARY_PATH under Environment variables for each binary, and that would work. 

I had thought that the Env variables under 'Build, Execution, Deployment' applied for all binaries in the project, and the Env variable setting under 'Edit Configurations' applied to only one binary/ However my surmise proved to be wrong, what is the difference between the two?

Question 2:

Under 'Edit Configurations' while exporting LD_LIBRARY_PATH I have tried adding variables such as '/$HOME/CLionProjects/test/extra_dir/:$LD_LIBRARY_PATH' but that didn't work. Referring to this, '/$USER_HOME$/CLionProjects/test/extra_dir/:$LD_LIBRARY_PATH' worked. Are we able to add environment variables as input to the environment variables we append to? Aka, is it possible to make '/$HOME/CLionProjects/test/extra_dir/:$LD_LIBRARY_PATH' work?

0

Hello!

1. Environment variables from File | Settings | Build, Execution, Deployment | CMake are passed to CMake generation, i.e. they are used during the CMake project loading - https://www.jetbrains.com/help/clion/cmake-profile.html#EnvVariables.

Environment variables from a run/debug configuration are used when the configuration is launched (during running or debugging process) - https://www.jetbrains.com/help/clion/run-debug-configuration.html#add-environment-variables.

2. Looks like https://youtrack.jetbrains.com/issue/CPP-15061. Feel free to comment or upvote the issue. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

 

1

Understood, thank you!

 

0

请先登录再写评论。