public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Rohland <cr@sap.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] Cannot use div operator in shared libraries
Date: Wed, 07 Jun 2000 08:26:19 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590678205124@msgid-missing> (raw)

--=-=-
Hi,

Attached are to files to reproduce the error:

1) lib.c
2) dl_test.c

compile them with:

$ gcc -c lib.c
$ ld -shared -o lib.so lib.o -lc
$ cc     dl_test.c   -o dl_test -ldl
$ cc     dl_test.c   -o dl_test2 -ldl ./lib.so

And test the result with

$ ./dl_test
./dl_test: error in loading shared libraries: ./lib.so: undefined symbol: __divdi3
$ ./dl_test2
13/5 = 2
2

Also '$ ld -shared -o lib.so lib.o -lc -Bsymbol' gives:
lib.o: In function `my_div':
lib.o(.text+0x92): undefined reference to `__divdi3'

I am using turbolinux 0505.

Greetings
                Christoph


--=-=-Content-Disposition: attachment; filename=lib.c

int my_div (int a, int b) {
  int c;
  c = a/b;
  printf ("%d/%d = %d\n",a,b,c);
  return c;
}

--=-=-Content-Disposition: attachment; filename=dl_test.c

#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv) {
  void *handle;
  int (*my_div)(int,int);
  char *error;
  
  handle = dlopen ("./lib.so", RTLD_LAZY);
  if (!handle) {
    fputs (dlerror(), stderr);
    exit(1);
  }

  my_div = dlsym(handle, "my_div");
  if ((error = dlerror()) != NULL)  {
    fputs(error, stderr);
    exit(1);
  }

  printf ("%d\n", (*my_div)(13,5));
  dlclose(handle);
}

--=-=-=--



             reply	other threads:[~2000-06-07  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-07  8:26 Christoph Rohland [this message]
2000-06-07 10:18 ` [Linux-ia64] Cannot use div operator in shared libraries Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590678205124@msgid-missing \
    --to=cr@sap.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox