简体   繁体   中英

Will a program written in visual studios 2017 run in a linux or unix environment?

I'm currently very confused about something. I'm currently programming in C, and I'm confused about whether or not that counts as a Unix or Linux environment. Do I actually need to download a port of linux or am I good to use visual studios? The problem is the program I write will be graded via linux/unix.

There isn't a short answer to your question. Consider:

  • Visual Studio 2017's C++ toolchain, by default, only generates Win32 PE executable files ( *.exe , *.dll , etc) which only run on Windows Vista or later (Windows XP support requires an optional VS component).
  • Linux cannot run these Win32 PE executables by default, though you can install Wine to attempt to run them on Linux installations on the same CPU instruction set. Wine enables Linux to run Win32 PE executables and also provides a Windows-like runtime environment (registry, simulated C:\\Windows path, etc) for them to run in: https://www.winehq.org/
  • Visual Studio 2017 can cross-compile to Linux, macOS, iOS and other operating systems using two different approaches:
    • Visual Studio 2017's preferred method is to use remote build-servers: you would have a Linux or Macintosh computer on your local network that runs a build agent process which then builds the software on that remote machine, keeping the build toolchain on the Linux/Mac, and even debugging support by running the program on the remote machine with a remote debugger attached.
    • The other approach is to use a custom makefile using a cross-compilation toolchain running on your local machine. You may need an environment like Cygwin or MINGW installed.
  • Excepting Wine, all other options assume your C++ code is actually portable: that you don't use any platform-specific APIs (ie you stick to the C++ standard library) or that you are using platform-specific APIs with conditional compilation.
  • Also remember that "Linux" is not a single platform: a binary executable built for Ubuntu 16.0 x64 might not work on RedHat x64, and especially won't work on FreeBSD or OpenBSD (which are not Linux, but a form of Unix).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM