[Build Error] [main.o] Error 1 (makefile error)

I am using: Dev-C++ 4.9.9.2 on Win 7.

So I am working on this project. And whenever I come to compile it, I get a make file error. Its weird cuz all the other projects compiles correctly. And even when I come to copy some new short code replacing the original one, it compiles perfectly, which is making me more sure that there is some mistake in the code itself. First of all, here is the make file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Project: Project1
# 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"C:/Dev-Cpp/lib" -L"C:/SDL-1.2.15/lib" -mwindows -lmingw32 -lSDLmain -lSDL  
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:/SDL-1.2.15/include" 
BIN  = A-Engine.exe
CXXFLAGS = $(CXXINCS)  
CFLAGS = $(INCS)  
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before A-Engine.exe all-after


clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(CPP) $(LINKOBJ) -o "A-Engine.exe" $(LIBS)

main.o: main.cpp
	$(CPP) -c main.cpp -o main.o $(CXXFLAGS)


The compile log:
1
2
3
4
5
6
7
8
9
10
Compiler: Default compiler
Building Makefile: "C:\Users\user01\Desktop\A-Studios\C++\SDL\A-Engine\Makefile.win"
Executing  make...
make.exe -f "C:\Users\user01\Desktop\A-Studios\C++\SDL\A-Engine\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:/SDL-1.2.15/include"   

make.exe: *** [main.o] Error 1

Execution terminated


The project files:
http://pastebin.com/5BWq8iEJ (main.cpp file)
http://pastebin.com/p3ZjdS8A (Object.h file)

What am I doing wrong this time ?_? ???

Thanks for your time and dedication! (and sorry for the page stretch)
Last edited on
I don't know SDL so I cannot you help deeply, but perhaps I found some little syntax error on compiling main.o

first of all: careful to spaces.... between "-I" options (example between 1st and 2nd one) there are 2 o more spaces..... remember that every option must be separated by one single space only

Second: (again, spaces...) when you use FLAGS (like CXXINCS) remember that first option must immediately follows the = so don't write a space from = and first -I option (becouse, after sostitution, there will be more spaces in command line)

so try to replace your CXXINCS with this one

 
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:/SDL-1.2.15/include"


As you can note I removed also the space after "C:/SDL-1.2.15/include" becouse the final string must end WITHOUT spaces.

Another good practice, for a "flag" macro, is to don't make spaces also from macro and = (in that case it is better to write CXXINCS= instead of CXXINCS =)... unlike the other spaces, this is NOT an error, only a suggested practice (becouse in this way you would probably not forget to don't use spaces between = and first param)

Moreover.... Dev-C++ is deprecated and abandone.... mainly your version that still use gcc 3.x while now it is suggested to use gcc 4.x (better if 4.6 or 4.8)

Hope this hint can be helpful
Last edited on
Actually, that makefile was not written by me; it was generated by Dev-C++ it self. So I tried replacing that line with what you gave, and now, I am receiving this error:
C:\Users\user01\Desktop\A-Studios\C++\SDL\A-Engine\Makefile.win [Build Error] No rule to make target `A-Engine.exe', needed by `all'. Stop.
Thanks for trying to help =D.

So any other guesses?

P.S: I don't really know anything about makefiles scripting, so I would appreciate if anyone would direct me to a good tutorial/guide on how to use them.
make.exe: *** [main.o] Error 1

¿is that all?
I've got
In file included from main.cpp:7:0:
Object.h: In member function ‘void spritegrid::ini(std::string, int, int, int, int, std::string)’:
Object.h:75:74: error: cast from ‘const char*’ to ‘int’ loses precision [-fpermissive]
Object.h:76:75: error: cast from ‘const char*’ to ‘int’ loses precision [-fpermissive]
Object.h:77:75: error: cast from ‘const char*’ to ‘int’ loses precision [-fpermissive]
make: *** [main.o] Error 1
Referring to
1
2
3
                             col1=  (int)("0x"+colk_.substr (5,2)).c_str();
                             col2=  (int)("0x"+ colk_.substr (3,2)).c_str();
                             col3=  (int)("0x"+ colk_.substr (1,2)).c_str();
¿what are you trying to do there?


