CrazyEngineers
  • Hi, I am using gcc compiler to compile the program and build an exe
    I used this command to compile
    gcc program.cpp -g -o program (generates program.exe and runs fine)
    But, if i write the same thing in system("gcc program.cpp -g -o program"); programmatically, then the exe is generated but, while running it I get a prompt saying "the exe is not compatible...... make see whether you need 32 bit or 62 bit"
    I'm using dev c++ for the program! any solutions??
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Abhishek Rawal

    MemberAug 9, 2013

    You have to use g++ not gcc for C++ programs.

    g++ prog.cpp -o prog

    You can use gcc too, but you have to mention C++ std libs i.e -lstdc++
    I prefer using g++ instead.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    You have to use g++ not gcc for C++ programs.

    g++ prog.cpp -o prog

    You can use gcc too, but you have to mention C++ std libs i.e -lstdc++
    I prefer using g++ instead.

    As far as i know, g++ is only for compiling not to generate an exe... 😒 anyway, I'll try and get back here!

    actually, gcc is also working fine if I do it in cmd. but when I'm using system() in my program, i get that prompt!
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    You have to use g++ not gcc for C++ programs.

    g++ prog.cpp -o prog

    You can use gcc too, but you have to mention C++ std libs i.e -lstdc++
    I prefer using g++ instead.
    Okay, I tried g++ too. same thing happens!
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Cd to directory where executable file is stored then ./exefile

    Doesn't this ^ executes the program ?
    Well from what I tested in Linux, gcc doesn't compile C++ program but g++ do.
    And it executes the program easily.
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Test with gcc (error in compiling) :
    1

    Test with g++ (successful compiling & executing) :
    2

    How you compiled without using -lstdc++ with 'gcc' ? 😨
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    Cd to directory where executable file is stored then ./exefile

    Doesn't this ^ executes the program ?
    Well from what I tested in Linux, gcc doesn't compile C++ program but g++ do.
    And it executes the program easily.

    through command prompt, if i go to the location where my .cpp file is, and use any of gcc or g++ commands, i get the .exe file and it runs.
    but coming to the programming, when I use the

    system("g++ program.cpp -o program");

    then program.exe is created but when i run it either by program or manually by double clicking or through command prompt, i get this message!

    "The version of this file is not compatible with the version of windows you are running. Check your computer's system information to see whether you need an x86 or x64 version of the program, and then contact software publisher"
    I think I explained everything now!
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Vishal0203
    when i run it either by program or manually by double clicking or through command prompt, i get this message!

    "The version of this file is not compatible with the version of windows you are running. Check your computer's system information to see whether you need an x86 or x64 version of the program, and then contact software publisher"
    I think I explained everything now!
    In Linux we can't open .exe file extension by double-clicking it, hence I have never tried executing like that for any C/C++ programs.

    Maybe Windows user can help you then.
    Sorry,mate.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    Test with gcc (error in compiling) :
    1

    Test with g++ (successful compiling & executing) :
    2

    How you compiled without using -lstdc++ with 'gcc' ? 😨

    This is what I'm getting all the time!! used both gcc and g++
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    g++ -o program.exe program.cpp

    The type : program

    This should work!
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    Just type program in CMD shell.
    same... It's pissing me off now! 😕
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Vishal0203
    same... It's pissing me off now! 😕
    Edited, try this :

    Abhishek Rawal
    g++ -o program.exe program.cpp

    Then type : program

    This should work!
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    Edited, try this :

    Its similar to what i typed before
    there is no difference in
    g++ program.cpp -o program
    g++ program.cpp -o program.exe
    and
    g++ -o program.exe program.cpp

    -o
    is just for giving the name to exe file generated if we don't write -o then a.exe will be created since it is default..
    all the three commands show the same message
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Well I know that, right ?
    I am just using Trial & error method, if by any miracle it helps you out (which shouldn't logically) & solves your problem.

    However,
    It shouldn't compile when you use 'gcc' without using -lstdc++ but it is happening in your case because it simply can't link without using that (-lstc++), unless you use g++.

    I don't know, but I think there might be problem in installing gcc properly. Or some libraries are missing ?
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    I'm using the things which came along with the dev-c++ ... the bin folder already consist of all the dll's necessary! and compiling the program through dev has no problems.... it arises only in cmd
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Vishal0203
    it arises only in cmd
    So, only last thing comes in my mind is :
    Run CMD.exe as administrators.
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    So, only last thing comes in my mind is :
    Run CMD.exe as administrators.
    or may be its a problem with OS
    Are you sure? This action cannot be undone.
    Cancel
  • Abhishek Rawal

    MemberAug 9, 2013

    Vishal0203
    or may be its a problem with OS
    Could be. Have you tried this in any other PC ?
    Or simply switch to Linux 😁
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 9, 2013

    Abhishek Rawal
    Could be. Have you tried this in any other PC ?
    Or simply switch to Linux 😁
    haha.. that would be the last option! anyway, thanks for your patience!
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberAug 9, 2013

    Vishal0203
    haha.. that would be the last option! anyway, thanks for your patience!
    Actually I think it is the compatibility problem, my guess is that u are using Windows 7 (maybe 64 bit) so the exe being created is not compatible, so if u need to run this, you can run this exe in windows XP (see if some friend of yours have XP installed, then take this exe, and run on his computer), or using virtualbox (with XP).
    Hope it helps
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberAug 10, 2013

    rahul69
    Actually I think it is the compatibility problem, my guess is that u are using Windows 7 (maybe 64 bit) so the exe being created is not compatible, so if u need to run this, you can run this exe in windows XP (see if some friend of yours have XP installed, then take this exe, and run on his computer), or using virtualbox (with XP).
    Hope it helps
    come on! I'm not that dumb 😛
    I know I'm using 32 bit OS.. so it must work fine!
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberAug 10, 2013

    Vishal0203
    come on! I'm not that dumb 😛
    I know I'm using 32 bit OS.. so it must work fine!
    Yes u r not! but once I faced a similar problem, and it happens when the program being used have some 16 bit dependencies, I once faced similar issue, I was using Win 7 32 bit at that time, seemingly it didn't supported the program, but that program ran in XP 😲
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register