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?

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.