Dev c++ mingw no longer compiles - c++

I'm using Dev C++ 4.9.9.2 and my programs stopped compiling since yesterday.
My compiler error just looks like this:
F:\Program\Makefile.win [Build Error] [Program.exe] Error 1
With the compile log messages being:
Compiler: Default compiler
Building Makefile: "F:\Program\Makefile.win"
Executing make...
make.exe -f "F:\Program\Makefile.win" all
gcc.exe Untitled1.o -o "Program.exe" -L"F:/Dev-Cpp/lib"
gcc.exe: Internal error: Aborted (program collect2)
Please submit a full bug report.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.
make.exe: *** [Program.exe] Error 1
Execution terminated
And this is my makefile for a newly made project:
# Project: Program
# Makefile created by Dev-C++ 4.9.9.2
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = main.o $(RES)
LINKOBJ = main.o $(RES)
LIBS = -L"F:/Dev-Cpp/lib"
INCS = -I"F:/Dev-Cpp/include"
CXXINCS = -I"F:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"F:/Dev-Cpp/include/c++/3.4.2/backward" -I"F:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"F:/Dev-Cpp/include/c++/3.4.2" -I"F:/Dev-Cpp/include"
BIN = Program.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
all: all-before Program.exe all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o "Program.exe" $(LIBS)
main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)
I've tried reinstalling mingw and linking a new compiler profile to it, and I've also tried reinstalling Dev C++ but this problem persists.
Both new projects and old projects that have previously compiled fine no longer compile...
Has anyone had any similar issues?

Something with the linker refused to work for me.
I installed mingw using TDM-GCC and made a new compiler profile for that, which ended up working.
I'm still at a loss for why the included mingw suddenly stopped working and didnt work properly even after reinstalling.

Related

How to adapt C++ Makefile to allow for using openmpi parallelization compiling several files into 1 executable

Just a disclaimer I'm not too experienced with Make files, so forgive me if the answer is simple! I have a Make file that compiles several .cpp & .h files into .o files, and then produces an executable. I am using g++ as the compiler currently. I'd like to adapt this file to allow for openmpi multi-core computing. To note: I'm on a Windows 11 x 64 architecture, using Cygwin to build run this cpp code. I also would like this to run on MacOS systems as well.
In particular, the parallelization macros are only in 1 .cpp file, what I'd consider the 'main' file of this project (mag_spec_tracker.cpp). I don't know if that makes a difference here but thought it could be useful to let be known.
My current Makefile is below - note I added a line to try and grab the mpicc compile flags, but I am unsure on how to use them here.
IDIR = include
CXX = g++
CXXFLAGS = -I$(IDIR) -std=c++17
ODIR = obj
_DEPS = my_functions.h particle.h beam.h threevector.h threematrix.h screen.h magnet.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = my_functions.o particle.o beam.o mag_spec_tracker.o screen.o magnet.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.cpp $(DEPS)
$(CXX) -c -o $# $< $(CXXFLAGS)
run: $(OBJ)
$(CXX) -o $# $^ $(CXXFLAGS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(IDIR)/*~
I have tried adding lines into the Makefile to get the mpi compile flags based on other reference I've found online, but was unsure how to adapt my current code to add these flags to allow for correct usage of openmpi. The lines I added to grab compile flags were:
MPI_COMPILE_FLAGS = $(shell mpicc --showme:compile)
MPI_LINK_FLAGS = $(shell mpicc --showme:link)
Thank you in advance!
Update (12/6/2022)
Responding to the comment from Matzeri ('for opempi the compiler is mpicc not gcc. for c++ is mpicxx not g++'), I replaced 'g++' in my makefile with 'mpicxx' and recieved the following error:
$ make
mpicxx -c -o obj/mag_spec_tracker.o mag_spec_tracker.cpp -Iinclude -std=c++17
mpicxx -o run obj/my_functions.o obj/particle.o obj/beam.o obj/mag_spec_tracker.o obj/screen.o obj/magnet.o -Iinclude -std=c++17
C:/Users/Jason/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmpi_cxx: No such file or directory
C:/Users/Jason/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmpi: No such file or directory
C:/Users/Jason/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopen-rte: No such file or directory
C:/Users/Jason/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopen-pal: No such file or directory
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:19: run] Error 1
I notice that its looking for an ld executable in 'mingw64'. I tried removing that directory (previously I had installed mingw64, but switched to cygwin), and got the following error:
$ make
mpicxx -o run obj/my_functions.o obj/particle.o obj/beam.o obj/mag_spec_tracker.o obj/screen.o obj/magnet.o -Iinclude -std=c++17
--------------------------------------------------------------------------
The Open MPI wrapper compiler was unable to find the specified compiler
g++ in your PATH.
Note that this compiler was either specified at configure time or in
one of several possible environment variables.
--------------------------------------------------------------------------
make: *** [Makefile:19: run] Error 1
I also added c:\cygwin\bin to my environment paths, and this issue still occurs. I confirmed that mpicxx is in that bin folder.
Any ideas?

