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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:32:16+00:00 2026-06-08T21:32:16+00:00

test.cu: #include <iostream> #include book.h __global__ void add( int a, int b, int *c

  • 0

test.cu:

#include <iostream> 
#include "book.h"
__global__ void add( int a, int b, int *c ) {
    *c = a + b; 
}
int main( void ) {
    int c;
    int *dev_c;
    HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) );
    add<<<1,1>>>( 2, 7, dev_c );
    HANDLE_ERROR( cudaMemcpy( &c, 
                              dev_c, 
                              sizeof(int), 
                              cudaMemcpyDeviceToHost ) );
    printf( "2 + 7 = %d\n", c );
    cudaFree( dev_c );
    return 0; 
}

I am trying to compile above example test.cu. I tried with nvcc test.cu but compiler gives error

4.cu:2:18: fatal error: book.h: No such file or directory
compilation terminated.

How can I tell compiler where book.h is present? I have installed CUDA in /usr/local/cuda.
Do I need to make Makefile?
I am new to CUDA and Makefile so question might seem trivial.

  • 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-08T21:32:17+00:00Added an answer on June 8, 2026 at 9:32 pm

    Book.h is not CUDA. It is used by “Cuda by Example” for some easy stuff.
    In this example it is needed to provide the HANDLE_ERROR, you should write your own code to handle errors.

    Here you can find the book.h code: http://code.google.com/p/cuda-examples/source/browse/trunk/common/book.h?r=3

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

Sidebar

Related Questions

I created a program called test: #include<stdlib.h> #include<iostream> int main() { std::cout<<system(..\\add\\debug\\add.exe 4 8);
This is my test code #include<iostream> using namespace std; int main() { uint8_t a;
my test code is below: main1.c: #include <stdio.h> extern struct tt ; int main()
Here is a little test program: #include <iostream> class Test { public: static void
I have the following code: #include <iostream> #define BOOST_TEST_MODULE my test #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE(
Having a program like this: #include <iostream> #include <string> using namespace std; class test
Problem: $ clang++ -L../lib/osx/ -I../include/ -o test Script.cpp Main.cpp Verbose.cpp -llua -lUnitTest++ Undefined symbols
A little test program: #include <iostream> const float TEST_FLOAT = 1/60; const float TEST_A
I have the following program test.cc: #include <iostream> unsigned char bogus1[] = { //
Consider that TEST code: #include <iostream> using namespace std; class Klass { public: Klass()

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.