Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about statically linking perl #741

Closed
p5pRT opened this issue Oct 19, 1999 · 4 comments
Closed

question about statically linking perl #741

p5pRT opened this issue Oct 19, 1999 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 19, 1999

Migrated from rt.perl.org#1664 (status was 'resolved')

Searchable as RT1664$

@p5pRT
Copy link
Author

p5pRT commented Oct 19, 1999

From mlevine@reshape.com

I am using gcc-2.95.1 and trying to compile perl 5.004_01 statically.
I have configured it with a command like this​:

  ./Configure -de -Dprefix='/home/mlevine/reshape.static/bin/perl ' -Dlibs='-lm
  -lstdc++ -lnsl ' -Dlibpth='-L/home/mlevine/reshape.static/blib '
  -Dldflags=' -static ' -Dso='none ' -Dcc='/home2/mlevine/reshape_tools/bin/gcc '
  -Dcf_email='mlevine@​reshape.com ' -Dmake='/home2/byron/reshape_tools/bin/gmake '
  -Dextensions='Reshape POSIX Fcntl IO Socket GD DProf GIFgraph DateManip '
  -Ddynamic_ext=' ' -Dstatic_ext='Reshape POSIX Fcntl IO Socket GD '
  -Dccflags='-DRESHAPE '

When I make perl, I die during the link of miniperl. The commands being generated
to compile and link miniperl are​:

/home2/mlevine/reshape_tools/bin/gcc -DPERL_CORE -c -DRESHAPE -I/usr/local/include -O miniperlmain.c
/home2/mlevine/reshape_tools/bin/gcc -static -o miniperl miniperlmain.o libperl.a -lm -lstdc++ -lnsl

When the make process tries to create miniperl, it gets undefined symbols, like this​:

  Undefined first referenced^M
  symbol in file^M
  dlclose /usr/lib/libc.a(nss_deffinder.o)^M
  dlsym /usr/lib/libc.a(nss_deffinder.o)^M
  dlopen /usr/lib/libc.a(nss_deffinder.o)^M
  ld​: fatal​: Symbol referencing errors. No output written to miniperl^M
  collect2​: ld returned 1 exit status^M

It seems like either miniperlmain.o or libperl.a is accessing a function in
libc.a which then wants to access dlcose(), dlsym(), and dlopen(), but of course,
I have no libraries for those since I am telling the linker not to look for .so's.
In other words, there is a libdl.so on my system, but no libdl.a (which makes
sense since I should want this from a dynamically linked executable).

Any ideas on what I am doing wrong?

@p5pRT
Copy link
Author

p5pRT commented Oct 19, 1999

From @gsar

On Tue, 19 Oct 1999 08​:48​:15 PDT, mlevine wrote​:

I am using gcc-2.95.1 and trying to compile perl 5.004_01 statically.
  ^^^^^^^^

Sorry I can't help with your real problem, but why such an old
version?

Sarathy
gsar@​activestate.com

@p5pRT
Copy link
Author

p5pRT commented Oct 19, 1999

From @doughera88

On Tue, 19 Oct 1999, mlevine wrote​:

Hi -

I am using gcc-2.95.1 and trying to compile perl 5.004_01 statically.
I have configured it with a command like this​:

Assuming (from the nss_deffinder stuff, i.e. the "Name Service Switch"
stuff) that you're on Solaris,

/home2/mlevine/reshape_tools/bin/gcc -static -o miniperl
miniperlmain.o libperl.a -lm -lstdc++ -lnsl

Undefined                 first referenced^M
 symbol                             in file^M
dlopen                              /usr/lib/libc\.a\(nss\_deffinder\.o\)^M

It seems like either miniperlmain.o or libperl.a is accessing a
function in libc.a which then wants to access dlcose(), dlsym(), and
dlopen(), but of course, I have no libraries for those since I am
telling the linker not to look for .so's. In other words, there is a
libdl.so on my system, but no libdl.a (which makes sense since I
should want this from a dynamically linked executable).

