Makefile with directories

My Makefile was fine. However, now I want to have a folder named "Makefile" and a folder named "main", where the first will contain my Makefiles and the second will contain files that are meant to be the main() of my my project, k-d GeRaF.

For now, the header files lie in the same folder. That folder also contains Makefile folder and main folder.

Here is my makefile (have tried many combinations, this is the last attempt):

OBJS = main_par_auto.o SOURCE = ../main/main_par_auto.cpp HEADER = ../Division_Euclidean_space.h ../Find_diameter.h ../Find_k_max.h ../Householder.h ../IO.h ../Mean_variance.h ../Point.h ../Random_generator.h ../Random_kd_forest.h ../Tree.h ../Auto_random_kd_forest.h OUT = geraf CXX = g++ FLAGS = -pthread -std=c++0x -DRKD_PAR -O3 -Wall all: $(OBJS) $(CXX) $(OBJS) -o $(OUT) $(FLAGS) # create/compile the individual files >>separately<< main_par_auto.o: main_par_auto.cpp $(CXX) -c ../main/main_par_auto.cpp $(FLAGS) .PHONY : all # clean house clean: rm -f $(OBJS)

and I am getting this error:

make: *** No rule to make target `main_par_auto.cpp', needed by `main_par_auto.o'. Stop.

I am executing this command: make -f Makefile/Makefile_par_auto in order to compile.

What am I missing please?

This is the big picture ( literally :) ) Makefile with directories

-------------Problems Reply------------

The paths in the Makefile have to be relative to the working directory (the directory from which you run make), not to the directory that contains the Makefile. With

main_par_auto.o: main/main_par_auto.cpp
$(CXX) -c main/main_par_auto.cpp $(FLAGS)

you should get the expected results.

Note that it is very unusual to expect a user to invoke make this way. Normally, you'd expect to have a Makefile in the directory where you call make (that may or may not go on to use other makefiles in other directories).

Category:c# Views:5 Time:2018-03-13

