473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A Problem with makefile.

Hi All,

I am trying to write a make file with the following specifications.

[Prasad@rsharma dir_make]$ pwd
/home/Prasad/programs/c/lsp/dir_make

[Prasad@rsharma dir_make]$ ls
add include main.c Makefile sub

Now, here main.c uses a function present in add/add.c and sub/sub.c.

I have written this makefile

[Prasad@rsharma dir_make]$ cat Makefile
SUB_DIRS := add sub
all:
@for d in $(SUB_DIRS) ; do \
( \
cd $$d ; \
make ; \
) \
done
OBJ_FILES=$($(foreach dir,$(SUB_DIRS),$(wildcard $(dir)/*.o)))
echo $(OBJ_FILES)
gcc main.c -o main -I $$PWD/include $(OBJ_FILES)

clean:
OBJ_FILES=$($(foreach dir,$(SUB_DIRS),$(wildcard $(dir)/*.o)))
echo $(OBJ_FILES)
rm $(OBJ_FILES)

But, it does not seem to work properly. I am getting following error
==>

[Prasad@rsharma dir_make]$ make
make[1]: Entering directory `/home/Prasad/programs/c/lsp/dir_make/add'
make[1]: `add.o' is up to date.
make[1]: Leaving directory `/home/Prasad/programs/c/lsp/dir_make/add'
make[1]: Entering directory `/home/Prasad/programs/c/lsp/dir_make/sub'
make[1]: `sub.o' is up to date.
make[1]: Leaving directory `/home/Prasad/programs/c/lsp/dir_make/sub'
OBJ_FILES=
echo

gcc main.c -o main -I $PWD/include
/tmp/ccmR5Xy4.o: In function `main':main.c:(.text+0x21): undefined
reference to `add'
:main.c:(.text+0x45): undefined reference to `sub'
collect2: ld returned 1 exit status
make: *** [all] Error 1

It seems that OBJ_FILES variable is not getting set properly.

Please help.

Thanks and regards,
Prasad.

Nov 29 '06 #1
3 1323
pr************@gmail.com wrote:
Hi All,

I am trying to write a make file with the following specifications.
<snip>
It seems that OBJ_FILES variable is not getting set properly.

Please help.
Ask in comp.unix.programmer or comp.os.ms-windows.programmer, (if that
is your development platform). But, really, the GNU docs for make are
quite excellent. Read them through.

Nov 29 '06 #2
In article <11*********************@j72g2000cwa.googlegroups. com>,
<pr************@gmail.comwrote:
>I am trying to write a make file with the following specifications.
makefiles are artifacts of your particular development environment,
and are not part of C itself. You need to ask in a newsgroup that
supports your development environment.

>[Prasad@rsharma dir_make]$ cat Makefile
OBJ_FILES=$($(foreach dir,$(SUB_DIRS),$(wildcard $(dir)/*.o)))
echo $(OBJ_FILES)
gcc main.c -o main -I $$PWD/include $(OBJ_FILES)
I've never seen a foreach in a makefile before, nor any mention
of 'wildcard'. That, together with the gcc line, suggests to me that
you are *not* using make, but instead are using gmake . If so,
then one of the gnu.* newsgroups would be appropriate.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
Nov 29 '06 #3
pr************@gmail.com wrote:
>
I am trying to write a make file with the following specifications.
.... snip ...
>
Please help.
Why should we, when you posted a completely off-topic query. Try a
newsgroup where make and makefiles are topical, such as
comp.unix.programmer, or something with gcc or gnu in its name.
Next time find out what is and is not topical on a newsgroup before
posting.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: pptran | last post by:
Hi, I am pretty new to building and installing Perl. Can someone help explain the severity of the following Perl 5.8.4 build error message? ==================================================...
4
by: newbiecpp | last post by:
I am very sorry to post this one because I know it is out of topic but I cannot find the proper news group. I understand that most senior C++ programmers know makefile very well. My question is...
0
by: Murray Bryant | last post by:
I am having problems with contrib/tablefunc in postgresql 7.4.1 on freebsd when i try to make install i get the errors below. I am unable to make the 7.3 -> 7.4 transition until i can get the...
2
by: Tony | last post by:
Hi, Now I am doing some programming on Openrisc processor on FPGA. with Xilinx tools set we can upload the makefile to it and run. the problem is how can I complie the c file to makefile which...
5
by: Jacobo Rodriguez Villar | last post by:
Hello, Is there any way (or program) to convert and maintain easily a C++ project (vs7.1) to a Makefile file, in order to build it in Linux? Many thanks -- Jacobo Rodríguez Villar ...
2
by: David Garamond | last post by:
Does it currently work? src/backend/utils/mb/conversion_procs/*/ is not building anything, and 'make install' fails because it tries to copy *.so files. -- dave ...
5
by: M.Liang Liu | last post by:
I have a project with the following dirs: --------------------------------------------------------------------------------------- +src |-proj0 |-program1 |-program2 |-proj1 |-program1...
0
by: Paul Anton Letnes | last post by:
>
2
by: chutsu | last post by:
I'm basically a summer student working on a program called Rivet. (http://projects.hepforge.org/rivet/) And I'm trying to port it to BOINC so that the hosts can download the BOINC client and do...
2
jwwicks
by: jwwicks | last post by:
C/C++ Programs and Debugging in Linux This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.