`./configure` ignores `LIBS=....`

Issue #68 closed
leos313 created an issue

Problem when compiling PAPI against another library.

I would like to use my just-created own library when compiling PAPI 5.7.0.

The library is very simple (for the purpose of this question):

myOwnLib.h:

#ifndef MYOWNLIB
#define MYOWNLIB

#include <stdio.h>
#include <stdlib.h>

void functionWithinShared();
int genericEvent(unsigned int slotId, unsigned int eventId);

#endif //MYOWNLIB

myOwnLib.c:

#include "myOwnLib.h"

/**
 *
 */
void functionWithinShared(){
    printf("Function within the shared library libmyOwnLib.so\n");
    return;
}

/**
 *
 * @param slotId
 * @param eventId
 * @return check error
 */
int genericEvent(unsigned int slotId, unsigned int eventId){
    printf("the selected slot where to read the event is %u\n", slotId);
    printf("the selected event is %u\n", eventId);
    // probably a swithc should be used!!
    return -1;
}

Well, the just created libmyOwnLib.so is in the right location (i.e. /usr/lical/lib/ and the header file is in the folder /usr/local/include.

If I want to use the library within the PAPI 5.7.0, what I do is:

./configure --with-components="myComponent" CFLAGS='-I /usr/local/include' LDFLAGS='-L /usr/local/lib' LIBS='-lmyOwnLib' | grep --color=always -e "^" -e "myOwnLib"

and after make, I have the error:

make[1]: Entering directory '/home/linaro/PAPI_5_7_0/papi/src/utils'
gcc -L /usr/local/lib -ldl  -o papi_avail papi_avail.o print_header.o ../libpapi.a
../libpapi.a(artico3.o): In function `myComponent_hardware_read':
/home/linaro/PAPI_5_7_0/papi/src/components/myComponent/myComponent.c:158: undefined reference to `functionWithinShared'
/home/linaro/PAPI_5_7_0/papi/src/components/myComponent/myComponent.c:159: undefined reference to `genericEvent'
collect2: error: ld returned 1 exit status
Makefile:19: recipe for target 'papi_avail' failed

The header file is correctly read, no error for it. If I execute:

$ nm -a libmyOwnLib.so | grep functionWithinShared
0000000000000800 T functionWithinShared

That means that the symbols are correctly created.

Where is the error? Why the /configure ignore LIBS=-lmyOwnLib?

Beside, after getting the error, no problem when executing manually gcc -L /usr/local/lib -ldl -o papi_avail papi_avail.o print_header.o ../libpapi.a -lmyOwnLib if I am in the folder papi/src/utilities. So, how to add the -lmyOwnLib properly using ./configure?

All the details where also shared [here](https://stackoverflow.com/questions/56669017/linking-shared-library-undefined-reference-to)

Comments (2)

  1. Log in to comment