Related post

  • Makefiles with source files in different directories 2009-07-16

    I have a project where the directory structure is like this: $projectroot | +---------------+----------------+ | | | part1/ part2/ part3/ | | | +------+-----+ +---+----+ +---+-----+ | | | | | | | data/ src/ inc/ src/ inc/ src/ inc/ How should I write

  • Have you replaced makefiles with ruby scripts? 2010-02-20

    I appreciate makefiles and make in all their glory, but I wonder if there isn't a more intuitive way to maintain my c/c++ builds. Has anyone tried replacing their makefiles with ruby scripts to allow for complex and adaptive builds without sacrificin

  • Passing arguments to commandline with directories having spaces 2010-04-09

    I am making a system call from perl for and passing parameters with directories (having spaces). So I pass them in quotes, but they are not being picked up in the file 1) my $call = "$perlExe $contentcheck -t

  • Building hierarchical Makefile with GNU Make 2011-04-05

    I have a project divided in modules, each hosted in a directory, say: root |_module_A |_module.cpp |_Makefile |_module_B |_Makefile |_main.c |_Makefile main.c depends on targets defined in Makefiles related to module_A and module_B. I want to write m

  • How can I interact with directories in C++? 2011-10-16

    Is the C++ language dealing with directories like create, delete, get directory content, search, etc. Does C++ have an internal library or are there external libraries ? Is there a recommended library? --------------Solutions------------- Boost.Files

  • Makefiles with C programming 2012-01-27

    I am very new to C and UNIX systems programming. I know what to put in a basic makefile (the c files, the dependencies and the commands) but how do I actually create a makefile? Is it a text file? What kind of extension is a makefile? I am using Mac

  • How to generate a Makefile with source in sub-directories using just one makefile 2008-10-23

    I have source in a bunch of subdirectories like: src/widgets/apple.cpp src/widgets/knob.cpp src/tests/blend.cpp src/ui/flash.cpp In the root of the project I want to generate a single Makefile using a rule like: %.o: %.cpp $(CC) -c $< build/test.e

  • Problems with directories making a simple makefile 2011-02-08

    I want to make a simple makefile for a C project that have the following directories. -Project - src - a.c - b.c - main.c - headers - a.h - b.h - build - makefile - project.exe And here it's the makefile that I've done. project: a.o b.o main.o cc -o

  • Automatic makefile with source and object files in different directories 2011-09-17

    I'm attempting to put together a makefile that will take source files from a directory (eg. src), compile them into object files in another directory (eg. build), and then take those files and create a static library from them in the main directory.

  • Makefile with multiple directories 2012-03-16

    I wanted to write a makefile for a program that has source files located in different directories, the structure is: --root(here will be makefile) --src: --main.c --include: --here are 6 .h files, that are used by other .c files, main.c includes on a

  • how to create a makefile with several sub-directories 2011-04-24

    I have one directory and underneath it 4 subdirectories like so: myDir: myDir/Part1 myDir/Part2 myDir/Part3 myDir/shared I want to make an executable that takes files from shared, links it to files in Part2 and puts the executable in myDir. This is w

  • makefile with directory tree creation suitable for parallel (-j ) build 2009-12-12

    My project needs temporary directories which are created during the build using mkdir -p similarly to this: all: dirtree $(OBJFILES) dirtree: @mkdir -p $(BUILD)/temp_directory But this approach cannot be used with the -j switch, because first of the

  • How to ensure object files are compiled with correct settings in Makefile with multiple MAKE targets 2010-07-02

    I have a small project that builds a number of targets from the same source files. The targets require building the source files with different compile flags. This is actually on cygwin so I'll use that as the concrete example although I suppose this

  • Makefile with Jar and Package Dependencies 2011-03-30

    I have been trying all day to get this thing to work. Basically I need to create a makefile to build my project from its sources. I know a little about Linux but not much and I am a complete makefile newbie. I have tried loads of examples from all ov

  • Makefile with coqtop -R coqdir 2012-03-20

    I have a makefile: Add the command: coqtop -R coqdir I have to give a physical path in my computer, but this directory depends on user directory. (~/color/trunk/color/devel/gwen Devel and ~/color/trunk/color CoLoR). Is there another way to call and c

  • Simple makefile with release and debug builds - Best practices 2009-04-27

    I am new to makefiles. I learned makefile creation and other related concepts from "Managing projects with GNU make" book. The makefile is ready now and I need to make sure the one which I created is OK. Here is the makefile #Main makefile which does

  • svn copy - problem with directories 2009-11-16

    I want to create a tag in my repository. My command is: svn copy trunk tags\1.1 I execute this command in the main directory of my local working copy. It however copies whole directory so the files ends up in tags\1.1\trunk directory, not in tags\1.1

  • Domain with directories or new domains? 2010-01-20

    what is better, a domain with subdirectories or whole new domains for those directories? I have a website divided by 12 directories which are the main purpose of the website like: I was wondering what is bett

  • How could I display a hierarchical org chart with directors, managers, and staff, using webforms and c#? 2010-02-03

    Assume I have an XML doc with employees and who reports to them. Something like this: <?xml version="1.0" encoding="utf-8" ?> <employees> <employee> <id>1</id> <name>Ashley King</name> <title>Director

  • How to empty a directory with .directories 2010-10-06

    In Ruby 1.8, how do I delete a tree of directories where some of the subdirectories begin with '.'? For example, I have an embedded Linux filesystem directory that I want to clean out. One of its subdirectories is ./dev/.udev/files. Dir[ "{**/*,**/.*

  • How to correctly make a java jar file using this makefile with files in src/ and bin/ 2010-12-23

    I am having trouble correctly generating a Jar for my Java implementation. I am not a Java master ( Thus why I am using Make and not Ant). I didn't think I cared about a Jar until I realized my Windows machine didn't hava javac. Then I thought to mys

  • Problem with directories in C 2011-04-02

    I'm making a program for Linux in C that recieves a directory as an argument, then for each file in that directory and each of it's sub-directories, calls a program called monfile. Here's the code: #include <stdio.h> #include <dirent.h> #

  • makefile with .s files beside .c files 2011-04-08

    I have a baremetal project which includes .s files beside .c files. I wonder how can i write a makefile, where i sepparate compiling of .s files from .c files. Files are located in a subfolders (source, include, startup) of a program. I was going for

  • Trouble using makefile with multiple files in C 2011-04-18

    Starting to get my head around makefiles for my C programs, but having some trouble when trying to include multiple files. Ignoring the fact that the program below is incomplete (in terms of functionality but not compilation), I'm trying to get this

  • makefile with relative path's? 2011-07-31

    i have a problem with my Makefiles. OS : Gentoo Linux Here my Folder hierarchy: Development -> GLTools -> include -> src ->Triangle ->triangle.cpp ->Makefile and my Makefile: MAIN = triangle SRCPATH = ./ SHAREDPATH = ../GLTools/src/

Copyright (C), All Rights Reserved.

processed in 0.249 (s). 11 q(s)