Thread: help with makefile

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > So an extra header file is (from what I understand) not allowed... Stupid rules
    This doesn't make any sense at all.
    The way two .c files communicate is with a .h file. Yes there are ways around it, but none of them stack up as good long term solutions.

    For example, one alternative is to leave your Image.c file "as is", and remove Image_lib.c from the makefile. So long as there is only ONE source file including another source file, then you can scrape by.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Salem View Post
    > So an extra header file is (from what I understand) not allowed... Stupid rules
    This doesn't make any sense at all.
    The way two .c files communicate is with a .h file. Yes there are ways around it, but none of them stack up as good long term solutions.

    For example, one alternative is to leave your Image.c file "as is", and remove Image_lib.c from the makefile. So long as there is only ONE source file including another source file, then you can scrape by.
    No, it doesn't make any sense. But that's how I understood it in posts by Taurus - he/she may of course have misunderstood the actual rules.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    With about half a dozen of them all on the same course posting here, it's hard to figure out who we're talking to at times, and what they may (or may not) have learnt in the process.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #19
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    Quote Originally Posted by matsp View Post
    No, it doesn't make any sense. But that's how I understood it in posts by Taurus - he/she may of course have misunderstood the actual rules.

    --
    Mats
    Theres a make file

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by taurus View Post
    Theres a make file
    Yes, but I fail to see the connection between "there is a makefile" and "you can't use a header-file" [although ok, technically, you should add the dependancy of the header file to the make-file, but it's not NECESSARY to do that].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #21
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    Hi , thanks for the ep100lib.h file matsp . I ended up putting it at the top of Image.c , as we are only meant to submit 2 files , the Image_lib.c and Image.c ...
    Now it looks like this :
    Code:
    #include <stdio.h>
    #include <string.h>
    #include "Image_lib.h"
    #ifndef IMAGE_LIB_INCLUDED
    #define IMAGE_LIB_INCLUDED
    
    #define EP100_LIB_MAX_X 1024
    #define EP100_LIB_MAX_Y 1024
    
    int (*Image_invert(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]))[];
    void Image_horizontal_scroll(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y], int scroll, int height, int 
    
    width);
    
    void Image_vertical_scroll(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y], int scroll, int height, int 
    
    width);
    
    #endif
    
    
    int (*Image_invert(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]))[];
    void Image_horizontal_scroll(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y], int scroll, int height, int 
    
    width);
    void Image_vertical_scroll(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y], int scroll, int height, int 
    
    width);
    
    
    
    int main(int argc, char **argv) ...
    I have gotten the image invert to work , now I have 11 hours or so to get the scrolling done .

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Just to clarify:
    1. I didn't post that header file. I think that was Salem.

    2. You don't need to use "include guards" if you are just putting a copy of the stuff IN the main file.

    3. You have duplicate defintions of the same function - that will just confuse everyone.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #23
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    > 3. You have duplicate defintions of the same function - that will just confuse everyone.

    Believe me it's hard to be more confused than me right now . But I will try to fix

  9. #24
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    I have been trying to get putty / xwin32 working for the last hour but it seems as there is a proble with uni server . ANyone know how I can use my dmccompiler to compile it ?

    I tried dmc make , which gives :
    Code:
    Do not know how to create Image.o
    I think the problem is that the makefile is referencing a directory stored on uni servers , which contains a library , that I can't copy to my machine . Is there any way of checking it on windows ? Otrherwise there's no way to check what I have done ....

  10. #25
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I presume "dmc" is a DOS/Windows compiler, and that the problem is that the makefile uses default rules to create the object files, hence the make utility for MS OS's don't know what you are asking it to do. Try changing all .o into .obj and see if that helps.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #26
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    Code:
    FILE=Image
    CFLAGS=-I. -I/usr/units/ep100/ass2.072/ `imlib2-config --cflags` -g
    $(FILE): $(FILE).obj 
    
    Image_lib.obj
    	cc  $(FILE).obj Image_lib.obj -o $(FILE) `imlib2-config --libs` -L/usr/units/ep100/ass2.072/ 
    
    -lep100 -g
    
    IMAGE=images/pa300570_small.jpg
    PARAM=
    run: $(FILE)
    	$(FILE) $(PARAM) $(IMAGE)
    
    # DO NOT DELETE
    Code:
    C:\Users\Ben\dm\bin>make
    Error: don't know how to make 'Image.obj'
    Is that what you meant by changing it into .obj ?

  12. #27
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That is indeed what I meant, but obviously not sufficient.

    You may need to add:
    Code:
    .c.obj:
           cc -o ${CFLAGS} $@ $<
    I also think that this:
    Code:
    CFLAGS=-I. -I/usr/units/ep100/ass2.072/ `imlib2-config --cflags` -g
    may not work right unless you've got a UNIX-like shell that this runs in - nor will the include path work very well.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #28
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    Sorry matsp , I didn't know how to add the :
    Code:
    .c.obj:
           cc -o ${CFLAGS} $@ $<
    But I'm afraid that no matter what I do it will not work , as it needs a library that is in this folder :
    /usr/units/ep100/ass2.072 .
    Code:
    13644637 &#37; chdir /usr/units/ep100/ass2.072
    13644637 % ls
    ep100lib.h  example_Image.c  Image  Image_lib.c  Image_lib.o  Image.o  images  libep100.a  Makefile  Makefile.bak  oldlibep100.a
    13644637 %
    I finally managed to get into it with putty.
    I guess that means there is no way to get that file on my computer . I tried
    Code:
    vi libep100.a
    but that gives me a whole bunch of scrmbled up code...

  14. #29
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, using vi on a binary will do that.

    Since the binary is for linux, you'll have to use the linux machine to build your files. You should be able to do that with putty - I've done that LOTS.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #30
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    Yes but the problem is I don't have a graphical interface . So I have no idea what it's doing to my image . Unless somehow I can make an executable and then somehow send it to my computer ... Do you know a way to copy a file from putty to the computer's hard drive

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  3. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM