1

Below is my setup file to setup a python wrapper. The issue I am having is that in my c code I am writing is making calls to clock_gettime for profiling reasons. The thing is when I try to import the module I get the following: error undefined symbol: clock_gettime. I understand that I need to compile with -lrt, but obviously my compiler is not getting that flag. What am I doing wrong?

from distutils.core import setup, Extension
import os


module1 = Extension('relaymod',
    extra_compile_args = ["-lrt"], #flag so compiler links to realtime lib
    sources=['relaymodule.c']

    )


setup (name = 'relaymod',
    version = '1.0',
    description = "CTec Relay Board controller",
    author='Richard Kelly',
    url='site',
    ext_modules=[module1])

EDIT: looking at the distutils.core documentation I believe I need to set extra_link_args Below is my new change, but I am now getting this error: NameError: name 'extra_link_args' is not defined

EDIT2: ok the code below is now working. Had a few things going on. after I removed the build folder and rebuilt this worked.

from distutils.core import setup, Extension
import os


module1 = Extension('relaymod',
    extra_link_args=["-lrt"],
    sources=['relaymodule.c']

    )


setup (name = 'relaymod',
    version = '1.0',
    description = "CTec Relay Board controller",
    author='Richard Kelly',
    url='site',
    ext_modules=[module1])
Dick
  • 85
  • 9

1 Answers1

2

you are missing the equal (=) you need to say extra_link_args=[your list of link args]

Updated per the comments:

delete the build folder before retrying

Totoro
  • 867
  • 9
  • 10
  • good catch, but I am still getting 'undefined symbol: clock_gettime' – Dick Mar 13 '18 at 13:14
  • I think you need to pass the arguments with the dash ["-lrt"] – Totoro Mar 13 '18 at 14:19
  • Have it working now.... Once I deleted the build folder and rebuilt, it worked. If you want to write that up in an answer I will accept. Thanks for the help! – Dick Mar 13 '18 at 15:18