Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Stuck with make again.

Posted on 2004-10-27
15
Medium Priority
?
770 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
Comment
Question by:b_vishwajit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
  • 2
  • +2
15 Comments
 
LVL 5

Author Comment

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

Author Comment

by:b_vishwajit
ID: 12427446
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
ID: 12427561
if you are working in a DOS environment, I suggest you to use shorter names like accdb.c and accdb.h
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:pankajtiwary
ID: 12428050
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
ID: 12428582
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
ID: 12431704
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
ID: 12436114
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
ID: 12436206
line of code that has strrev is:
strrev(balance);
where balance is a string.
0
 
LVL 5

Author Comment

by:b_vishwajit
ID: 12436327
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
ID: 12436448
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
ID: 12436567
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
ID: 12436652
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:
brettmjohnson earned 375 total points
ID: 12436751
> 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
ID: 12436860
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
ID: 12436923
I have already read an introduction to makefile. Thanks though. You were quite helpful. Thanks to everyone else for trying to answer.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

618 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