Static linked programs

374 views
Skip to first unread message

oph

unread,
May 16, 2012, 7:04:01 AM5/16/12
to dislin...@googlegroups.com

What is necessary to link a program with -static option using DISLIN?

Regards,

OPH.

Helmut Michels

unread,
May 20, 2012, 8:50:43 AM5/20/12
to dislin-users
Hi,

to link a Dislin program completely static is not a good idea. Dislin
uses
the X11 library, which requires a lot of other libraries, and also an
OpenGL
library, where a static library makes no sense. What you can do is to
link
with the static Dislin library libdislin.a instead of the shareable
library libdislin.so.
For exanple:

gfortran t1.f90 /usr/local/dislin/libdislin.a -lXm -lXt -lX11 -
lGL

Additional, you can also link with the static OpenMotif library, since
OpenMotif
is not installed by default on other systems:

gfortran t1.f90 /usr/local/dislin/libdislin.a /usr/lib/libXm.a -
lXt -lX11 -lGL

Best regards,

Helmut
Message has been deleted

oph

unread,
May 21, 2012, 8:49:58 AM5/21/12
to dislin-users


On 20 mayo, 09:50, Helmut Michels <mich...@dislin.de> wrote:
> Hi,
>
> to link a Dislin program completely static is not a good idea. Dislin
> uses
> the X11 library, which requires a lot of other libraries, and also an
> OpenGL
> library, where a static library makes no sense. What you can do is to
> link
> with the static Dislin library libdislin.a instead of the shareable
> library libdislin.so.
> For exanple:
>
>      gfortran t1.f90 /usr/local/dislin/libdislin.a -lXm -lXt -lX11 -
> lGL
>
> Additional, you can also link with the static OpenMotif library, since
> OpenMotif
> is not installed by default on other systems:
>
>      gfortran t1.f90 /usr/local/dislin/libdislin.a /usr/lib/libXm.a -
> lXt -lX11 -lGL
>
> Best regards,
>
> Helmut
>

I agree. I am distributing a big program, and not all the users know
what to install to run it.

With an old version of Linux I can compile a static program, but the
new features of DISLIN are lost.

I see that is more simple to explain what must the user install
(DISLIN and libXm.so.3) that generate a static program.

Thank you.

OPH.

Helmut Michels

unread,
May 21, 2012, 9:02:13 AM5/21/12
to dislin-users
or just link static with Dislin and libXm.a as I explained in my mail
before, so that the user don't have to install Dislin and OpenMotif.

Best regards,

Helmut

hibr

unread,
Aug 8, 2012, 7:13:37 PM8/8/12
to dislin...@googlegroups.com
I also tried to compile Dislin program statically with (K)Ubuntu 12.04 64-bit. I just want that the target machines do not need to have Dislin installed.

 gfortran -o map_f90 map_f90.f90 -I/usr/local/dislin/gf /usr/local/dislin/libdislin.a /usr/lib/libXm.a -lXt -lX11 -lGL

does not work. I get:

/usr/bin/ld: cannot find -lXt
/usr/bin/ld: cannot find -lX11
/usr/bin/ld: cannot find -lGL

BTW: Shared compiling with gf95link works perfectly. I tried to locate the missing libs:

$ locate libXt
/usr/lib/i386-linux-gnu/libXt.so.6
/usr/lib/i386-linux-gnu/libXt.so.6.0.0
/usr/lib/i386-linux-gnu/libXtst.so.6
/usr/lib/i386-linux-gnu/libXtst.so.6.1.0
/usr/lib/x86_64-linux-gnu/libXt.so.6
/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0
/usr/lib/x86_64-linux-gnu/libXtst.so.6
/usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0

$ locate libX11
/usr/lib/i386-linux-gnu/libX11-xcb.so.1
/usr/lib/i386-linux-gnu/libX11-xcb.so.1.0.0
/usr/lib/i386-linux-gnu/libX11.so.6
/usr/lib/i386-linux-gnu/libX11.so.6.3.0
/usr/lib/x86_64-linux-gnu/libX11-xcb.so.1
/usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
/usr/lib/x86_64-linux-gnu/libX11.so.6
/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0

$ locate libGL
/usr/lib/libGLEW.so.1.5
/usr/lib/libGLEW.so.1.5.2
/usr/lib/i386-linux-gnu/libGLU.so.1
/usr/lib/i386-linux-gnu/libGLU.so.1.3.08000
/usr/lib/i386-linux-gnu/mesa/libGL.so.1
/usr/lib/i386-linux-gnu/mesa/libGL.so.1.2
/usr/lib/nvidia-current/libGL.so
/usr/lib/nvidia-current/libGL.so.1
/usr/lib/nvidia-current/libGL.so.295.40
/usr/lib/x86_64-linux-gnu/libGLU.so.1
/usr/lib/x86_64-linux-gnu/libGLU.so.1.3.08000
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2
/usr/lib32/nvidia-current/libGL.la
/usr/lib32/nvidia-current/libGL.so
/usr/lib32/nvidia-current/libGL.so.1
/usr/lib32/nvidia-current/libGL.so.295.40

