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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:36:16+00:00 2026-05-26T20:36:16+00:00

I am new to linux development. I wrote a project using MPI and cuda.

  • 0

I am new to linux development.
I wrote a project using MPI and cuda. When
it gets bigger and bigger, I realize that I
need a Makefile now. So I learned how to write
one. The Makefile works, but will only compile
cpp files even if I have both of the following
lines in my Makefile:

.cpp.o:

    $(CC) $(CCFLAGS) $<  

.cu.o:

    $(NVCC) $(CCFLAGS) $<

Any idea why this is happening? Thanks.

  • 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-26T20:36:16+00:00Added an answer on May 26, 2026 at 8:36 pm

    UNDERSTANDING MAKE

    Make is all about generating missing files.

    If you have TWO rules that generate the SAME file upon existence of a source then the first one in make’s list that actually has a source file present will get invoked. So for instance if you have the rules:

    .c.o: 
        $(CC) -o $@ -c $<
    
    .cpp.o:
        $(CXX) -o $@ -c $<
    

    and you have two files, foo.c and bar.cpp then you can type:

      $ make foo.o 
    

    it will use the first rule… and when you type

      $ make bar.o 
    

    it will use the second rule.

    Now suppose you have TWO files foo.c and foo.cpp

    Here make has to make a choice as to which takes precedence. Make uses suffixes of files intimately for its build rules. What is considered a suffix is controlled by the .SUFFIXES directive.

    The .SUFFIXES directive has a default built-in value that defines common suffixes such as .c .cpp .cc .o etc. in a particular order. If we want to change the order of precedence we clear that out with a blank line in Makefile i.e.:

    .SUFFIXES: 
    

    and then follow it with our definition:

    .SUFFIXES: .cpp .c .o
    

    if you don’t blank the line out, then make just appends the listed suffixes to its current list, that way multiple makefiles can simply add new suffixes without worrying about breaking each other.

    Now since the .cpp is before .c the .cpp.o rule will take precedence (in case foo.cpp and foo.c are both present)

    NOTE: Yes there is a “.” before the words SUFFIXES and yes it is all capital letters.

    Try to play with this Makefile to see the effects:

    .SUFFIXES: 
    
    .SUFFIXES:  .cpp .c .o
    
    
    .c.o:
        echo Compiling C
    
    .cpp.o:
        echo Compiling CPP
    

    Make is very very powerful, and quite well documented so well worth the read. GNU make, which is probably the strongest implementation with amazing extensions has made me a lot of money in the past 🙂 enjoy the experience.

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

Sidebar

Related Questions

I'd like to hack on my new Android phone using a Linux development environment.
I am new to Linux development and I have to work with Mono project
I am new to both Qt and Linux C++ development (although I have many
I am planning to build a new development computer for both Windows & Linux
As a newbie in Linux driver development, I've successfully recompiled a new kernel(2.6.39.4) upon
I'm new to Windows development, having messed around in Linux for a while. I
I usually do all my java development on linux, using fedora package manager setting
I'm trying to get started with Android development. I'm using eclipse on Linux and
I'm starting a new development position with a company that implements many of its
I am new to iphone development. Iphone development under linux is available through toolchain.

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.