Can not run make command in Dev-cpp application - c++

I have a very simple example named HelloWorld and located in folder "C:/HelloWorld" in Dev-Cpp as follows:
#include <iostream>
using namespace std;
int main(){
cout << "Hello World";
return 0;
}
Of course, if I press F11 (Compile and run) then the program executes normally.
But I want to execute this program in an another way: use make command!!!
I have known that the syntax to run make command : make -f [make file name]. In Dev-Cpp, this command is make -f "Makefile.win". So I jump into HelloWorld folder and type as follows:
The console displays many errors relating to included headers.
How can I run make command without any errors? Thanks in advance.

not so easy with make :)
at first if you use msvc or DevCpp try to find "Export makefile"
at second you need to configure your compilator(s).
at third you need to show what Makefile.win contains.
man:
http://www.gnu.org/software/make/manual/make.html
gcc:
https://gcc.gnu.org/install/binaries.html

All right. There are something wrong with my make command.
The problem is I had installed two versions of gcc in my computer. The HelloWorld example is compiled and built with the latest GCC version.
However, the make command I had type is belonged to the older GCC version. As a result, it leads to many errors.
In order to run make command correctly, I must to use the right make command that is defined in Dev-Cpp (below picture): mingw32-make.exe

Related

Command line cpp compile isn't working properly

First of all, I made a simple program to test if compiling was working properly, it is as follows:
#include <iostream>
int main() {
std::cout << "Oi!";
}
Quite simple indeed, should compile properly, right? Wrong.
I am using MinGW for Windows 10, just to let you know.
I tried compiling it using "cpp <file name>.cpp -o a.exe" and was, first time, going through with the compile, but once I tried to execute the file it would send me this:
./a.exe: line 14: namespace: command not found
./a.exe: line 20: syntax error near unexpected token `('
./a.exe: line 20: ` typedef decltype(nullptr) nullptr_t;'
Clearly something was wrong, so I searched for a solution, found out someone had a similar problem and doing a reinstall solved it, so I went to the MinGW installation manager, noticed the C++ compiler library wasn't installed and installed it. It felt I was doing alright.
I also noticed that they were using g++ instead of cpp and tried that instead, it worked properly this time, but I would like to note that I have "git bash" installed, so I assume it used "git bash" 's command and not MinGW's.
So I opened cmd and tried using cpp, once I tried executing the program cmd said that the software wasn't compatible with the version of windows being executed, that doesn't sound right. I did a verbose compile with cpp and noticed this oddity:
#include <...> search starts here:
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include-fixed
End of search list.
That doesn't follow Windows's file path standard...
Does it have anything to do with the problems I am facing? I just want things to compile! ;w;
As mentioned above, you need to use g++ to compile your code. Try the command g++ --version If you get any result that doesn't include a version number you need to install g++. Here is a guide that may be helpful.
https://techsupportwhale.com/install-gcc-compiler-on-windows/

Suppress g++ warning message "resolving __ZSt4cout" on Windows 7 [duplicate]

I am trying to compile the following program:
#include <iostream>
int main(){
std::cout << "Hello, world!";
return 0;
}
When I compile it, I get this message:
C:\programs>g++ test.cpp
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-import)
c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: a
uto-importing has been activated without --enable-auto-import specified on the c
ommand line.
This should work unless it involves constant data structures referencing symbols
from auto-imported DLLs.
The build succeeds and the executable runs as expected, but this warning still irritates me. I expect a successful build to be completely silent. This message gives the false impression that there's something wrong with my code.
I can silence this error with g++ -Xlinker --enable-auto-import test.cpp, but this is undesirable, as it triples the number of characters I need to type to compile a program.
Questions:
Why does this warning appear for the simplest of programs? i don't expect cryptic warnings when I compile Hello World.
Is it possible to silence this warning without passing the flag to the linker every time? An option in a config file hidden somewhere in c:\mingw, perhaps? Or maybe I missed an "automatically enable auto-import" checkbox during installation?
Possibly Relevant Specs
GCC Version 4.5.0
ld.exe Version 2.20.51.20100613
Windows XP Service Pack 3
I used to face same problem as you do with g++. I solved this irritating problem just now. Here is how I come to the solution, step-by-step:
On Windows, you can create an alias of g++ with all given options which you want to use with g++. Say, for example, you want to create an alias s++ of g++ -enable-auto-import, then you run this on cmd as:
C:\>doskey s++=g++ -enable-auto-import
This creates an alias called s++. But this alias will not take any command line argument, which means, you cannot write this:
C:\>s++ filename.cpp //it is not working
To make it work, if you've to tell the alias to accept command line arguments while creating it, so here is how it is done:
C:\>doskey s++=g++ -enable-auto-import $*
Please note the $* at the right, which indicates that now s++ can take command line argument:
C:\>s++ filename.cpp //yayyyy..its working now, without giving any warnings!
But you may not prefer to create the alias everytime you open cmd. In that case, you can create a shortcut of cmd.
For example, I created a shortcut called Console and in the Target textbox of shortcut window, I wrote this:
C:\WINDOWS\System32\cmd.exe /K doskey s++=g++ -enable-auto-import $*
And since this is too long (horizontally), one screenshot was not able to capture the entire command. I took two screenshots so that you could see yourself how I did it:
Left part of the command
Right part of the command
For more information on creating aliases on windows, see this:
Creating aliases on Windows
I did some reading and it looks like it might be related to the mingw32 dll not having dllimport attributes defined.
Perhaps there is a patch or you can rebuild mingw32 yourself and add them?

No such file or directory "ruby/config.h" when trying to compile C++ into Ruby using SWIG