This diagnosis looks reasonable.

Any ideas on what I am doing wrong?

I don't think you're doing anything "wrong", but you may have to rethink
your quest to have *everything* statically linked. From the
nsswitch.conf(4) man page [trimmed]

FILES

  A source named SSS is implemented by a shared object named
  nss_SSS.so.1 that resides in /usr/lib.

  /usr/lib/nss_compat.so.1 implements "compat" source
  /usr/lib/nss_dns.so.1 implements "dns" source
  /usr/lib/nss_files.so.1 implements "files" source
  /usr/lib/nss_nis.so.1 implements "nis" source

I don't think you'll easily be able to build a perl on Solaris that uses
name services without allowing some shared objects to sneak into the
picture somehow. Whether or not this is a problem depends ultimately on
just why you want to build everything static.

Hope this helps,

  Andy Dougherty doughera@​lafayette.edu
  Dept. of Physics
  Lafayette College, Easton PA 18042

@p5pRT
Copy link
Author

p5pRT commented Oct 19, 1999

From [Unknown Contact. See original ticket]

Mlevine <mlevine@​reshape.com> writes​:

Hi -

I am using gcc-2.95.1 and trying to compile perl 5.004_01 statically.
I have configured it with a command like this​:

./Configure -de -Dprefix='/home/mlevine/reshape.static/bin/perl ' -Dlibs='-lm
-lstdc++ -lnsl ' -Dlibpth='-L/home/mlevine/reshape.static/blib '
-Dldflags=' -static ' -Dso='none ' -Dcc='/home2/mlevine/reshape_tools/bin/gcc '
-Dcf_email='mlevine@​reshape.com ' -Dmake='/home2/byron/reshape_tools/bin/gmake '
-Dextensions='Reshape POSIX Fcntl IO Socket GD DProf GIFgraph DateManip '
-Ddynamic_ext=' ' -Dstatic_ext='Reshape POSIX Fcntl IO Socket GD '
-Dccflags='-DRESHAPE '

I cannot see anything in there which tells us which OS you are using.

When I make perl, I die during the link of miniperl. The commands being generated
to compile and link miniperl are​:

/home2/mlevine/reshape_tools/bin/gcc -DPERL_CORE -c -DRESHAPE -I/usr/local/include -O miniperlmain.c
/home2/mlevine/reshape_tools/bin/gcc -static -o miniperl miniperlmain.o libperl.a -lm -lstdc++ -lnsl

When the make process tries to create miniperl, it gets undefined symbols, like this​:

Undefined first referenced^M
symbol in file^M
dlclose /usr/lib/libc.a(nss_deffinder.o)^M
dlsym /usr/lib/libc.a(nss_deffinder.o)^M
dlopen /usr/lib/libc.a(nss_deffinder.o)^M
ld​: fatal​: Symbol referencing errors. No output written to miniperl^M
collect2​: ld returned 1 exit status^M

If this is Solaris you may just not be able to build fully static.
You might try moving -lnsl up-front

It seems like either miniperlmain.o or libperl.a is accessing a function in
libc.a which then wants to access dlcose(), dlsym(), and dlopen(), but of course,
I have no libraries for those since I am telling the linker not to look for .so's.
In other words, there is a libdl.so on my system, but no libdl.a (which makes
sense since I should want this from a dynamically linked executable).

If libc.a needs dlopen() & co. you are in bad shape.
But presumably it is only "name service switch" code that needs
this stuff. Hence the suggestion about -lnsl above.

But note that this means you need to specify HOW names are going
to get resolved (FILES, NIS, DNS) at link time. This is usually
a bad idea and limits where executable can be used.

Any ideas on what I am doing wrong?

Why do you want an all static version?

Message from the perl bug squashing team at 'perlbug@​perl.org'
--
Nick Ing-Simmons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant