Currently I'm learning how to build projects (C programming) with GNU make. I have a problem with one Makefile and I would appreciate if you could kindly give me a hand. Here is the environment:
OS: Redhat linux 5
compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
make: GNU Make 3.81
I have one header file (.h) and two .c files. All of the files are in the same directory. here is my Makefile:
Makefile:
This works pretty well. But there is a problem. The file named file1.c is the principal file, that is, the file that includes the main function. As you can see in the first entry, among the prerequisites of the target file1, I just included mathfun1.o and mathfun1.h. As a result, if the source file "file1.c" is modified the target file1 is not updated because 'file1.c' is not in the list of the prerequisited of the target file1. Now, the problem is that if I add this file to the list of the preequisites I receive an error message.
I mean, if in the Makefile, instead of
I write
I receive the following error message:
Any idea? why I get this error message?
Thanks in advance,
Kind Regards,
Dariyoosh
In the case where it may be helpful, here are the complete definitions of other files. As I said earlier, all files are in the same directory.
In simple words the error means there are two main functions since you have included file1.c twice here
What you can do to solve your problem is build two object files mathfun1.o and file1.o and build the executable "file1" including both these object files. Your makefile would look something like this
Regards,
Harish J
In simple words the error means there are two main functions since you have included file1.c twice here
What you can do to solve your problem is build two object files mathfun1.o and file1.o and build the executable "file1" including both these object files. Your makefile would look something like this
Regards,
Harish J
Hello there,
Thank you very much for your attention to my question. In fact this was the source of the problem. Here is therefore the new version of Makefile
And everything works pretty well now.
Hello,
My makefiles are set up to generate an environment specific build directory based on the local configuration and some values passed to make. It generally looks like,
# compilers, may be passed to make
CC++ = g++
FCOMP = gfortran
# version of program, may be passed to make
ver =... (4 Replies)
I have a make file for C program, which always gives the error
ld: 0711-738 ERROR: Input file ../src/file_name.o
XCOFF32 object files are not allowed in 64 mode
Does anybody know the problem?
Thanks for contribution (2 Replies)
I am new to Solaris and compilation using make files.
I have a code base which is organized into different folders. At the root folder is a master make file and in the sub directories, there are make files for that particular folder.
In the make files present in subdirectories, I am seeing... (2 Replies)
I've created a tag in the makefile:
mytag: $(shell ${PWD}/script.sh)
When i do: make clean - the script is executed
When i perform make or make mytag the script is again executed with the output:
make: Nothing to be done for mytag
What i want ?
I want script.sh to be executed only... (0 Replies)
I am trying to create a makefile to build a program and am getting the following error:
make -f tsimplex.mk
make: *** No rule to make target `/main/tsimplex_main.cpp', needed by `tsimplex_main.o'. Stop.
OPSYS = $(shell uname -s )
TARGET = tsimplex
ROOTDIR = ../../..
GTSDIR =... (1 Reply)
I want to run a target defined in a shell script. The shell script name is 'ua.sc' and the target in it is 'N' i.e. (ua N) throught a makefile. How can i do it so that i can run it with a make target. (3 Replies)
Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error:
make: module: command not found
Why is this? Is there any way to run this command in a Makefile?
NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Hi,
This stems from the following thread https://www.unix.com/showthread.php?t=18299
I have a makefile which makes either executables or a shared library.
i.e. make -f unix.mak will create the executables and
make -f unix.mak libolsv will create the shared library.
Since these have to be... (4 Replies)
I am running a make file through the gnu make tool and i am getting the following error
jsh1035c:/users/egate453/admegate/kapil/samples $ make -f GNUmakefile queue_c
make -f ./GNUmakefile queue_c in_objdir=1 build_root=/users/egate453/admegate/kapil/samples
make: Entering directory... (2 Replies)