-2

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.

  • 2
    Wait what?.. `.NET` is not something that compiles your `C++` code.. Please clarify. – Hatted Rooster Jan 03 '16 at 19:48
  • @JameyD yea, but VS compiles using .NET, which means that if I want to run my program on a Windows computer that doesn't have the required .NET, it won't run. – Mr. Someone Jan 03 '16 at 19:51
  • @Mr.Someone In Visual Studio, did you choose a project that is not `.NET` related? Like a `Win32 Console` project? – PaulMcKenzie Jan 03 '16 at 19:51
  • Visual Studio can be used to create .NET C++/CLI programs, *or* unmanaged C++ projects. Why not recreate your project as an unmanaged C++ project? Then you won't have any dependencies on .NET. – Some programmer dude Jan 03 '16 at 19:52
  • @PaulMcKenzie of course. My program is a win32 console. I need to find a way to make an exe file that does not need .NET to run. – Mr. Someone Jan 03 '16 at 19:53
  • @JoachimPileborg How do I do that? – Mr. Someone Jan 03 '16 at 19:53
  • @Mr.Someone If you have an unmanaged console application then you already have no dependencies on .NET. The VC++ runtime yes, but it has nothing to do with .NET. – Some programmer dude Jan 03 '16 at 19:54
  • @JoachimPileborg Yea... that's what I thought, so after I tried to run the exe file that VS made on the computer, I saw it needed the MSVCP140.dll, that's why I tried code::blocks on windows, which couldn't make an exe file from the same main.cpp file (I included all the files I mentioned above) and I gave me so many errors that it doesn't know some definitions, so I tried mingw32 on Ubuntu and it gave me even more errors (copied all the included files, of course) – Mr. Someone Jan 03 '16 at 19:59
  • Make sure that your compiler is linking STATICALLY. If you are using mingw then you need to add: `--static --static-libgcc --static-libstdc++ -m64` to the linker flags and `-m64` to Other/Compiler Flags. If you're using VS, then you need to do `settings->C/C++->Code Generation->Runtime Library->Multithreaded (/MT)`. – Brandon Jan 03 '16 at 20:03
  • 1
    @Mr.Someone seems like your question is a duplicate of [Standalone VS 2010 C++ Program](http://stackoverflow.com/q/4998512) then. Would have been easy to answer if you told us about MSVCP140.dll right away. – AliciaBytes Jan 03 '16 at 20:06
  • 1
    @Mr.Someone also just as a note, MSVCP140.dll doesn't have anything to do with `.Net`. It's the C++ runtime, i.e. the code for `vector`, `cout`... and all the other standard functions you can use in your code. – AliciaBytes Jan 03 '16 at 20:14
  • @RaphaelMiedl, I edited my question. I hope you'll be able to help me. – Mr. Someone Jan 05 '16 at 14:16

1 Answers1

0

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.

truepaddii
  • 9
  • 1
  • 3