Makefile very simple question.


 
Thread Tools Search this Thread
Top Forums Programming Makefile very simple question.
# 1  
Old 05-04-2008
Question Makefile very simple question.

Hi
I tried many times and I dont know what the he... is going on.

Problem:
I hava in /home/marcin/c1_menu/
this file:
menu_item_data.c

I want to compile this file.
so I tried something like this
Code:
CC=gcc
LIBS=-lmenu -lncurses
RM=rm

BINS=menu_item_data

%: %.o
    ${CC} -o $@ $< ${LIBS} 

%.o: %.c
    ${CC} -o $@ -c $< 

.PHONY: all clean


all: $(BINS)
    echo "Jeśli nie widzisz błędów to wszystko OKi"

clean:
    ${RM} -f ${BINS}

when I tried make in /home/marcin/c1_menu/.
I get somethig like this

Code:
$ make
gcc     menu_item_data.c   -o menu_item_data
menu_item_data.c: In function 'main':
menu_item_data.c:29: warning: incompatible implicit declaration of built-in function 'calloc'
/tmp/ccsA63dp.o: In function `main':
menu_item_data.c:(.text+0x14): undefined reference to `initscr'
(......)
menu_item_data.c:(.text+0x215): undefined reference to `endwin'
collect2: ld returned 1 exit status
make: *** [menu_item_data] Błąd 1

but when I try manualy everythign is ok

Code:
[marcin@zet c1_menu(0)]$ ls 
makefile  menu_item_data.c
[marcin@zet c1_menu(0)]$ vim m  
makefile          menu_item_data.c  
[marcin@zet c1_menu(0)]$ vim makefile  
[marcin@zet c1_menu(0)]$ gcc -o menu_item_data.o -c menu_item_data.c 
menu_item_data.c: In function 'main':
menu_item_data.c:29: warning: incompatible implicit declaration of built-in function 'calloc'
[marcin@zet c1_menu(0)]$ gcc -o menu_item_data menu_item_data.o -lmenu -lncurses
[marcin@zet c1_menu(0)]$ ls
makefile  menu_item_data  menu_item_data.c  menu_item_data.o
[marcin@zet c1_menu(0)]$

Why there are no LIBS ?
Code:
[marcin@zet c1_menu(0)]$ make -f makefile -n
gcc     menu_item_data.c   -o menu_item_data
echo "Jeśli nie widzisz błędów to wszystko OKi"


My target is compiling many files in one dir.
for example
if I had
x1.c x2.c ..... x100.c

and I have
BINS= x1.c x2.c .... x100.c
or something like a loop in Makefile


Please help me I can't get clear WORKING example from enybody.
# 2  
Old 05-04-2008
Code:
[marcin@zet c1_menu(0)]$ gcc -o menu_item_data.o -c menu_item_data.c 
menu_item_data.c: In function 'main':
menu_item_data.c:29: warning: incompatible implicit declaration of built-in function 'calloc'

Have a look at this file. I assume you use calloc(number,size) in an improper way. While gcc tries to link your binary it therefore does not resolve your call for calloc to the function calloc in libc/stdlib.h.

Maybe it'll help if you try to create and compile a minimum (standalone) example with calloc to check whether you use it properly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question in creating targets in makefile

Hi, I have a question related to makefile. I'm new to makefile and I'm in the process of writing a makefile for my RBT build. I have multiple source files and when I compile them I will get multiple object files (one object file for each source file). I'm having problem in creating a target for... (1 Reply)
Discussion started by: Anand Venkatesa
1 Replies

2. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

3. Shell Programming and Scripting

Simple Makefile for LaTeX

I create figures using Gnuplot, but I use terminal epslatex, which produces a .tex file as output. I then latex this .tex file which creates are .dvi file, which I then convert to .ps and finally to an .eps file. Anyway here's what I'm doing in steps gnuplot plot.gplt (this writes out... (2 Replies)
Discussion started by: lost.identity
2 Replies

4. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

5. AIX

makefile question

Hi all, In a makefile I would like to grab the first line of a given parameter file using ‘head' and assign it to a variable, how do I do this? I've got a simple makefile but it does not work? #! /bin/ksh ... .sqc.c: db2prep $*.sqc bindfile if ] DB2_PARM=`/usr/bin/head -1 $*.prm`; fi... (2 Replies)
Discussion started by: apersak
2 Replies

6. Programming

Simple Makefile Problem (with a dependency)

Hi all, I have 4 '.cpp' files and 1 header files: Tools.cpp Code1.cpp Code2.cpp Code3.cpp and Tools.hh Now all Code1.cpp, Code2.cpp, Code3.cpp use functions stored in Tools.cpp. Currently, what I do to compile all of them is using this simple shell script: (1 Reply)
Discussion started by: monkfan
1 Replies

7. UNIX for Dummies Questions & Answers

makefile Question

Hello, I'm trying to use the make command with a makefile I've made for an assignment. The professor supplied the code and I've copied it into a new file. I made sure to place the tabs in the correct spaces, however when I try to execute it in UNIX I get: "make: Fatal error in reader:... (5 Replies)
Discussion started by: Shinra1003
5 Replies

8. Shell Programming and Scripting

Makefile question

Hi all, I've a makefile which has this line: @touch $@ I know $@ is for representing the target. But I don't know what's the @ preceding the touch. Can anyone help me? Thanks in advance. (4 Replies)
Discussion started by: mjdousti
4 Replies

9. Programming

Tough makefile question

At my company, we build some stuff using a makefile. While the makefile script is running, a developer may check in a newer version of a source file. The problem is, when we next run the make command, the target file isn't rebuilt, because the date of the target is after the dependency. Any... (1 Reply)
Discussion started by: mbbeaubi
1 Replies

10. UNIX for Dummies Questions & Answers

Makefile question

I'm trying to do string replacement with a Makefile and this is my scenario: Inside file "fileA", I have "#include<text>" statements and I want to replace it with the text inside a file called "params". I wish to perform this task using Makefiles. I've tried using m4 but that only works if... (1 Reply)
Discussion started by: hc29
1 Replies
Login or Register to Ask a Question