Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:47:45+00:00 2026-06-17T08:47:45+00:00

For reasons too lengthy to explain here, I need to create, in C, a

  • 0

For reasons too lengthy to explain here, I need to create, in “C”, a shared library (call it libA) that is callable within Python. This shared library needs to call another custom shared library (we’ll name it libCuda). In addition libA calls many other external shared libraries such as MySQL, etc.

Before the inclusion of libCuda, all C-functions called within Python worked flawlessly, MySQL sub-calls worked fine, etc. However, once libCuda was added to libA, Python complains:

caughtError c process - [directory]/libA.so: undefined symbol: cudaFunction1

libCuda, as you might have guessed, is nVidia Cuda Code compiled with nvcc and setup to be C-linkable (i.e. export “C” in function prototyes) I have tested this shared library (libCuda) with a stand-alone test bench (written in C) and everything works as expected. This is the instruction used to compile the Cuda library:

nvcc -arch=sm_30 -shared -o libCuda.so *.cu -Xcompiler -fPIC

if I use:

$ ldd libA

I do not see any information indicating that libA needs to load libCuda (or MySQL for that matter)

The command used to compile libA is as follows (libCuda lives in local directory):

gcc *.c -c -L. -lCuda -lmysqlclient [many other shared libraries] -fPIC
gcc -shared -Wl,-soname,libA.so -lCuda -lmysqlclient [many other shared libraries] -o libA.so *.o

I have tried placing both library files in /usr/lib and explicitly exporting the LD_LIBRARY_PATH. No luck. Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:47:45+00:00Added an answer on June 17, 2026 at 8:47 am

    Ok, so didn’t win, but I was able to change the rules.

    Using this as a reference, I first compiled the CUDA code with nvcc, thus creating several object ( *.o ) files. These object files were then added to the list of object files linked by gcc when creating the library, libA. In addition, the follwing linker arguments were added to the gcc command “-L/usr/local/cuda/lib64 -lcudart” (I’m using an x64 machine).

    It is EXTREMELY IMPORTANT to point out that you must place any library dependency AFTER the object file that needs it. If you don’t gcc will complain about undefined references. A good rule of thumb is to place all libraries at the end of your gcc line. See below for details.

    In a nutshell here’s what worked:

    CUDA:

    nvcc -arch=sm_30 -c *.cu -Xcompiler -fPIC
    

    C:

    gcc *.c -c -fPIC -L/usr/local/cuda/lib64 -lcudart -lmysqlclient [many other shared libraries]
    gcc -shared -Wl,-soname,libA.so -o libA.so *.o [cuda_obj_file_dir]/*.o -L/usr/local/cuda/lib64 -lcudart -lmysqlclient [many other shared libraries]
    

    Many thanks to Anton Kovalenko for advice. Unfortunately, I wasn’t able to solve my ultimate goal, but maybe this will serve as an intermediate for someone else, as it is doing for me now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For reasons that are irrelevant to this question I'll need to run several SQLite
For reasons that only the developers can understand, Firefox will create and open .url
For reasons beyond my control, I need to return const char* from a function,
For reasons that I would not like to discuss, our master database schema is
The Zen of Python states that there should only be one way to do
I'd like to write a simple wrapper for the python list type that forces
This sounds like a weird title and probably not stated too well. But here's
First, let me say that I have been at this for far too long,
So I am working on a project that for certain reasons is limited to
I've been putting up with this for probably too long. For some odd reason,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.