PS: http://www.gnu.org/software/make/manual/make.html
:facepalm: I was trying to convert a extract 3 RGB values from "0xFFFFFF" color format to use as a color key. That was back in the days were I thought I can convert a string to an int by simply using (int).. The color key is basically extracted from a txt file, and that's why I dealt with it as a string. Can you please replace the 3 lines with the following and compiling again?
1
2
3
                             col1=  atoi(("0x"+colk_.substr (5,2)).c_str());
                             col2=  atoi(("0x"+ colk_.substr (3,2)).c_str());
                             col3=  atoi(("0x"+ colk_.substr (1,2)).c_str());

And thanks for the tut!!

Btw, what IDE are you using???

Thanks in advance!!
Last edited on
> what IDE are you using?
none (aka linux http://blog.sanctum.geek.nz/unix-as-ide-introduction/ )

Also, regarding your code, take a look at http://wiki.hsr.ch/Prog3/files/overload72-FINAL_DesigningHeaderFiles.pdf
Last edited on
Linux as an ide.. Interesting XD!

And, I checked that guide on header files, and I added that #indef statement thingy. But that doesn't seem to be the issue for me (is it?). I will try to build it using another IDE this time then I will report back. Thanks.
I never used VIM.
I tried but I find it confusing... I am not able to remember all key combinations :P

I'm used to use a graphical text editor for sourcecode (Under linux I usually use KWrite and under win I use Crimson Editor)... It is more intuitive than using VIM.... even if VIM has the great advantage it doesn't require X to be runned...

However... I don't use any more IDEs from years (except Qt Designer for designing Qt widgets... but it is not properly an IDE)... I think that using gcc/g++ from command line is better.... even if a bit harder.... but you have full control of what you are doing...
@CPlahPlahLearner: changing those lines it does compile
However I've got stack overflow because `LOADED' is too big (~18MB)

Also, I didn't just point to the #ifdef #endif
You've got to put the necessary includes in your header, remove using directive, and avoid function definitions
Whaaat?? 18mb?? This can't be! Basically all what I am loading is 2 small sprite grids with ~70 Kbs altogether. Maybe I am just loading them more than once resulting in that ...
So, I tried Orwel's Dev-C++ 5.4.2 and it compiled. However, when I come to run the exe, nothing opens. Tried using debugging mode, and some very weird stuff happened.

1-I placed breakpoints all over the 2 files (the main and the header file), but the debugger would ignore everything, and jumps into this line:
http://i33.servimg.com/u/f33/16/27/78/35/screen12.png

2-I clicked on "next line", and the debugger moved normally to the next line:
http://i33.servimg.com/u/f33/16/27/78/35/screen13.png

3-I clicked on "next line" once more expecting that the debugger would enter the main function, but then:
http://i33.servimg.com/u/f33/16/27/78/35/screen15.png
It jumped to the closing bracket of the function "breakpoints invalid"...

4-Tried clicking "next line" 3 more times, and I received a "segmentation fault":
http://i33.servimg.com/u/f33/16/27/78/35/screen16.png

5-Clicking on ok with "show CPU window" checked:
http://i33.servimg.com/u/f33/16/27/78/35/screen17.png
:\

Thanks ne555, I appreciate your time and dedication =)
Last edited on
Yep, that was what were happening over here.
My guess is that you blow the stack space
Try
1
2
3
4
5
int main(){
	std::cout << "object " << sizeof(object)/1024 << "KB\n";
	std::cout << "LOAD " << sizeof(LOAD)/1024/1024 << "MB\n";

}
object 36KB
LOAD 18MB
18MB is a little much for the stack, use the heap instead
By instance,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <vector>
class LOAD{
//...
   //object OBJECT_IDS[500];
   std::vector<object> OBJECT_IDS;
}

LOAD::LOAD (string dir, string TOKEN)
	:OBJECT_IDS(500)
{
	OBJID_INDEX = 0;
	LOAD_DIR = dir.c_str ();
	LOAD_TOKEN = TOKEN.c_str ();
	LOAD_TXT.open (dir.c_str ());
}
The rest of the code is the same
Vectors ... Interesting!! I must have a look at its documentation, then I will be using them instead of arrays and for all. And nice technique you've used there to find how much memory each is using!! Once again, THANKS!!
Deemed solved~
Topic archived. No new replies allowed.