Like Tree3Likes

How to make my compiled C exe run on different computers?

This is a discussion on How to make my compiled C exe run on different computers? within the C Programming forums, part of the General Programming Boards category; I have made a c file, using windows and gnu gcc compiler and it runs, but only on my computer. ...

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    8

    How to make my compiled C exe run on different computers?

    I have made a c file, using windows and gnu gcc compiler and it runs, but only on my computer. Is t posible to make it run on other computer. BTW using codeblocks.

    Thanks!

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    what does it do on other Windows computers? does it give you an error message or what?

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    You mean it doesn't run in a computer with the same OS and the same CPU as yours?!
    Devoted my life to programming...

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    2,577
    Yes, it is possible.

    Without the error, I see no way to help you.

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  5. #5
    Registered User
    Join Date
    Jun 2012
    Posts
    8
    I work at a factory and I am the it guy. This program simply backs-up user access logs via ftp, which I made in .bat, but I needed it to run without a windows and I used C. I am using windows 7 on a bootcamped macbook pro. The others are windows 7 and xp. I have downloaded .exe before and they work across different windows machines.

    Thanks again

  6. #6
    Registered User
    Join Date
    Jun 2012
    Posts
    8
    It says ""The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 or x64 version of the program, and then contact the software publisher.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Quote Originally Posted by Bruce Gregory View Post
    It says ""The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 or x64 version of the program, and then contact the software publisher.
    Usually load modules don't run on a host other than the one on which they are compiled due to differences in architecture, compilers, assemblers, shared libs, etc. So the wise thing would be to copy the source to the target machine, and compile it over there instead of copying the load module and hoping it'd work.

  8. #8
    Registered User
    Join Date
    Jun 2012
    Posts
    8
    Quote Originally Posted by itCbitC View Post
    Usually load modules don't run on a host other than the one on which they are compiled due to differences in architecture, compilers, assemblers, shared libs, etc. So the wise thing would be to copy the source to the target machine, and compile it over there instead of copying the load module and hoping it'd work.
    Thanks for your quick reply, but this is just not possible. We have well over 100 computers and I dont think the factory workers will understand this. How do other people do it? You can download any .exe from the web and it just works.

    Thanks for replying

  9. #9
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Quote Originally Posted by Bruce Gregory View Post
    Thanks for your quick reply, but this is just not possible. We have well over 100 computers and I dont think the factory workers will understand this. How do other people do it? You can download any .exe from the web and it just works.

    Thanks for replying
    A downloaded executable from the web works, but only after matching the executable to the target platform. Prior to downloading, the user selects the relevant OS and platform. Similarly you can create one executable for win 7 machines, another for xp, yet another for macbook pro and so on and so forth and then go about distributing the relevant executable.

  10. #10
    Registered User
    Join Date
    Jun 2012
    Posts
    8
    Quote Originally Posted by itCbitC View Post
    A downloaded executable from the web works, but only after matching the executable to the target platform. Prior to downloading, the user selects the relevant OS and platform. Similarly you can create one executable for win 7 machines, another for xp, yet another for macbook pro and so on and so forth and then go about distributing the relevant executable.
    I am sorry to ask anymore questions, but do you know how to do this in code blocks or possibly point me in a direction? Thank You!

  11. #11
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Bruce Gregory View Post
    I am sorry to ask anymore questions, but do you know how to do this in code blocks or possibly point me in a direction? Thank You!
    Look up "Cross Compilation".
    Or use codeblocks on the relevant systems and compile the code everywhere separately.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    2,577
    You first have to decide what systems you are going to target!

    I am guessing Windows OS only.

    But, you then must decide what version of Windows OS you will be supporting.

    You must test on each major version!!

    Platforms that must be tested (with your software) each OS Version number, 32 or 64 bits, service packs installed.

    Other software might be needed to be tested(Many old software apps required IE version 6 or above).

    The software you need is an software installer (Code::Blocks is NOT a software installer)
    Other information you MUST get; what compiler are you using!
    What version/build of the Compiler you are using!


    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  13. #13
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    You've either build a 16-bit app and are trying to run it on a 64-bit system, or you've built a 64-bit app and are trying to run it on a 32-bit system. Or you've built something not even meant for Windows.
    Either configure CodeBlocks to produce the correct executable type, or download Visual Studio Express v2008 or v2010 (I still prefer 2008) and port your code to that.
    Then make sure you learn how to statically link to the various runtime libraries.
    stahta01 and dmh2000 like this.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  14. #14
    Registered User
    Join Date
    Jun 2005
    Posts
    6,305
    Quote Originally Posted by Bruce Gregory View Post
    I work at a factory and I am the it guy. This program simply backs-up user access logs via ftp, which I made in .bat, but I needed it to run without a windows and I used C. I am using windows 7 on a bootcamped macbook pro. The others are windows 7 and xp. I have downloaded .exe before and they work across different windows machines.
    From what you describe, you are making a mountain from a molehill.

    Your later posts suggest you are using Code::Blocks. That probably means you are using a gnu compiler like MingW (common default with Code::Block as distributed). I have assumed that in the following.

    By default, Code::Blocks when running under windows 7 normally produces a 32-bit executable, which will run on any of the machines you describe. The only potential problem is that the development machine might have additional libraries installed. Your choices are then to configure your project for a static link (i.e. all libraries are bundled in the executable) or to work out what libraries you need and distribute them with your executable. I would suggest going the static link route.

    The building of a static executable depends on what compiler and linker you are using. For that you need to read the compilation for the compiler (say MingW).

    Before trying to distribute the executable, it is a good idea to test. You only need four machines for that: your development box, a bootcamped macbook pro without Code::Blocks or your compiler installed, a Windows 7 box, and and XP box. Every time you have an executable debugged and ready to go, copy it from your development box to the others, and see if it runs.

    Given that all of your operating systems are windows variants (a bootcamped macbook is actually supporting windows) I don't see the benefit in going to C, given that you started with a bat file. All you really needed to do was test the bat file on all of the box types above. But, it's not hard to build an executable that will run on the available machines, and confirm it runs on representative machines before distributing it to all end-user machines.

    If you were also having to support non-windows operating systems, then there might be some additional challenges. But all of your variants are windows boxes, so you have it easy.

    It would probably be a good idea to do some version control, particularly if any of your test machines are used by end-users.
    Right 98% of the time, and don't care about the other 3%.

  15. #15
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,261
    This program simply backs-up user access logs via ftp, which I made in .bat, but I needed it to run without a windows and I used C.
    I dont think the factory workers will understand this.
    O_o

    I don't know if I'd give you that label "IT guy" if you are relying on other people to do any job manually that must be done as way to preserve logs in the case of fault.

    As grumpy says, this isn't a thing you need to use C to do. You need to do it with scripts appropriate to the systems in play. You need to do it as both a "login script" and "cron job" (running as protected user).

    [Edit]
    By the by, if you are really doing this just to get rid of the console/terminal window (as your post history implies) you should be aware that such a tool exists for pretty much every system that can be run from a script.
    [/Edit]

    Soma
    Last edited by phantomotap; 06-12-2012 at 02:11 PM.
    antred likes this.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why do pre-compiled headers make my build take longer?
    By cpjust in forum C++ Programming
    Replies: 5
    Last Post: 02-22-2011, 11:44 AM
  2. Replies: 1
    Last Post: 03-12-2008, 12:10 AM
  3. I don't get >8 bit computers
    By jrahhali in forum Tech Board
    Replies: 7
    Last Post: 02-09-2006, 10:15 AM
  4. Can Computers Think?
    By Ben_Robotics in forum A Brief History of Cprogramming.com
    Replies: 78
    Last Post: 07-04-2003, 12:14 PM
  5. First computers
    By itld in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 11-15-2001, 07:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21