Hi, i think sudo kills the LD_LIBRARY_PATH variable.
But this is configurable, try something like: Defaults env_keep += “LD_LIBRARY_PATH" in /etc/sudoers and / or consult the sudo man page. Best regards, Michael > On 24. Jun 2019, at 18:48, Nitish Saboo <nitish.sabo...@gmail.com> wrote: > > Hi , > > I am using cgo in this project where I need the following given .so files. > After building the go code, I get the binary 'main'. > > ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ ls -lrt > total 17000 > -rwxr-xr-x 1 parsing parsing 17405424 Jun 24 11:14 main > > './main' works fine whereas 'sudo ./main' throws the following error: > > ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ sudo ./main > ./main: error while loading shared libraries: libsyslog-ng-3.6.so.0: cannot > open shared object file: No such file or directory > > Following is the LD_LIBRARY_PATH set to: > -------------------------------------------------------------- > ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ echo $LD_LIBRARY_PATH > > /opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib/syslog-ng:/opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib > > > ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ cd > /opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib/ > ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib$ > ls -lrt > total 2544 > -rwxr-xr-x 1 parsing parsing 861259 Jun 24 11:14 libsyslog-ng.so > -rwxr-xr-x 1 parsing parsing 1405 Jun 24 11:14 libsyslog-ng.la > -rwxr-xr-x 1 parsing parsing 861259 Jun 24 11:14 libsyslog-ng-3.6.so.0.0.0 > -rwxr-xr-x 1 parsing parsing 861259 Jun 24 11:14 libsyslog-ng-3.6.so.0 > drwxr-xr-x 2 parsing parsing 4096 Jun 24 11:25 pkgconfig > drwxr-xr-x 3 parsing parsing 4096 Jun 24 11:25 syslog-ng > > Parsing user details: > ================= > > ubuntu@hexint09-ingest-0693b91d:~$ cat /etc/passwd | grep parsing > parsing:x:1004:1006::/home/parsing: > > ubuntu@hexint09-ingest-0693b91d:~$ cat /etc/group | grep parsing > parsing:x:1006: > > > makefile: > ======= > > .PHONY: all clean > > all: main > > main:./lib/syslog-node.so main.go ./lib/syslog-node1.h > go build -v -x main.go > > ./lib/syslog-node.so: ./lib/syslog-node.c ./lib/syslog-node1.h > gcc -L/usr/local/lib -lsyslog-ng -o ./lib/syslog-node.so > -L/usr/local/lib/syslog-ng -ldbparser -c `pkg-config --libs --cflags > glib-2.0` -I/usr/local/include/syslog-ng/ -I./lib/syslog-ng-3.6.2/ > -I/usr/local/include/eventlog/ ./lib/syslog-node.c > > clean: > rm main > rm ./lib/syslog-node.so > > > I understand I am missing a very small point here but couldn't just figure it > out. > Can someone please guide me here ? > > > Thanks, > Ntiish > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/3cc0a8f8-8b39-4948-9084-55a0b6628399%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 2scale GmbH, Schanzenstr. 20, 40549 Düsseldorf Amtsgericht: Düsseldorf HRB 50718 Geschäftsführer: Georg von Zezschwitz, Dirk Vleugels USt-IdNr.: DE 210936505 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/E4EFBEC1-40E7-452F-B2BC-68BECE7C7AA0%402scale.net. For more options, visit https://groups.google.com/d/optout.