I make symbolic links of
  • /usr/lib/x86_64-linux-gnu/libXt.so.6
  • /usr/lib/x86_64-linux-gnu/libX11.so.6
  • /usr/lib/x86_64-linux-gnu/libX11.so.6
with the suffix ".so" in the /usr/lib/x86_64-linux-gnu/ and /usr/lib/ directories. But it did not work. Furthermore I had no idea which GL-lib I have to use with Dislin.

Does anyone have an idea? Any comment is appreciated.

Kind regards,

Hani

PS: With former Ubuntus "gfortran -o map_f90 map_f90.f90 -I/usr/local/dislin/gf /usr/local/dislin/libdislin.a -lm -lXm -lXt" did the job but
it does not work with current versions.

Helmut Michels

unread,
Aug 9, 2012, 12:58:04 PM8/9/12
to dislin-users
Hi,

On 9 Aug., 01:13, hibr <hibr-l...@gmx.de> wrote:
> I also tried to compile Dislin program statically with (K)Ubuntu 12.04
> 64-bit. I just want that the target machines do not need to have Dislin
> installed.

one solution is to pass the shareable Dislin library libdislin.so.10
with
your program.

>
>  gfortran -o map_f90 map_f90.f90 -I/usr/local/dislin/gf
> /usr/local/dislin/libdislin.a /usr/lib/libXm.a -lXt -lX11 -lGL
>
> does not work. I get:
>
> /usr/bin/ld: cannot find -lXt
> /usr/bin/ld: cannot find -lX11
> /usr/bin/ld: cannot find -lGL
>
> ....

you have to install the packages libx11-dev, libxt-dev and libgl1-mesa-
dev
to solve the linking problem. After installing libmotif-dev, the
command

gfortran -o map_f90 map_f90.f90 -I/usr/local/dislin/gf
/usr/local/dislin/libdislin.a -lXm -lXt -lX11 -lGL

was working for me. Linking with the static OpenMotif library libXm.a
requires some more X libraries I think.

Best regards,

Helmut

hibr

unread,
Aug 9, 2012, 3:10:44 PM8/9/12
to dislin...@googlegroups.com
Hi Helmut,

first of all, thank you for your prompt and competent help.


Hi,

On 9 Aug., 01:13, hibr <hibr-l...@gmx.de> wrote:
> I also tried to compile Dislin program statically with (K)Ubuntu 12.04
> 64-bit. I just want that the target machines do not need to have Dislin
> installed.

one solution is to pass the shareable Dislin library libdislin.so.10
with
your program.

This is just a symbolic link to /usr/local/dislin/lib/dislin-10.2.so . I guess I have to copy this lib and rename it to the upper filename. And if I use the double precision lib I should do the same with /usr/local/dislin/lib/dislin_d-10.2.so.


you have to install the packages libx11-dev, libxt-dev and libgl1-mesa-
dev
to solve the linking problem. After installing libmotif-dev, the
command

 gfortran -o map_f90 map_f90.f90 -I/usr/local/dislin/gf
   /usr/local/dislin/libdislin.a -lXm  -lXt -lX11 -lGL

was working for me. Linking with the static OpenMotif library libXm.a
requires some more X libraries I think.

Yes this did the job for me perfectly. As another positive  side effect it is then possible to start the 64-bit Dislin program by (double-)click from the GUI-filemanager.

Again, thanks for your assistance.

Kind regards, Hani

Helmut Michels

unread,
Aug 9, 2012, 5:53:32 PM8/9/12
to dislin-users
Hi Hani,

On 9 Aug., 21:10, hibr <hibr-l...@gmx.de> wrote:
> Hi Helmut,
>
> first of all, thank you for your prompt and competent help.
>
> Hi,
>
>
>
> > On 9 Aug., 01:13, hibr <hibr-l...@gmx.de> wrote:
> > > I also tried to compile Dislin program statically with (K)Ubuntu 12.04
> > > 64-bit. I just want that the target machines do not need to have Dislin
> > > installed.
>
> > one solution is to pass the shareable Dislin library libdislin.so.10
> > with
> > your program.
>
> This is just a symbolic link to /usr/local/dislin/lib/dislin-10.2.so . I
> guess I have to copy this lib and rename it to the upper filename. And if I
> use the double precision lib I should do the same with
> /usr/local/dislin/lib/dislin_d-10.2.so.
>

Yes, exactly. I've forgot to explain.

Best regards,

Helmut
Reply all
Reply to author
Forward
0 new messages