How to set LD_LIBRARY_PATH to debug a cgo program


To run the binary from the command line I set this

export LD_LIBRARY_PATH=/home/dean/src/liqid.slurm.integration/liqid.conf.file.parser/c/cmake-build-debug

When running the debugger I've tried setting LD_LIBRARY_PATH in the Environment settings of the Run/Debug Configurations but it fails saying it can't find my .so library.  I've also tried setting it in the Go tool arguments, but it fails with 

can't load package: named files must be .go files: export

Can the debugger work with cgo?  If so where do I set LD_LIBRARY_PATH?


Setting the Environment seems to be the right thing to do. What IDE version are you using?


I'm using 2019.2.  I noticed that the latest version is incompatible with the Go plugin.


Am I right that you're using IntelliJ IDEA? There's a Go plugin for each IDEA version, you only need to update both of them.


Yes, I'm using IDEA.

I was able to get the debugger to work by putting the .so in /usr/local/lib and running ldconfig.  It would be better if I could set the LD_LIBRARY_PATH from IDEA though.


Hi Dean,


Sorry for the delay in following up on this.

Can you please attach a screenshot of the LD_LIBRARY_PATH from IntelliJ IDEA Ultimate?

Thank you.





Here is the listing of that directory showing that the .so file is there:

$ ls -lart /home/dean/src/liqid.slurm.integration/liqid.conf.file.parser/c/cmake-build-debug
total 108
-rw-r--r-- 1 dean dean 1595 Apr 30 10:01 cmake_install.cmake
-rw-r--r-- 1 dean dean 22994 Apr 30 10:01 CMakeCache.txt
-rw-r--r-- 1 dean dean 6624 May 1 13:41 Makefile
-rw-r--r-- 1 dean dean 9335 May 1 13:41 liqid_conf_file_parser.cbp
drwxr-xr-x 4 dean dean 4096 May 4 15:50 ..
drwxr-xr-x 3 dean dean 4096 May 4 15:50 .
-rwxr-xr-x 1 dean dean 23744 May 4 15:50 test
-rwxr-xr-x 1 dean dean 21368 May 4 15:50
drwxr-xr-x 7 dean dean 4096 May 4 15:50 CMakeFiles


If I copy the to /usr/local/lib then it works.


Dean, please try without the `export` under the `Environment` field.

The field expects values in the `Variable=Value` format. If you need to add more, then you can use `Variable=Value;Variable2=Value2` and so on.

Please let me know if this solves the issue.


Please sign in to leave a comment.