error when trying to compile with MinGW: cannot execute cc1plus - c++

I did a clean install of MinGW on Windows 7 32bit with the GUI Installer, and installed
ming32-base-bin
mingw32-gcc-g++-bin
msys-base-bin
When trying to compile a simple "Hello World.cpp" from the cmd.exe i get the error:
C:\Users\Lorenzo\Desktop>g++ "Hello World.cpp" -o"Hello World.exe" -m32
g++: fatal error: cannot execute 'cc1plus': CreateProcess: No such file or directory.
compilation terminated.
The weird thing is that by grabbing the file from the desktop and putting it over g++.exe (so that i open the file with the application) in the MinGW directory, i don't get any error.
A temporary fix i found was to have a new environmet variable pointing in the folder where cc1plus is (C:\MinGW\libexec\gcc\mingw32\9.2.0). The program runs but doesn't include the libraries from C:/MinGw/lib and C:/MinGw/Include, i have to include those manually, which shouldn't occur (i guess).
I don't want to do this crude fix since i know i'll encounter some other problems with time.

Ok. I found the solution with some luck.
It is as simple as adding .exe to g++
> g++.exe *input file* -o*output.exe*
Don't Know if it's a bug or not, but this works for me.

I'm not sure which MinGW you used exactly, but it's better to use MinGW-w64.
There is a standalone build you can get from http://winlibs.com/ that doesn't require installation. The site also gives some instructions on how to use it.

Related

VS Code building .exe files in Windows 10, how do I change to build for windows 10 compatibility

