0

When I compile my test application in CLion with gcc 6.2, it outputs

/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found

Which is obvious, since I am using gcc 4.8 as system compiler, and gcc 6.2 resides in my home folder, and compiled program is using my system libs.

Obvious solution here is to use LD_PRELOAD, which is working fine, when I am running my compiled app via console.

The question: What shall I put into CMakeList.txt in CLion, so, when I click "Run" in CLion - my compiled app executes as "LD_PRELOAD=something ./myApp" instead of just "./myApp"

Starl1ght
  • 4,422
  • 1
  • 21
  • 49
  • See https://stackoverflow.com/questions/41979148/clion-cant-find-shared-library-when-running-an-executable – trozen Jun 14 '19 at 15:47

2 Answers2

1

Well, helped myself. Added environment variable in build configuration for project in CLion. enter image description here

Starl1ght
  • 4,422
  • 1
  • 21
  • 49
0

When I compile my test application in CLion with gcc 6.2, it outputs

I guess you mean "when I run my test application". That happens because your app was linked to newer version of libstdc++ but can only find older one at startup.

What shall I put into CMakeList.txt in CLion, so, when I click "Run" in CLion - my compiled app executes as "LD_PRELOAD=something ./myApp" instead of just "./myApp"

You either need to run your app with modified LD_LIBRARY_PATH (so that it points to 6.2's libstdc++, not 4.8's) or build with custom rpath:

 gcc -Wl,-rpath=/path/to/new/libstdc++ ...
yugr
  • 19,769
  • 3
  • 51
  • 96