The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Tough makefile question mbbeaubi High Level Programming 1 06-04-2007 02:15 PM
Simple C question... Hopefully it's simple Xeed High Level Programming 6 12-15-2006 10:29 AM
Simple question. TARFU Shell Programming and Scripting 2 01-27-2006 01:49 PM
Ok simple question for simple knowledge... Corrail UNIX for Dummies Questions & Answers 1 11-28-2005 09:03 AM
Makefile question hc29 UNIX for Dummies Questions & Answers 1 07-13-2004 03:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-04-2008
marcintom's Avatar
Registered User
 

Join Date: Dec 2007
Posts: 7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-04-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 180
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101