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 8489135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:44:33+00:00 2026-06-10T21:44:33+00:00

I am working through a sample program that uses both C++ source code as

  • 0

I am working through a sample program that uses both C++ source code as well as CUDA. This is the essential content from my four source files.

matrixmul.cu (main CUDA source code):

#include <stdlib.h>
#include <cutil.h>
#include "assist.h"
#include "matrixmul.h"

int main (int argc, char ** argv)
{
    ...
    computeGold(reference, hostM, hostN, Mh, Mw, Nw);  //reference to .cpp file
    ...
}

matrixmul_gold.cpp (C++ source code, single function, no main method):

void computeGold(float * P, const float * M, const float * N, int Mh, int Mw, int Nw)
{

    ...
}

matrixmul.h (header for matrixmul_gold.cpp file)

#ifndef matrixmul_h
#define matrixmul_h

extern "C"
void computeGold(float * P, const float * M, const float * N, int Mh, int Mw, int Nw);
#endif

assist.h (helper functions)

I am trying to compile and link these files so that they, well, work. So far I can get matrixmul_gold.cpp compiled using:

g++ -c matrixmul_gold.cpp

And I can compile the CUDA source code with out errors using:

nvcc -I/home/sbu/NVIDIA_GPU_Computing_SDK/C/common/inc -L/home/sbu/NVIDIA_GPU_Computing_SDK/C/lib matrixmul.cu -c -lcutil_x86_64

But I just end up with two .O files. I’ve tried a lot of different ways to link the two .O files but so far it’s a no-go. What’s the proper approach?

UPDATE: As requested, here is the output of:

nm matrixmul_gold.o matrixmul.o | grep computeGold

nm: 'matrixmul.o': No such file
0000000000000000 T _Z11computeGoldPfPKfS1_iii

I think the ‘matrixmul.o’ missing error is because I am not actually getting a successful compile when running the suggested compile command:

nvcc -I/home/sbu/NVIDIA_GPU_Computing_SDK/C/common/inc -L/home/sbu/NVIDIA_GPU_Computing_SDK/C/lib -o matrixmul matrixmul.cu matrixmul_gold.o -lcutil_x86_64

UPDATE 2: I was missing an extern "C" from the beginning of matrixmul_gold.cpp. I added that and the suggested compilation command works great. Thank you!

  • 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-10T21:44:35+00:00Added an answer on June 10, 2026 at 9:44 pm

    Conventionally you would use whichever compiler you are using to compile the code containing the main subroutine to link the application. In this case you have the main in the .cu, so use nvcc to do the linking. Something like this:

    $ g++ -c matrixmul_gold.cpp
    $ nvcc -I/home/sbu/NVIDIA_GPU_Computing_SDK/C/common/inc \
    -L/home/sbu/NVIDIA_GPU_Computing_SDK/C/lib \
    -o matrixmul matrixmul.cu matrixmul_gold.o -lcutil_x86_64
    

    This will link an executable binary called matrimul from matrixmul.cu, matrixmul_gold.o and the cutil library (implicitly nvcc will link the CUDA runtime library and CUDA driver library as well).

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

Sidebar

Related Questions

I'm working through Beej's socket tutorial . Using the sample code I've created a
I'm working on a server code that uses fork() and exec to create child
I'm working on a program that deals with a file that uses hashes. The
I am working through a bug. In recreating the bug for the following sample
I am working through the EditableGrid demos modifying the code to understand it and
I'm working through the Demo: Binding Data with the SqlDataSource of this pluralsight video
I'm working through a problem where I want to select a different static content
I am trying to get a sample program working with JUNG , a graphing
I am working through a problem for my MCTS certification. The program has to
I have this program that I want other processes to be able to call

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.