#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    Not enough memory when running .exe


    Hey, im using linux vi editor to make a an .exe file. (I'm connecting to the college i go to using linux and making it so its being saved on my drive at the college).. when i run it in linux on my computer connected to the college it works, however if i use ftp and put the file on my computer, it gos to open in command prompt but says "programs to big to fit in memory". I'm new to programming, and its a very very simple program with only one variable that is a string and it uses the cin command and cout command. so can anyone tell me why when running on my computer it says programs to big to fit in memory? (it also says the same thing on my friends computer) we both use win XP
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    13
    Rep Power
    0
    Sounds like you programmed it for linux... maybe its not compatible with windows.
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    wicked, let's try to get straight what you're doing.

    Are you using Linux or WinXP at home? Also, vi is a text editor, whereas an .EXE file is binary. How could you use vi to create a binary file?

    But it's possible your problem is the ftp. Since an .EXE is a binary file, you need to make sure that you are sending it as binary. If you sent it as text then it will arrive all munged up. When you ftp in, enter the command, binary. It should respond back with "Type set to I." I is for "image". Then upload .EXE file.

    The first part of an .EXE file is the EXE header which contains the information that the loader needs to allocate resources (eg, memory), load the program, and fix up all the addresses. If the field containing the amount of memory needed gets munged, it could end up containing a very large value, which could account for your error message.


    Another possibility occurs to me, based on my confusion of what you are doing. Are you running XP at home but telneting in to a Linux server at school? And are you compiling the program on the Linux server and expecting to be able to run the compiled version on your XP at home? Won't work. Executable files are very much operating system dependent. Unless you have special cross-platform development tools, you simply cannot create an executable in one OS and expect it to run on an entirely different one. What you would need to do would be to ftp the source code to your XP (after having entered the ascii command to place it in text mode, AKA 'A') and use your compiler on the XP to create an .EXE file that can run on Windows/DOS.

    If you don't have a C/C++ compiler on your XP, check out the free compiler and IDE, Dev-C++, at bloodshed.com. One advantage is that it uses a 32-bit Windows port of gcc, which you are already becoming familiar with at school.

    Another caveat:
    UNIX/Linux and Windows/DOS format their text files differently, mainly in how they terminate lines (CR-LF in DOS, LF only in Linux). Google for a utility called todos or fromdos that will convert text files back and forth. Or check with your instructor about what conversion utilities are available on the school server.
    Last edited by dwise1_aol; September 19th, 2003 at 03:30 PM.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    I will try and explain clearer..


    Ok swy i will try to explain clearer... my home computer has winXP, i use WS_ftp pro to transfer files (and binary was selected) i see where i did go wrong though, i use putty to connect to linux and i have linux running on my computer *which looks like the command prompt* and i write the code in .cpp file then i use the g++ command to turn it into a .exe, then i connect to the sever again with WS_ftp pro and get my file, whoever seeing my computer uses win XP, and i made the program on linux, that would be the problem.

    i think u said i can take the code and use it on winxp by complining it in winXP... do i use dos edit program to do that and if so how do i do it?... like what kinda file do i save the code as.. then how do i compile it? thanks:)
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222

    Re: I will try and explain clearer..


    Originally posted by wicked205
    Ok swy i will try to explain clearer... my home computer has winXP, i use WS_ftp pro to transfer files (and binary was selected) i see where i did go wrong though, i use putty to connect to linux and i have linux running on my computer *which looks like the command prompt* and i write the code in .cpp file then i use the g++ command to turn it into a .exe, then i connect to the sever again with WS_ftp pro and get my file, whoever seeing my computer uses win XP, and i made the program on linux, that would be the problem.

    i think u said i can take the code and use it on winxp by complining it in winXP... do i use dos edit program to do that and if so how do i do it?... like what kinda file do i save the code as.. then how do i compile it? thanks:)
    Lots of hoops being jumped through there, but, yes, if it was compiled on Linux then you cannot run it on XP. Though, you don't need to give a Linux executable a .exe extension, so maybe that's a bad habit -- you should probably only give DOS/Windows executables a .exe extension and avoid the confusion.

    The source file is in text, so any text editor should do -- I'm even taken to using a DOS port of vi I found several years ago. The only other thing you need is a C/C++ compiler for XP. Fortunately, there are many free ones; many of them are listed on compilers.net at http://www.compilers.net/Dir/Free/Compilers/CCpp.htm . I personally use the MinGW port of gcc which comes with Dev-C++ (though I never use the Dev-C++ IDE; just personal preference). I also only use Windows 98SE/ME/2k, but I haven't heard of any problems using it on XP (which I'm given to calling "FP" for "Fisher-Price" -- sorry, I'm not impressed with it, though it might actually have some nice features).

    The second thing you need to keep in mind is that business with text files being slightly different between DOS and UNIX. I use a utility called tofrodos which converts either way; conventional usage is to copy it to two files, fromdos and todos, and depending on which name was used it will convert from DOS to UNIX or from UNIX to DOS. The distribution includes binaries for Windows/DOS and source for UNIX/Linux. Here is a link to the utility: http://www.thefreecountry.com/tofrodos/index.shtml .
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    Ok, heres something that wont work


    this is one of my hwk assignments, it works when i compile it using the c++ command in linux, but i can only run it on linux! i wanna use it at home on my win XP comp, what do i do change the code or compile differently?



    //***********************************************
    //Program Hal
    //This program contains several syntax errors. Once the errors
    //are corrected, it deomonstrates simple input and output operations
    //***********************************************

    #include <iostream>

    using namespace std;

    int main()

    {

    const string computer_name = "HAL";
    string first_name;

    cout<<"Enter your first name"<<endl;
    cin>>first_name;
    cout<<"Hello "<<first_name<<" my name is "<< computer_name;

    return 0;
  12. #7
  13. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,172
    Rep Power
    2222
    The source code should work as-is (I assume that your leaving main's closing brace off was a typo). The "CRLF vs LF" issue between Linux and DOS should not be a problem. I had forgotten before and just now verified by FTP'ing a file from my Linux box to Windows: ftp in ASCII mode automatically converts the end-of-line! Using xxd on a source file:
    Linux:
    [wise@pc10593 hello]$ xxd hello.c
    0000000: 2369 6e63 6c75 6465 203c 7374 646c 6962 #include <stdlib
    0000010: 2e68 3e0a 2369 6e63 6c75 6465 203c 7374 .h>.#include <st
    0000020: 6469 6f2e 683e 0a0a 696e 7420 6d61 696e dio.h>..int main
    0000030: 2876 6f69 6429 0a7b 0a20 2020 7072 696e (void).{. prin
    0000040: 7466 2822 5468 6973 2069 7320 6120 7465 tf("This is a te
    0000050: 7374 206f 6620 6d79 2066 6972 7374 2043 st of my first C
    0000060: 2070 726f 6772 616d 2075 6e64 6572 204c program under L
    0000070: 696e 7578 5c6e 2229 3b0a 2020 2072 6574 inux\n");. ret
    0000080: 7572 6e20 303b 0a7d 0a0a 0a urn 0;.}...

    Windows/DOS:
    C:\Dev\comsync2\firmware\DTF\version>xxd hello.c
    0000000: 2369 6e63 6c75 6465 203c 7374 646c 6962 #include <stdlib
    0000010: 2e68 3e0d 0a23 696e 636c 7564 6520 3c73 .h>..#include <s
    0000020: 7464 696f 2e68 3e0d 0a0d 0a69 6e74 206d tdio.h>....int m
    0000030: 6169 6e28 766f 6964 290d 0a7b 0d0a 2020 ain(void)..{..
    0000040: 2070 7269 6e74 6628 2254 6869 7320 6973 printf("This is
    0000050: 2061 2074 6573 7420 6f66 206d 7920 6669 a test of my fi
    0000060: 7273 7420 4320 7072 6f67 7261 6d20 756e rst C program un
    0000070: 6465 7220 4c69 6e75 785c 6e22 293b 0d0a der Linux\n");..
    0000080: 2020 2072 6574 7572 6e20 303b 0d0a 7d0d return 0;..}.
    0000090: 0a0d 0a0d 0a .....

    Notice how every 0a in Linux is a 0d0a in DOS. Problem solved! Well, at least it's solved using ftp; I assume that WS_FTP will behave the same. Also, it probably won't convert if you ftp in binary mode.

    So, to run your program on XP, simply recompile and run. Since you're outputting to stdout, you'd want to make it a console app. What compiler are you using? In Visual C++, I create an empty console project, copy the source file into the project's directory, and then add the file to the project. And of course I run it from DOS; if you run it from the IDE then you'd want to put an input statement at the end or else the window will close before you can see it.
    Last edited by dwise1_aol; September 25th, 2003 at 05:21 PM.

IMN logo majestic logo threadwatch logo seochat tools logo