This question already has answers here:
Standalone VS 2010 C++ Program
(5 answers)
Closed 7 years ago.
I'm trying to compile my c++ program I wrote without using .NET Framework (I needit to be, at the end, an EXE file).
These are my includes:
stdio.h, tchar.h, windows.h, string.h, iostream, thread, Wbemidl.h, memory, algorithm, WinHttpClient.h, functional , cctype, locale.
When I try to compile and run this program in VS (adding the stdafx.h) the program works just fine, but it compiles with the .NET framework.
How can I compile it without the .NET Framework? Is it even possible? (I believe it is but I'm asking anyway).
I tried to use both mingw32 in Ubuntu and code::blocks in windows. Maybe I'm doing something wrong?
Thank you.
Edit:
This question is not the same as the question you marked mine to be similar to.
I can't and I don't want to rely on the fact that the destination computer has redistributable packages or .NET or some MSVCP. In the end, this program should work on Windows XP and above and on most of the Linux distributes.
Please, I need your help. I might said something wrong earlier in this topic, and I'd like you to explain me my mistakes and also, I still need your help to compile this.
I tried to change the settings you told me on VS, to /MT in the code generation settings, but it gave me even more errors that it cannot open some source files, which makes even more error.
I thought about leaving VS 2015 and move to code::blocks on Ubuntu, even compiling with the MingW32 itself, but it writes me "undefined reference to..." 49 times (all the functions defined in the header files I included).
I'd really appreciate any help.
Do you actually know, what the difference between .NET and WinApi is?
If you plan to code without .NET you should have a look at win32developer.
An alternative would be to use Qt, which I warmly recommend you to use.
.NET provides many functions for networking and window handling etc. like Java but it is WINDOWS ONLY and since you don't want to depend on .NET you have to either implement it yourself or get another package like I suggested above.
Related
This question already has answers here:
Can I program for Macs without owning one?
(3 answers)
Closed 3 years ago.
Recently I have been working on creating a game using Visual C++ 2017 and SDL2. I want to make my game accessible to users on all different kinds of systems, not just Windows. I tried starting with making my game also usable on Mac OS, but I cannot figure out any ways of doing this. I figured the best method would be to get Visual Studio to compile my code into a file type like ".APP" rather than ".EXE" since I don't own any form of Mac or Apple computer that can use software made to create apps for Mac. However, I cannot figure out how to change the options in Visual Studio to compile the code into a different file type or even if doing so is possible.
I've searched all over the internet for methods of converting ".EXE" to other file types, using different C++ compilers for compiling into Mac-compatible files, etc. but I haven't been able to find anything that works without requiring a virtual machine or having a physical Mac computer (neither of which I've tried yet since it would take a lot of effort and I'd like an easier solution).
If anybody could tell me how to change the type of file that Visual Studio compiles your code into or if they could suggest a different compiler that works on Windows, is compatible with SDL2, and can compile C++ code into file types that work on Mac computers like ".APP", that would solve my problem. Thank you in advance!
You need to compile your code on all the different platforms you want to support. Using a compiler supported on each of those platforms.
Code compiled on one platform can not run on another (except cross compiling, see below, but that's painful).
Cross compiling is an option on some platforms and with some compilers, but it's usually more pain than gain if you can in any way set up a local tool chain. Cross compilers generate code for a different platform than you are currently running, but getting that working can be hard. And you then also have no way to test your code on the target platform (unless you have one, in which case native compiling would just be easier in the first place).
You should automate the building of your code on different systems with different compilers in your Continuous Integration systen (CI) btw. So you always know after you push a commit, on what platforms it fails and why.
Easiest way forward (IMHO): Buy a cheap Mac. Buy a cheap PC and install Linux on it. Setup a CI system to build all code you commit to your code repository on all your systems (Windows, Mac, Linux) and make it scream at you when the build fails. Also use that system to build installable packages for each platform and again, scream when that fails.
Do the same for all your unit tests.
That's the only serious way to go forward supporting multiple platforms.
I am trying to port a piece of software from Linux to Windows. Actual software is written primarily in C++ and significant code is in C language. I tried to compile this code using Visual Studio 2012 (because I am using windows 2007) but at linking time I am getting many errors which says the function calls in C files are unknown entries. This software compiles, links and run fine on Linux so there are no issues with include of or anything silly like that.
Has anyone run into this issue? Does anyone know how to resolve it?
Please note that I have to do a native port so cygwin or other mingw are not options for me.
Thanks for your help in advance.
Chances are, you are using some kind of Linux-specific library. The most obvious example would be unistd.h, which doesn't really have a direct equivalent in Windows.
Firstly, please forgive my ignorance regarding these matters, I have done a search and not found any comprehensive answers as of yet.
I plan on learning how to develop for Windows, however I am very fond of the GNU toolchain and don't really want to move onto using big environments like Visual Studio until I feel more comfortable with the underlying basics.
From what I understand, one can download the Windows SDK, which contains the headers and libraries needed to build native Windows applications.
Is the SDK literally just a collection of libraries and headers? If so, as my logic goes, it should be possible to point MinGW towards these libraries/headers, and simply build as normal.
When I build using Visual Studio, I can't see what preprocessor directives are being defined, what is being linked in etc. etc., as I am still learning, I like to be able to know exactly what is going on, preferably so I have to manually define, link etc. Hence the question.
So, what I want to know: is my logic correct?
Again, apologies if the question is rudimentary, I am still learning.
P.s. I am planning to develop Windows applications in a windows environment, this is not a question regarding cross-compilation.
Thanks!
MinGW is not compatible with the official Windows SDK, with one of the reasons
being that the SDK contains many VS-specific things (opposed to the GCC base
on MinGW). MinGW has adapted many of the necessary files, and for many programs
this is enough.
You don´t need to know the VS project settings for some program;
MinGW is still GCC in the core and used as such. If you can compile
programs with GCC on linux, learning how to use MinGW won´t be hard.
If you need functions/structures/etc. which are not yet part of it,
you´re out of luck, other than doing the adaption yourself, which
can be everything between very easy or very hard, depending on the case.
Additionally, proper thread usage is a bit quirky (has some "hidden" pitfalls,
which could go unnoticed in an actual program for years, but then...).
(While this is a disadvantage to VS, you´ll get C++11/14 (while VS hasn´t
even finished with 11, see link), better optimzation in many cases etc.)
If you´re choosing what exactly to download, look at WinGW-W64 instead of
the "original" old one. The original project somewhat stopped, has poor
lib support compared to W64, no 64bit compiler etc. (and don´t misunderstand
the "W64", it can be used for 32bit programs too)
I am used to Java and Eclipse, as that was what I first programmed with. That said, in Eclipse, when debugging Java, you can make code changes, and save them, while the code is running. The changes to the code will then take effect in the debug window, without a change to your code.
I am wondering if you can do the same thing, or similar with C++. I am currently using Code::Blocks, and I'm wondering if there is a debugging plugin for it that does the same thing, or similar. I know about Edit and Continue in VS, but I would really rather stick with Code::Blocks. Also, I have not programmed C++ in Eclipse yet, and will hot swapping C++ work in Eclipse? Or is that a Java feature?
What you're looking for is a feature of the entire toolchain, including the compiler, linker, loader, and debugger. Visual C++ has this feature because Microsoft has made all its tools work together to support it. Similarly, the same effort has been spent to make Java work this way.
As far as I know, Code::Blocks is just an editor but delegates the compiling and linking to other compilers (without specifically integrating with their features).
Java is JIT compiled (just in time, compiled at runtime) making this feature, perhaps not trivial, but not as significant a challenge as it is to implement in a C++ environment. I've been developing in Visual Studio for 10+ years now, and to be honest, I find edit and continue rather useless.
As to having it in Code::Blocks, gcc would have to support incremental compilation before this was put significantly on the agenda of many C::B users. There was a project to add this functionality, but I'd say at this stage, you're out of luck.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Cross platform programming
I've written some code using wxwidgets in c++. But I am not able to compile the same code for both windows and linux. Actually I'm a bit scared by the preprocessor directives generated by code-blocks ide. I wonder if anyone could point out some nice tutorials for learning cross-compilation.
Thanks in Advance
Jvc
If you want to build a cross platform program, you will stumbl across a few kind of problems.
Cross compilers problem
Some compilers are offering non-standard functionalities that might not work on other compiler. You have to make sure that compiler functionnalitie's you use are standard or available on all the compilers you use (An exemple would be the VC++ #pragma that wasn't usable on gcc until version 4.2.1)
Platform specific functions and libraries
Guess what, if you include <windows.h> it won't compile on a linux system (this is madness I know). So you must try to avoid those platform specific libraries/function. If you ever have to use them, try to encapsulate their use and select the specific class you need to compile on different system.
Here is a wonderful guide posted by the Mozilla foundation :
https://developer.mozilla.org/en/C___Portability_Guide
You could have a look at Cross Compiling wxWidgets Applications on Linux (Code::Blocks wiki) and Cross-Compiling Under Linux (wxWiki). There is also a section on cross compiling Windows applications in Brent W. Woodruff C++ Introduction to wxWidgets.