How to make an object file in a different folder with c++ and a makefile

When I run my code I get the error
g++ -c -o main.o main.cpp
g++ -I -o obj/main.o -lm
g++ error: obj/main.o: No such file or directory
makefile:21: recipe for target 'main' failed
make: *** [main] Error 1
In my file structure I have a folder with everything in it so I am trying to make some subdirectories and organize everything a little bit. I am trying to get the object file (main.o) to go into an obj folder instead of staying in the base folder as it currently is.
I can't figure out what is going wrong in my makefile and can't find where some of this is being executed and am extremely new to c++ and make. My code is pasted below.
IDIR=../include
CC = g++
CFLAGS = -I
LDIR = ../lib
ODIR= obj
LIBS = -lm
_DEPS = add.h multiply.h
DEPS = $(patsubst %, $(IDIR)/%,$(_DEPS))
_OBJ = main.o
OBJ = $(patsubst %, $(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: $(OBJ)
$(CC) -c $(CFLAGS) $< -o $#
main: $(_OBJ)
$(CC) $(CFLAGS) -o$(OBJ) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
I haven't read any specific documentation as I have been teaching myself by simply searching the internet for tons of small bits from many different sources. I am using Windows 10 with visual studio code as my compiler and make g++ as my make utility. I apologize for commenting on my own question as this is my first time using Stack Overflow and didn't know I could get in trouble for commenting. I am sorry for causing a mess.
g++ -c -o obj/main.o main.cpp
you must provide the path for the output file

adding a resource file manually in Dev-Cpp

I am making a simple Win32 C++ game and when I made a header file and a resource file once I compiled it I had an error message from the compile log wich said "*** missing separator. stop"and it was from the make file in the line that had my new resource file.
This is not the first time I try to make a resource file as I did it with another simple apps and it worked fine but now with this application it didnt work also I checked the makefile from another aplication and they had the same syntax.
Any help would be appreciated.
And by the way im using Dev-Cpp ide and compiler if that may help you find a solution for my problem.
**Edit:**The makefile code is:
# Project: Win32 Game 1
# Makefile created by Dev-C++ 4.9.9.2
CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe
RES = Win32_Game_#1_private.res
OBJ = WinMain.o $(RES)
LINKOBJ = WinMain.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -mwindows -lgmon -pg -g3
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -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"
BIN = "Win32 Game 1.exe"
CXXFLAGS = $(CXXINCS) -pg -g3
CFLAGS = $(INCS) -pg -g3
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
all: all-before "Win32 Game 1.exe" all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o "Win32 Game 1.exe" $(LIBS)
WinMain.o: WinMain.cpp
$(CPP) -c WinMain.cpp -o WinMain.o $(CXXFLAGS)
Win32_Game_#1_private.res: Win32_Game_#1_private.rc Settings.rc
$(WINDRES) -i Win32_Game_#1_private.rc --input-format=rc -o Win32_Game_#1_private.res -O coff
Settings.rc is the resource file that im trying to add

makefile Recipe for target failed in Dev C++

I am using Dev C++ v5.5.3
I have just written the code for the program and the makefile was generated by Dev C++.
I don't know anything about Makefiles. Here is the makefile generated by Dev C++.
I keep getting the error "recipe for target 'Dialogs_Private.res' failed".
Please help
# Project: Dialogs
# Makefile created by Dev-C++ 5.5.3
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES = Dialogs_private.res
OBJ = Main.o $(RES)
LINKOBJ = Main.o $(RES)
LIBS = -L"C:/Program Files/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc
INCS = -I"C:/Program Files/Dev-Cpp/MinGW32/include"
CXXINCS = -I"C:/Program Files/Dev-Cpp/MinGW32/include"
BIN = Dialogs.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)
Main.o: Main.cpp
$(CPP) -c Main.cpp -o Main.o $(CXXFLAGS)
Dialogs_private.res: Dialogs_private.rc dialogResource.rc
$(WINDRES) -i Dialogs_private.rc --input-format=rc -o Dialogs_private.res -O coff
From your generated makefile we can find you are using your own resource script.
Dialogs_private.res: Dialogs_private.rc dialogResource.rc
DevC++ will generate a resource script(ProjectName_private.rc, in your case, is Dialogs_private.rc) and make a resource file(ProjectName_private.res) via that script. in your case, this generated Dialogs_private.rc file may like this:
/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
/* DO NOT EDIT! */
#include "dialogResource.rc"
As you can see, it just included your dialogResource.rc. DevC++ will try to compile it. if your resource script have some error, then it can not be compiled. Then you will see an error that tell you recipe for target 'Dialogs_Private.res' failed .
You should check your own resource script and have a look if there is any error in your script file. For example, are you missing some resource you are going to compile but you forget to place the resource file to the correct path? After all your own resource script compiled successfully, this error will be fixed.

Makefile issue with compiling a C++ program

I recently got MySQL compiled and working on Cygwin, and got a simple test example from online to verify that it worked. The test example compiled and ran successfully.
However, when incorporating MySQL in a hobby project of mine it isn't compiling which I believe is due to how the Makefile is setup, I have no experience with Makefiles and after reading tutorials about them, I have a better grasp but still can't get it working correctly.
When I try and compile my hobby project I recieve errors such as:
Obj/Database.o:Database.cpp:(.text+0x492): undefined reference to `_mysql_insert_id'
Obj/Database.o:Database.cpp:(.text+0x4c1): undefined reference to `_mysql_affected_rows'
collect2: ld returned 1 exit status
make[1]: *** [build] Error 1
make: *** [all] Error 2
Here is my Makefile, it worked with compiling and building the source before I attempted to put in MySQL support into the project. The LIBMYSQL paths are correct, verified by 'mysql_config'.
COMPILER = g++
WARNING1 = -Wall -Werror -Wformat-security -Winline -Wshadow -Wpointer-arith
WARNING2 = -Wcast-align -Wcast-qual -Wredundant-decls
LIBMYSQL = -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient
DEBUGGER = -g3
OPTIMISE = -O
C_FLAGS = $(OPTIMISE) $(DEBUGGER) $(WARNING1) $(WARNING2) -export-dynamic $(LIBMYSQL)
L_FLAGS = -lz -lm -lpthread -lcrypt $(LIBMYSQL)
OBJ_DIR = Obj/
SRC_DIR = Source/
MUD_EXE = project
MUD_DIR = TestP/
LOG_DIR = $(MUD_DIR)Files/Logs/
ECHOCMD = echo -e
L_GREEN = \e[1;32m
L_WHITE = \e[1;37m
L_BLUE = \e[1;34m
L_RED = \e[1;31m
L_NRM = \e[0;00m
DATE = `date +%d-%m-%Y`
FILES = $(wildcard $(SRC_DIR)*.cpp)
C_FILES = $(sort $(FILES))
O_FILES = $(patsubst $(SRC_DIR)%.cpp, $(OBJ_DIR)%.o, $(C_FILES))
all:
#$(ECHOCMD) " Compiling $(L_RED)$(MUD_EXE)$(L_NRM).";
#$(MAKE) -s build
build: $(O_FILES)
#rm -f $(MUD_EXE)
$(COMPILER) -o $(MUD_EXE) $(L_FLAGS) $(O_FILES)
#echo " Finished Compiling $(MUD_EXE).";
#chmod g+w $(MUD_EXE)
#chmod a+x $(MUD_EXE)
#chmod g+w $(O_FILES)
$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp
#echo " Compiling $#";
$(COMPILER) -c $(C_FLAGS) $< -o $#
.cpp.o:
$(COMPILER) -c $(C_FLAGS) $<
clean:
#echo " Complete compile on $(MUD_EXE).";
#rm -f $(OBJ_DIR)*.o $(MUD_EXE)
#$(MAKE) -s build
I like the functionality of the Makefile, instead of spitting out all the arguments etc, it just spits out the "Compiling [Filename]" etc.
If I add -c to the L_FLAGS then it compiles (I think) but instead spits out stuff like:
g++: Obj/Database.o: linker input file unused because linking not done
After a full day of trying and research on google, I'm no closer to solving my problem, so I come to you guys to see if you can explain to me why all this is happening and if possible, steps to solve.
Regards,
Steve
Try changing
$(COMPILER) -o $(MUD_EXE) $(L_FLAGS) $(O_FILES)
to
$(COMPILER) -o $(MUD_EXE) $(O_FILES) $(L_FLAGS)
The linker searches and processes libraries and object files in the order they are specified. Thus when you mention the libraries before the object files, the functions used in the object files may not be loaded from the libraries.
Have you tried using the built-in mysql_config --cflags and mysql_config --libs, respectively?