This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

creating shared object (.so) with gcc under cygwin


Hello

I am trying to create a shared object and use it in a program under
cygwin with gcc. I seem to miss a point. If some kind soul could help
me on that, I'd be very grateful.

Here's the code for the shared object (calc_mean.c):

  #include "calc_mean.h"
  double mean(double a, double b) {
    return (a+b) / 2;
  }

Here's its header file (calc_mean.h):

  double mean(double, double);


So, I compile that to a .so like so:

$ gcc -shared -o libmean.so calc_mean.c

Then, there's main.c that wants to use the shared object:

  #include <stdio.h>
  #include "calc_mean.h"

  int main(int argc, char* argv[]) {
    double v1, v2, m;
    v1 = 5.2;
    v2 = 7.9;

    m  = mean(v1, v2);

    printf("The mean of %3.2f and %3.2f is %3.2f\n", v1, v2, m);
    return 0;
  }

I try to compile main.c like so:

$ gcc main.c -o main -L. -lmean

However, the following error is returned:
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cygwin/bin/ld: 
cannot find -lmean
collect2: ld returned 1 exit status


Obviously, I do something wrong here, but I have no idea what that could
be.

Rene

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]