So I am having trouble building my .exe files in visual studio code for my current windows OS. for some reason, my .exe files, when I run a diagnostic on them, seem to only be compatible for windows 8, not 10.
Using
Processor architecture: AMDx64
system: x64 based PC
VS code version: 1.74.3
When creating a simple "Hello World" application I tried following this tutorial, and it didn't have any problems. It was when I followed the tutorial for importing external libraries that the problems ocured.
I’ve tried importing an external library, and used msys2 to install the files in the bin/include/lib folders for mingw64.
I set my include path to the include folder, and I’ve set my compiler to default. My JSON tasks document appears correct, and when I build the .exe file, it builds successfully… but it only builds an executable file compatible for windows eight
I ran the properties compatibility test, and this is the output I get
What exactly do I need to do in order to change the OS version to make it compatible to run on both the visual studio code terminal, and my system terminal as well?
the following is the output once I ran the build process
Starting build...
C:\msys64\mingw64\bin\cpp.exe -IC:\msys64\mingw64\include -fdiagnostics-color=always -g "D:\Documents\C++\VS_Code\FMT Import\FMTImport.cpp" -o "D:\Documents\C++\VS_Code\FMT Import\FMTImport.exe" -lfmt
>Build finished successfully.
edit:
config name:C:/msys64/mingw64/bin/g++.exe
compiler path: C:/msys64/mingw64/bin/g++.exe
intellisense mode: ${default}
edit 2:
running terminal attempts to build..
for g++
D:\Documents\C++\VS_Code\FMT Import>g++ -o FMTImport FMTImport.cpp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\William\AppData\Local\Temp\ccshGhdE.o:FMTImport.cpp:(.text+0x8c): undefined reference to `fmt::v9::vprint(fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)'
collect2.exe: error: ld returned 1 exit status
for clang++
D:\Documents\C++\VS_Code\FMT Import>clang++ FMTImport.cpp -o FMTImport
FMTImport.cpp:1:10: fatal error: 'fmt/format.h' file not found
#include <fmt/format.h>

Program won't start because libmpc-3.dll is missing

I'm trying to compile c++ code in Notepad++. The command I'm running is as follows in the Program to Run box.
C:\MinGW\bin\g++.exe -o "$(NAME_PART)" "$(FULL_CURRENT_PATH)"
I get the error saying "The program can't start because libmpc-3.dll is missing...". I checked the MinGW file path and the libmpc-3.dll file is there in the bin folder.
Why would it say the file is missing, or is there something wrong with my command?
Please take a look at this solved question:
MinGW gcc -> libmpc-3.dll missing on 64-Bit Windows 7
Maybe it helps you.

Compiling DISLIN gfortran

I am having trouble compiling Fortran code with references to DISLIN. I have downloaded DISLIN from the website, unzipped the file and ran the setup. I have added an environment variable called DISLIN (C:\dislin) and added C:\dislin\win to the PATH section of my system variables.
I am trying to compile some example code of the DISLIN website which includes line
USE DISLIN
I am using a MinGW shell to compile with command gfortran -o progrname -ldislin EX11_1.f90 and am getting the following error:
Fatal Error: Cant open module file 'dislin.mod' for reading at (1): No such file or directory.
I have tried changing the variable path and even moving the dislin.mod file (which is there) but still get the same message.
Ok I fixed this problem so thought I come back and post what worked for me incase any one else needs it...
Install both DISLIN and MinGW on the c drive
Copy disgf.a from /c/dislin and dislin.f90 from /c/dislin/gf into the directory containing your fortran files
(for me this is /c/MinGW/pnote)
Using the MinGW shell navigate to you files: cd /c/MinGW/pnote
compile dislin.f90 and your fortran program: gfortran -c dislin.f90 progName.f90 (dislin.f90 obviously only needs to be done once)
link libraries etc and compile: gfortran progName.o disgf.a -luser32 -lgdi32 -lopengl32 -o exeName
'run' exeName
You probably need to specify the path to the DISLIN module files:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules
and, if not already configured like described here, also the path to the library itself:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules \
-L/path/to/DISLIN/library
They provide a batch file (windows) to do the compiling and linking for you.
f90link -c My_Program
This is located in c:\dislin\Win
Also, if you are having trouble with the dislin.mod file which resides in c:\dislin\gf then recompile that with the -c compile option. I found all of this info in c:\dislin\readme.inf
near as I can tell (Jan 2018) dislin (64 bit) fails miserably with gfortran 7.2, period; and probably with many other newer compilers.
When trying to link, gfortran 7 says 'dislin.mod' is an unrecognizable format.
I think this program is highly dependent on exactly correct version synchronization - something that renders such software useless imho after many years in research.
and no, the correctness of various 'paths' seems not to help.
after all, gnuplot works, "at all". Not sure why I spent so much time on brand x.
jrc

dev c++ compiler error

i am getting this error at compile (actually this is a very simple project and the syntax is absolutely ok)
E:\proj1\Makefile.win [Build Error] [main.o] Error 1
this is my compiler log (dev c++ v 4.9.9.2)
Compiler: Default compiler
Building Makefile: "E:\proj1\Makefile.win"
Executing make...
make.exe -f "E:\proj1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
'C:\Users\r' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
make.exe: *** [main.o] Error 1
Execution terminated
my user path is 'c:\Users\r&d', i think the '&' is makeing trouble in compile process , does anybody has any idea ?, i can not reinstall windows because i have got many softwares installed on my current windows and it is very time consuming to me, how can i fix this /
r&d is definitely a problem. Try surrounding it with quotes: "c:\users\r&d" and hope for the best. If it doesn't work, change the folder to something without an ampersand (you don't need to reinstall Windows for that, just create another user).
You can try creating another user without the ampersand, and then copying your profile to it to keep all your settings and application preferences, as well as documents.
You might want to try another build enviroment, like code:blocks which has its own internal build system. You probably want make sure you are using the latest gcc mingw compiler and build system from mingw(use their installer, I think it was http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20120426/ ), and even if you don't go with code::blocks, make sure you are using the new branch of devc++ that was forked and still being developed. One last thing is if you go with code::blocks, use a nightly build in the forum, http://forums.codeblocks.org/index.php/board,20.0.html as they are much more up to date.
The escape character in Windows is ^. So try
C:\Users\r^&d

calling sql from C++

my c++ program has sql code in it, and it runs fine on one linux machine but on the other, I get the following error when I compile it
g++ test.cpp -o a -L/usr/lib/mysql -lmysqlclient -lboost_date_time
fatal error: /usr/include/mysql/mysql.h: No such file or directory
compilation terminated.
I have mysql installed but I am obviously missing some step somewhere (on this machine with a new ubuntu installation)
can someone please let me know the fix. thx!
Looks like your computer doesn't have MySQL installed (in which case, install it), or is installed to a location other than /usr/include/mysql/mysql.h (in which case, change your compile command to point at the correct location)
You need to pass the location of mysql include files.
You are passing library location with:
-L/usr/lib/mysql -lmysqlclient.
If you know where mysql headers are you need to pass them to compiler using:
-I/path/to/directory/with/mysql/headers