adding a resource file manually in Dev-Cpp - c++

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

Related

Error while loading shared libraries when running executable

When I make the Makefile everything works fine, I get a library in the directory dir. And when I run "Make test" I get a testfile that I want to run. But when I want to run this file I get this weird error: ./programma: error while loading shared libraries: libprogramma.so: cannot open shared object file: No such file or directory. I have tried running the program on both WSL and Linux, but nothing makes this error go away. Can anyone help me?
Here I have my Makefile which makes the library and the executable:
INC_DIR = include
SRC_DIR = src
SOURCES = $(sort $(shell find $(SRC_DIR) -name '*.cc'))
OBJECTS = $(SOURCES:.cc=.o)
DEPS = $(OBJECTS:.o=.d)
TARGET = programma
CXX = g++
CFLAGS = -Wall -Wextra -Wpedantic -std=c++11
CPPFLAGS = $(addprefix -I, $(INC_DIR))
.PHONY: all clean debug release
release: CFLAGS += -O3 -DNDEBUG
release: all
debug: CFLAGS += -O0 -DDEBUG -ggdb3
debug: all
all: $(TARGET)
clean:
rm -f $(OBJECTS) $(DEPS) lib/*.so programma *.d
$(TARGET): $(OBJECTS)
$(CXX) $(CFLAGS) $(CPPFLAGS) -fPIC -shared -o lib/lib$#.so $^
-include $(DEPS)
%.o: %.cc
$(CXX) $(CFLAGS) $(CPPFLAGS) -fPIC -MMD -o $# -c $<
test:
$(CXX) $(CFLAGS) -L./lib $(CPPFLAGS) -MMD -o programma tests/main.cc -l$(TARGET)
Executables on Linux don't look for shared libraries in the directory they're located in, at least by default.
You can either fix that at link-time, by passing -Wl,-rpath='$ORIGIN', or at runtime, by setting LD_LIBRARY_PATH env variable to the directory with the library. (LD_LIBRARY_PATH=path/to/lib ./programma)

SFML library doesn't link with makefile compilation

I have been trying to link the SFML dlls to my windows C++ project, but I can't get it to work. I always end up with:
fatal error: SFML/System.hpp: No such file or directory
I've tried a bunch of things but nothing changes the issue.
Here is my makefile:
PROGRAM = zero_flip
OBJS = src/main.o src/Math.o src/card.o src/game_board.o src/indicator.o src/ui.o
CXX = g++
CXX_FLAGS = -O0 -g -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable
LIB_DIRS = -L./Resources/libs/
LIBS = -lsfml-system -lsfml-graphics -lsfml-window -lsfml-audio
LNK_FLAGS = $(LIB_DIRS) $(LIBS)
DEPS=$(OBJS:.o=.d)
.PHONY: all clean
all: $(PROGRAM)
-include $(DEPS)
%.o: %.cpp
$(CXX) $(CXX_FLAGS) $(LNK_FLAGS) $< -o $#
$(PROGRAM): $(OBJS)
$(CXX) $(CXX_FLAGS) $(LNK_FLAGS) $^ -o $#
clean:
rm -f $(OBJS) $(DEPS) $(PROGRAM) && clear
The "./Resources/libs/" directory contains:
openal32.dll
sfml-audio-2.dll
sfml-audio-d-2.dll
sfml-graphics-2.dll
sfml-graphics-d-2.dll
sfml-system-2.dll
sfml-system-d-2.dll
sfml-window-2.dll
sfml-window-d-2.dll
Can anyone get me unstuck please this is driving me mad.
This is wrong:
%.o: %.cpp
$(CXX) $(CXX_FLAGS) $(LNK_FLAGS) $< -o $#
This rule says it will compile a source file into an object file, but the recipe actually builds a complete executable: it will compile the source file like xxx.cpp then link it into a program named xxx.o. You need to invoke just the compiler here, not the linker, so you should not have $(LNK_FLAGS) and you need to add the -c option to tell the compiler to stop after compiling and not link.
Then you need to add an -I option to the compile line telling the compiler where to find the header files needed during compilation... in this case SFML/System.hpp.

with glfw -3.2.1 inside my work directory ,how to compile with it using makefile

I want to compile a program with makefile as bellow:
CC = g++
CFLAGS = -g -DGL_GLEXT_PROTOTYPES -I/example_01/glew -I/example_01/glfw-3.2.1 -Wno-deprecated-declarations
LDFLAGS = -lGL -lGLEW -glfw
RM = /bin/rm -f
all: main
main: example_01/src/example_01.o
$(CC) $(CFLAGS) -o as1 example_01/src/example_01.o $(LDFLAGS)
example_00/example_00.o: example_01/example_01.cpp
$(CC) $(CFLAGS) -c example_01/src/example_01.cpp -o example_01/src/example_01.o
clean:
$(RM) *.o example_01/src/*.o as1
But there's error :
fatal error: GLFW/glfw3.h: No such file or directory
#include <GLFW/glfw3.h>
my makefile located in
graphics/example_01
glfw-3.2.1 and glew file located in
graphics/example_01/example_01
glfw3.h located in
graphics/example_01/example_01/glfw-3.2.1/include/GLFW
example_01.cpp located in
graphics/example_01/example_01/src
So how to compile ? Thanks!
inside glfw-3.2.1
inside GLFW
Your include directory is wrong.
CFLAGS = -g -DGL_GLEXT_PROTOTYPES -I/example_01/glew -I/example_01/glfw-3.2.1 -Wno-deprecated-declarations
You should change -I/example_01/glfw-3.2.1 to -I/example_01/glfw-3.2.1/include
It is possible that you'll need to make a similar change to the GLEW include directory.

undefined reference to `_imp___ZN2sf13TransformableD2Ev'

Ive just installed DEV-C on windows 7 starter and have managed to successfully compile a small c++ program to read an image file and then display it in a window. Im using SFML.
Ive included these references in the project directories:
SFML-2.3.2\include
SFML-2.3.2\lib
However, it wont link. Here is the compile log. It is a bit incomprehensible to me as i am still learning how to use it.
COMPILE LOG:
vbrowse1.o:vbrowse1.cpp:(.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x5e): undefined reference to `_imp___ZN2sf13TransformableD2Ev'
collect2.exe: error: ld returned 1 exit status
HERE IS THE MAKE FILE:
# Project: vbrowse
# Makefile created by Dev-C++ 5.11
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = vbrowse1.o
LINKOBJ = vbrowse1.o
LIBS = -L"C:/Program Files/Dev-Cpp/MinGW64/lib32" -L"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -static-libgcc -L"C:/SFML-2.3.2/lib" -mwindows -m32
INCS = -I"C:/Program Files/Dev-Cpp/MinGW64/include" -I"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/SFML-2.3.2/include"
CXXINCS = -I"C:/Program Files/Dev-Cpp/MinGW64/include" -I"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" -I"C:/SFML-2.3.2/include"
BIN = vbrowse.exe
CXXFLAGS = $(CXXINCS) -m32
CFLAGS = $(INCS) -m32
RM = rm.exe -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)
vbrowse1.o: vbrowse1.cpp
$(CPP) -c vbrowse1.cpp -o vbrowse1.o $(CXXFLAGS)
C:\eyeball\vbrowse\Makefile.win:25: recipe for target 'vbrowse.exe' failed
mingw32-make.exe: *** [vbrowse.exe] Error 1
Can anyone spot the problem?
Thanks.

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.