• C

Stuck with make again.

accountsDB: accountsDB.exe
      gcc -o accountsDB accountsDB.exe
accountsDB.exe: accountsDB.c account.h
      gcc -c accountsDB.c
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

b_vishwajitAuthor Commented:
When I compile the make file I get some errors.
Whats wrong?
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 .
Jaime OlivaresSoftware ArchitectCommented:
if you are working in a DOS environment, I suggest you to use shorter names like accdb.c and accdb.h
Increase Security & Decrease Risk with NSPM Tools

Analyst firm, Enterprise Management Associates (EMA) reveals significant benefits to enterprises when using Network Security Policy Management (NSPM) solutions, while organizations without, experienced issues including non standard security policies and failed cloud migrations

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.

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
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.

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!!!!!!!!!!!!
b_vishwajitAuthor Commented:
line of code that has strrev is:
where balance is a string.
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?
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;

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.
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?
> 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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.