[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 774
  • Last Modified:

Stuck with make again.

accountsDB: accountsDB.exe
      gcc -o accountsDB accountsDB.exe
accountsDB.exe: accountsDB.c account.h
      gcc -c accountsDB.c
0
b_vishwajit
Asked:
b_vishwajit
  • 8
  • 3
  • 2
  • +2
1 Solution
 
b_vishwajitAuthor Commented:
When I compile the make file I get some errors.
Whats wrong?
0
 
b_vishwajitAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
if you are working in a DOS environment, I suggest you to use shorter names like accdb.c and accdb.h
0
Managing Security & Risk at the Speed of Business

Gartner Research VP, Neil McDonald & AlgoSec CTO, Prof. Avishai Wool, discuss the business-driven approach to automated security policy management, its benefits and how to align security policy management with business processes to address today's security challenges.

 
pankajtiwaryCommented:
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
 
brettmjohnsonCommented:
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
 
Mic77Commented:
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
 
b_vishwajitAuthor Commented:
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
 
b_vishwajitAuthor Commented:
line of code that has strrev is:
strrev(balance);
where balance is a string.
0
 
b_vishwajitAuthor Commented:
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
 
Jaime OlivaresSoftware ArchitectCommented:
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
 
b_vishwajitAuthor Commented:
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
 
b_vishwajitAuthor Commented:
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
 
brettmjohnsonCommented:
> 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
 
brettmjohnsonCommented:
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
 
b_vishwajitAuthor Commented:
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

Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.

  • 8
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now