I'm trying to get a basic example running using SWIG to convert a C++ file into Ruby. I have Ruby 2.0.0p451 (64 bit version) installed and I've also installed the 64-bit DevKit. I'm running Windows 7 and trying to use swigwin-2.0.12. Finally, I am using the GCC C++ compiler supplied by Mingw-builds for the 64-bit version of Windows.
I have the basic C++ hello world program as shown below.
#include <iostream>
#include <cstdlib>
using namespace std;
main()
{
cout << "Hello World!";
system("pause");
return 0;
}
At the command prompt, I use the command:
swig -module -c++ -ruby hello_world.cpp
This completes fine and produces a file titled hello_world_wrap.cxx. However, when I receive an error when I try to compile the .cxx file using the command:
g++ -fPIC -c hello_world_wrap.cxx -IC:\Ruby200-x64\include\ruby-2.0.0
The error I am receiving is:
All the research I've done has pointed me to an installation of the incorrect DevKit, but I don't think this is my issue. I've made sure to download the 64-bit version of Ruby and the DevKit. I've checked the folder specified in the error, and there is no config.h file. I'm not sure why the config.h file does not exist or why ruby.h is trying to load it.
Any thoughts?
Check that C:\Ruby200-x64\include\ruby-2.0.0\ruby\config.h exists. If not, find it and fix the path.
Update:
Check if there is a ruby.h in the same folder. If there is then just use -IC:\Ruby200-x64\include\ruby-2.0.0\ruby\x64-mingw instead. Otherwise try adding a second -I, for this extra path. I agree with you this is a little strange (not so much the former, but definitely if you have to have two -I). The script at https://groups.google.com/forum/m/#!topic/comp.lang.ruby/RpjuvXpFI30 suggests that this might be normal, I.e. you need one -I for platform-independent headers and one for platform-dependent.

using mingw and g++ compiler

I’m trying to run my c++ files off the prompt, but nothing is showing, e.g.
C:\C++\mingw>g++ hello.cpp -o hello.exe
It seems to be bug free but nothing displays, in this case a simple hello to the terminal.
My code is a straightforward
#include <iostream>
using namespace std;
int main()
{
cout << "Hello \n" << endl;
return 0;
}
Of course, the simplest answer "Just run hello.exe" is correct. Here's some additional logic behind:
If you're used to interpreted languages, such as Python or Lua, you might have noticed that you execute them by supplying source file to the executable, as such:
python my_source.py
However, this works because each time you run python command, it reads the source file given, and then interprets it and executes appropriate machine instructions based on the file contents - it interprets the file.
C++, on the other hand, is a compiled language. The execution of g++, which is a compiler, generates said machine code for your platform, and stops there. Next time you don't need the compiler to run your program; every instruction is encoded as the machine code in the .exe file. That's why you can share your .exe file with your friend if he doesn't have a compiler, but he won't be able to execute python script without python environment installed.
g++ hello.cpp -o hello.exe // This command only produce the exe file
The executive file doesn't run automatically. You should run it by yourself.
hello.exe

Purpose of --enable-auto-import Warning

I am trying to compile the following program:
#include <iostream>
int main(){
std::cout << "Hello, world!";
return 0;
}
When I compile it, I get this message:
C:\programs>g++ test.cpp
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-import)
c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: a
uto-importing has been activated without --enable-auto-import specified on the c
ommand line.
This should work unless it involves constant data structures referencing symbols
from auto-imported DLLs.
The build succeeds and the executable runs as expected, but this warning still irritates me. I expect a successful build to be completely silent. This message gives the false impression that there's something wrong with my code.
I can silence this error with g++ -Xlinker --enable-auto-import test.cpp, but this is undesirable, as it triples the number of characters I need to type to compile a program.
Questions:
Why does this warning appear for the simplest of programs? i don't expect cryptic warnings when I compile Hello World.
Is it possible to silence this warning without passing the flag to the linker every time? An option in a config file hidden somewhere in c:\mingw, perhaps? Or maybe I missed an "automatically enable auto-import" checkbox during installation?
Possibly Relevant Specs
GCC Version 4.5.0
ld.exe Version 2.20.51.20100613
Windows XP Service Pack 3
I used to face same problem as you do with g++. I solved this irritating problem just now. Here is how I come to the solution, step-by-step:
On Windows, you can create an alias of g++ with all given options which you want to use with g++. Say, for example, you want to create an alias s++ of g++ -enable-auto-import, then you run this on cmd as:
C:\>doskey s++=g++ -enable-auto-import
This creates an alias called s++. But this alias will not take any command line argument, which means, you cannot write this:
C:\>s++ filename.cpp //it is not working
To make it work, if you've to tell the alias to accept command line arguments while creating it, so here is how it is done:
C:\>doskey s++=g++ -enable-auto-import $*
Please note the $* at the right, which indicates that now s++ can take command line argument:
C:\>s++ filename.cpp //yayyyy..its working now, without giving any warnings!
But you may not prefer to create the alias everytime you open cmd. In that case, you can create a shortcut of cmd.
For example, I created a shortcut called Console and in the Target textbox of shortcut window, I wrote this:
C:\WINDOWS\System32\cmd.exe /K doskey s++=g++ -enable-auto-import $*
And since this is too long (horizontally), one screenshot was not able to capture the entire command. I took two screenshots so that you could see yourself how I did it:
Left part of the command
Right part of the command
For more information on creating aliases on windows, see this:
Creating aliases on Windows
I did some reading and it looks like it might be related to the mingw32 dll not having dllimport attributes defined.
Perhaps there is a patch or you can rebuild mingw32 yourself and add them?