1

I make a module for apache, and use gcc for compile:

gcc \
    $(apr-1-config --cflags) \
    $(apr-1-config --includes) \
    $(python3.6-config --cflags) \
    -fPIC -DSHARED_MODULE \
    -I/usr/include/httpd/ \
    -c mod_demo.c

But when I try to link the python libraries it does not work:

ld \
    $(apr-1-config --link-ld) \
    $(python3.6-config --ldflags) \
    -Bshareable \
    -o mod_demo.so \
    mod_demo.o

The output message is:

ld: -linker not found.

What is the problem?. The flags are:

[root@demo demo]# python3.6-config --ldflags
-L/usr/lib64 -lpython3.6m -lpthread -ldl  -lutil -lm  -Xlinker -export-dynamic

If write the flags without -Xlinker, it works fine:

 ld \
    $(apr-1-config --link-ld) \
    -L/usr/lib64 -lpython3.6m -lpthread -ldl  -lutil -lm  -export-dynamic \
    -Bshareable \
    -o mod_demo.so \
    mod_demo.o

How to use native flags from python3.6-config?, what is the problem for -Xlinker?

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
e-info128
  • 3,727
  • 10
  • 40
  • 57

1 Answers1

3

-Xlinker -export-dynamic is a single thing which tells GCC to pass -export-dynamic to the linker.

You are misusing python3.6-config --ldflags in the sense that it expects its output to be given to GCC, not to ld directly.

Try this:

gcc \
    $(apr-1-config --link-ld) \
    $(python3.6-config --ldflags) \
    -shared \
    -o mod_demo.so \
    mod_demo.o
John Zwinck
  • 239,568
  • 38
  • 324
  • 436