compile with static library

490 views
Skip to first unread message

Albert

unread,
Oct 16, 2015, 2:24:36 AM10/16/15
to klish
Hi,

I would like to ask if it possible to compile the clish/klish with static library so that I can get an executable without shared library dependency.  Thank you.

Serj Kalichev

unread,
Oct 16, 2015, 2:46:03 AM10/16/15
to kl...@googlegroups.com
Hi

From klish documentation:
"
## Static build

To build Klish statically use:

```
$ ./configure --disable-shared
$ make LDFLAGS+="-all-static"
```
The LDFLAGS is global so shared libraries can't be build and building of shared libraries must be disabled.
"

It was written a several years ago but try it. Probably it works.


16.10.2015 09:24, Albert пишет:
Hi,

I would like to ask if it possible to compile the clish/klish with static library so that I can get an executable without shared library dependency.  Thank you.
--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Albert

unread,
Oct 16, 2015, 3:12:34 AM10/16/15
to klish
Hi ,

I did as per instruction but I got the following error.  FYI,  I am running Ubuntu 14.04 x64.


libtool: link: warning: `-version-info' is ignored for programs
libtool: link: gcc -Wall -g -O2 -static -o bin/clish bin/clish.o  ./.libs/libclish.a /home/albert/klish/.libs/libtinyrl.a /home/albert/klish/.libs/libkonf.a /usr/lib/x86_64-linux-gnu/libexpat.a ./.libs/libkonf.a ./.libs/libtinyrl.a /home/albert/klish/.libs/liblub.a ./.libs/liblub.a -ldl
./.libs/libclish.a(libclish_la-plugin.o): In function `clish_plugin_load_shared':
/home/albert/klish/clish/plugin/plugin.c:354: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/albert/klish/.libs/liblub.a(db.o): In function `lub_db_getgrgid':
/home/albert/klish/lub/db/db.c:131: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/albert/klish/.libs/liblub.a(db.o): In function `lub_db_getgrnam':
/home/albert/klish/lub/db/db.c:98: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/albert/klish/.libs/liblub.a(db.o): In function `lub_db_getpwnam':
/home/albert/klish/lub/db/db.c:32: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/albert/klish/.libs/liblub.a(db.o): In function `lub_db_getpwuid':
/home/albert/klish/lub/db/db.c:65: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
./.libs/libclish.a(libclish_la-shell_execute.o): In function `clish_shell__get_fifo':
/home/albert/klish/clish/shell/shell_execute.c:415: warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp'
make[1]: Leaving directory `/home/albert/klish'

Serj Kalichev

unread,
Oct 16, 2015, 3:16:19 AM10/16/15
to kl...@googlegroups.com
Try this:
From documentation:

## Leak of dlopen()

If target system doesn't support dlopen() then configure script will configure building process to don't use dlopen() (and other dl functions) but link to plugin's shared objects.

If you need to link statically with plugins use:

```
$ ac_cv_header_dlfcn_h=no ./configure --prefix=/usr --disable-shared
$ make LDFLAGS+="-all-static"




16.10.2015 10:12, Albert пишет:

Albert

unread,
Oct 16, 2015, 3:28:38 AM10/16/15
to klish
Hi,

Thanks for the additional info.  I did the following and it seems to be working.   Will report if there are other problems.  

$  make clean
$ ac_cv_header_dlfcn_h=no ./configure --prefix=/usr --disable-shared --with-lua=/home/albert/klish/lua
$ make LDFLAGS+=-"all-static"
Reply all
Reply to author
Forward
0 new messages