Solved

Stuck with make again.

Posted on 2004-10-27
767 Views
Last Modified: 2011-09-20
accountsDB: accountsDB.exe
      gcc -o accountsDB accountsDB.exe
accountsDB.exe: accountsDB.c account.h
      gcc -c accountsDB.c
0
Question by:b_vishwajit
    15 Comments
     
    LVL 5

    Author Comment

    by:b_vishwajit
    When I compile the make file I get some errors.
    Whats wrong?
    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    cc     accountsDB.c   -o accountsDB
    process_begin: CreateProcess((null), cc accountsDB.c -o accountsDB, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [accountsDB] Error 2


    Errors generated when type "make accountsDB". I am doing it on a dos system .
    0
     
    LVL 55

    Expert Comment

    by:Jaime Olivares
    if you are working in a DOS environment, I suggest you to use shorter names like accdb.c and accdb.h
    0
     
    LVL 4

    Expert Comment

    by:pankajtiwary
    Hi b_vishwajit,

    As I can see you make file is trying to compile a file named accountsDB.exe which does not seem to be a C or C++ source files. Can you elaborate more on this? I think it should be accountsDB.o or accountsDB.lib something which should be an object file created from the command 'gcc -c accountsDB.c'

    Hope this helps.

    Cheers!
    0
     
    LVL 23

    Expert Comment

    by:brettmjohnson
    accountsDB.exe: accountsDB.c account.h
        gcc -c accountsDB.c

    By default, the output of the compilation of a .c file is a .o file, not a .exe file.
    I think your makefile wants to look like this:

    accountsDB: accountsDB.o
        gcc -o accountsDB accountsDB.o

    accountsDB.o: accountsDB.c account.h
        gcc -c accountsDB.c


    Or for something so trivial:

    accountsDB: accountsDB.c account.h
        gcc -o accountsDB accountsDB.c
    0
     

    Expert Comment

    by:Mic77
    Your Dependencies are somehow wrong

    I am not sure about the gcc flags but you need something like this.

    account.exe: account.obj
      gcc -v accountsDB.c
    account.obj: accountsDB.c account.h
      gcc -c accountsDB.c

    You can read this like this.
    account.exe depends on account.obj. So if account.obj exists oris out of Date, create a new one using a given rule.
    account.obj depends on accountsDB.c and account.h. Same thing as Mentioned above. If make cannot find the Header or source file it will terminate with an error.

     
    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    I am compiling my program on solaris system and I get this error:
    /tmp/ccDOMOM3.o: In function `procInput':
    /tmp/ccDOMOM3.o(.text+0x4cf): undefined reference to `strrev'


    actualy within procInput I am using strrev(str); to reverse a string and I have inlcuded <string.h>
    Why am gettting that error?On dos I have no problems. So weird!!!!!!!!!!!!
    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    line of code that has strrev is:
    strrev(balance);
    where balance is a string.
    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    I have to resovle this issue. strrev is not available on unix systems. What the heck? What am I supposed to do now? Should I right my own reverse string function?
    0
     
    LVL 55

    Expert Comment

    by:Jaime Olivares
    A simple strrev() implementation.

    char* strrev (char *str)
    {
            char *left = str;
            char *right = str + strlen(string) -1;
            char ch;

           while (left < right)
            {
                    ch = *left;
                    *left++ = *right;
                    *right-- = ch;
            }

            return(str);
    }
    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    jaime I knew how to write a simple reverse string function. I did what I was supposed to do before seeing your post. But anyway now I am back to makefile.
    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    Ok . My makefile looks like:
    hw3op:  hw3.c
            gcc -o hw3op hw3.o
    hw3.o: hw3.c hw3.h
            gcc -c hw3.c


    and I am saving it as makefile.txt.
    when i type make it says no targets.
    But make hw3op works since it is the first target in my make file and I end up with hw3op is uptodate when make ends.But by default make is supposed to compile  the first target in the makefile? is'nt it?
    0
     
    LVL 23

    Accepted Solution

    by:
    > and I am saving it as makefile.txt.
    > when i type make it says no targets.

    The make utility expects the makefile to be named 'makefile' or 'Makefile',
    (and in some versions, 'makefile.mak'), not 'makefile.txt'.  If you use a
    non-standard filename for the makefile, you must specify it with a -f switch
    to make:

    make -f makefile.txt hw3op

    0
     
    LVL 23

    Expert Comment

    by:brettmjohnson
    You might consider running through a tutorial on make and makefiles.
    Simply google "makefile make tutorial" and pick from the 8 or 10 that
    are at the top of the list.

    0
     
    LVL 5

    Author Comment

    by:b_vishwajit
    I have already read an introduction to makefile. Thanks though. You were quite helpful. Thanks to everyone else for trying to answer.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
    The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now