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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:00:36+00:00 2026-05-20T10:00:36+00:00

While scouring the net for an answer to my problem I have seen multiple

  • 0

While scouring the net for an answer to my problem I have seen multiple forum and blog posts tackling the ‘How do I set up, compile, link and run a CUDA project in VIsual Studio 2008’

(I was trying to give the links but I am not allowed to, as a new poster :p)

But what is missing here?

What’s missing is that all the above guides or posts tell you how to set up a single VS project which will be the startup project and will run by itself. As a consequence they are using the ‘CUDA Runtime API Rule’ which is tailored to create a CUDA friendly .exe file.

What do I want/need?

1)I want to have a VS solution which will contain multiple projects, most of which are written in C++. There will be one main project written in C++ creating the ‘.exe’ (containing the ‘main’ function and therefore controlling the flow) and multiple other projects that will be creating appropriate ‘.lib’ files against which the main project will link.
2)In the simplest form I need one project which will be doing CUDA stuff which will create the lib file and the main project which will link to it and use it.

I’ve looked everywhere to no avail, nobody seems to be using multiple projects.

My problem is:
1)The CUDA project creates a lib and therefore must use the ‘CUDA Driver API Rule’ and not the runtime variant (if I dare do so then the CUDA project tries to use libraries used by the main one and there are multiply defined projects’
2)When trying to do it the proper way the main project cant link to the CUDA project

Here is the example code I am using to show what the deal is (I will also attach the VS sln file here for those of you who want to try it out)

Outline:
    VS Solution
        Main Project(C++ project producing the .exe and containing the main function)
            main.cpp

                #include "../CUDAProject/testCuda.h"

                int
                main(int argc, char** argv)
                {

                    testCudaClass* t2;
                    t2 = new testCudaClass();
                    t2->stub_function();

                    return 0;
                }

        CUDA Project:
            testCuda.h

                #include <cstdio>
                #include <cstdlib>
                #include <iostream>

                class testCudaClass
                {
                public:
                    void stub_function();
                };

            testCuda.cpp

                #include "testCuda.h"
                extern "C" int cuda_function();

                void testCudaClass::stub_function()
                {
                    int a;
                    a=cuda_function();
                    std::cout<< a <<"\n";
                }

            test.cu

                #include "cuda.h"

                extern "C" int cuda_function()
                {
                    return 5;
                }           

Attached (temporary dropbox public links) is a zip file with 2 VS2008 solutions, one where I have a single CUDA project which works fine and one where I try to do the above (part of the project’s code is outlined above)

http://dl.dropbox.com/u/3091507/CUDA.zip

I would terribly appreciate any information or advice that can help me solve this conundrum

Thanks a lot
Adam

  • 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-05-20T10:00:37+00:00Added an answer on May 20, 2026 at 10:00 am

    I checked your code and this is what I did to succesfully compile it and run it:

    • Used CUDA Runtime API (it is OK to use it even if you have multiple projects)

    • MainProject -> Configuration Properties -> Linker -> General -> Additional Library Directories : added path to CUDA libs (it’s one of subfolders of your CUDA installation path)

    • MainProject -> Configuration Properties -> Linker -> Input -> Additional Dependencies : added “cudart.lib”

    • MainProject -> Configuration Properties -> Linker -> Input -> Ignore Specific Library : added “LIBCMT” to remove that warning about conflicts.

    • Make sure that you use the same “Runtime Library” for normal .cpp and .cu. In your case it didn’t match and it seems it was the reason for the warning abount library incompatibility. Compare the values of :

      • C/C++ -> Code Generation -> Runtime Library

      • CUDA Runtime API -> Host -> Runtime Library

    Also, you are generating “testCppProject.lib” and “CUDAProject.lib”, but you are including “test.lib” & “CUDAProject.lib”, where the first one is some older version of the lib.

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

Sidebar

Related Questions

I have been scouring for a while about this one but haven't seen a
While I've seen rare cases where private inheritance was needed, I've never encountered a
I've been scouring the net and SO and I can't get around or through
I have been scouring the Internet looking for a Java package/class that will allow
While trying problem 41 from the Euler Project, I ran across what seems to
While creating a simple client for a REST service which I have stubbed out,
While developing ASP.NET applications I often need to parse a boolean value given in
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
While going through university and from following the development of SO, I've heard a
While setting up CruiseControl, I added a buildpublisher block to the publisher tasks: <buildpublisher>

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.