Easy BC 3.1 question 
Author Message
 Easy BC 3.1 question

This is the first time I've programmed on anything, besides unix, and I'm
having a little difficulties with Borland C++ 3.1.

The .cpp files compiles with no errors. When compiled in unix, it works
fine. I'm trying to compile it for either dos or windows.

Here is the error log:
Linking MKDIR.EXE:
Linker Warning: No module definition file specified: using defaults
Linker Error: Undefined symbol system(char near*) in module MKDIR.CPP

The program takes input, then it is suppose to spit out a system()
command. This is the program I have already:

#include <stdio.h>

void main()
{
        char dir_name[255];
        char edir_name[255];
        int system(char *s);
        char command[261];

        printf("Enter Directory Name: ");
        scanf("%s", dir_name);      
        sprintf(command, "md %s", dir_name);
        system(command);
        printf("Command = %s\n", command);
        printf("Created %s.", dir_name);

Quote:
}

What needs to be added/changed for this to work properly???

Dave Elkins
--
Tron-Thorpe, Inc.



Mon, 15 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

Quote:

>This is the first time I've programmed on anything, besides unix, and
I'm
>having a little difficulties with Borland C++ 3.1.

>The .cpp files compiles with no errors. When compiled in unix, it works
>fine. I'm trying to compile it for either dos or windows.

>Here is the error log:
>Linking MKDIR.EXE:
>Linker Warning: No module definition file specified: using defaults
>Linker Error: Undefined symbol system(char near*) in module MKDIR.CPP

>The program takes input, then it is suppose to spit out a system()
>command. This is the program I have already:

>#include <stdio.h>

>void main()

main should return an int.  This could get you in trouble one day.

Quote:
>{
>        char dir_name[255];
>        char edir_name[255];
>        int system(char *s);

I'm not sure you wouldn't be better off including stdlib.h instead.
This declaration does not exactly match the ansi definition, but
BC doesn't complain, even set for ansi.

Quote:
>        char command[261];

>        printf("Enter Directory Name: ");
>        scanf("%s", dir_name);      
>        sprintf(command, "md %s", dir_name);
>        system(command);
>        printf("Command = %s\n", command);
>        printf("Created %s.", dir_name);

Add a return statement.

Quote:
>}

Sounds like you might be set to generate a Windows application.  Look
under Options/Application and see.  It compiles and executes just
fine from my BC 3.1, set for DOS app.  The modifications noted were
needed to compile it as ansi.

--
John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:



Mon, 15 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

Quote:

>This is the first time I've programmed on anything, besides unix, and I'm
>having a little difficulties with Borland C++ 3.1.

It transpires that you are writing C++ (not C). However you probably do not
know this, and hence I forgive your mis-post.

Quote:
>The .cpp files compiles with no errors. When compiled in unix, it works
>fine. I'm trying to compile it for either dos or windows.

Rename the file to be a ".C" and then Borland will treat it as a C program,
rather than as a C++ program.

Quote:
>Here is the error log:
>Linking MKDIR.EXE:
>Linker Warning: No module definition file specified: using defaults
>Linker Error: Undefined symbol system(char near*) in module MKDIR.CPP
>The program takes input, then it is suppose to spit out a system()
>command. This is the program I have already:

[snip]

Quote:
>        int system(char *s);

You are creating your own prototype, which turns out to be incorrect both in
terms of C, C++ and the unusual environment you are using.

If you #include <stdlib.h> and remove this home-brew prototype, and keep your
file-extensions to ".C" you will be in better shape.

BTW: Borland has lots of options for setting many warnings that are useful
to someone like yourself who is learning. For example, Borland can trap
the fatal:

   if (x = 3) ...

When you meant to say:

   if (x == 3) ...

I would turn on as many of these additional warnings as possible (in fact
I have) and then ensure you understand every error/warning that you get.

Also remember that using MS-DOS and Borland is likely to throw up many
issues that involve non-ANSI C.  Posting in this newsgroup is asking for
flames.  So get yourself a good reference manual to try and filter this
yourself. People are likely to be forgiving if you say "I have this problem,
but I think section x.y of the standard ..."

Claude.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 vv    vv       David Claude Brown

 ||     | /
 /\------/
(oo)
(~~)



Tue, 16 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

Quote:

>Also remember that using MS-DOS and Borland is likely to throw up many
>issues that involve non-ANSI C.

        Something which UNIX programmers, of course, never do. That thread
about how to set a password doesn't really exist.
        -- Pete


Tue, 16 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

Quote:
> Here is the error log:
> Linking MKDIR.EXE:
> Linker Warning: No module definition file specified: using defaults
> Linker Error: Undefined symbol system(char near*) in module MKDIR.CPP

    You are not linking with whatever Borland library contains the
    system() function. Check out how to specify link libraries in your
    compiler manual.

    Some things you could try are renaming your file to "mkdir.c".
    Some compilers may do odd things with the ".cpp" extension that
    you're currently using. Another thing you could try is to #include
    <stdlib.h>.

Quote:
>    printf("Created %s.", dir_name);
> }

    BTW, insert an exit(0) here.

Quote:
> Dave Elkins

--

***     "If pigs had wings, bacon'd be more expensive" - Jonas Glim     ***


Wed, 17 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

Quote:
>#include <stdio.h>
>        int system(char *s);
>        system(command);

For one thing, system is defined in the stdlib.h header. Try using that
one instead of your own. Your definition may not match the one in the
header, which would ruin the mangling that C++ does in order to be able
to find the function in the library.


Thu, 18 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question
I recently purchased Turbo C++ 4.5 for Windows.  I
have had a book ("Teach Yourself Advanced C in 21
Days") for a while, and had no trouble compiling and
running the sample programs in Turbo C++ 3.1 for DOS.
I installed 4.5, and tried to compile a program.  It
compiled, and ran fine, until I asked it to display my
input, in which case it gave me a Gen. Prot. Fault and
booted me out of the application.  If you need more
specific details, e-mail me for them.  Any help would
be greatly appreciated.  Thanks in advance!
-S-


Fri, 19 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

Quote:

>Your definition may not match the one in the
>header, which would ruin the mangling that C++ does in order to be able
>to find the function in the library.

Avoided incorrect prototypes for library functions is a good idea, but
 * comp.lang.c ain't got no s{*filter*}king mangling *

--




Fri, 19 Dec 1997 03:00:00 GMT  
 Easy BC 3.1 question

The warning about using default module definition file _IS_ because
you are trying to build for Windows and not DOS.

                        - Chris

-============================================================================-

Tel     : +44 (0)1344 305305            :
Fax     : +44 (0)1344 305100            : I'll be back...
-============================================================================-



Mon, 22 Dec 1997 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. BC 3.1 Optimization Question..

2. Easy Borland C++ 3.1 for DOS and Windows question

3. Bug in BC 3.1

4. Bug in BC 3.1

5. Funny bug in BC 3.1

6. BC 3.1 FAR HEAP!

7. HELP: BC 3.1 DGROUP Problem

8. looking for bc 3.1 port of gnu's regex

9. BC 3.1 (HELP files)

10. Phar Lap's 286|DOS-Extender Lite for BC 3.1/4.0

11. BC 3.1 FAR HEAP!

12. BC 2.0 - Prob Running BCX with WIN 3.1

 

 
Powered by phpBB® Forum Software