I have C++ project. This is Makefile:
CXX=g++
LD=g++
CFLAGS=-Wall -pedantic -Wno-long-long -O0 -ggdb
LIBS=-lncurses -lmenu -lform
SOURCE=src/
all: compile doc
compile: glazafil
doc:
doxygen .doxygen
glazafil: main.o xmlparser.o xmltree.o xmlnode.o xmlnodeattribute.o gui.o
$(LD) -o main.o xmlparser.o xmltree.o xmlnode.o xmlnodeattribute.o gui.o $(LIBS)
main.o: $(SOURCE)main.cpp $(SOURCE)xmlparser.h $(SOURCE)xmltree.h $(SOURCE)gui.h
$(CXX) $(CFLAGS) -c -o main.o $(SOURCE)main.cpp
xmlparser.o: $(SOURCE)xmlparser.cpp $(SOURCE)xmlnode.h
$(CXX) $(CFLAGS) -c -o xmlparser.o $(SOURCE)xmlparser.cpp
xmltree.o: $(SOURCE)xmltree.cpp $(SOURCE)xmltree.h $(SOURCE)xmlnode.h
$(CXX) $(CFLAGS) -c -o xmltree.o $(SOURCE)xmltree.cpp
xmlnode.o: $(SOURCE)xmlnode.cpp $(SOURCE)xmlnode.h $(SOURCE)xmlnodeattribute.h
$(CXX) $(CFLAGS) -c -o xmlnode.o $(SOURCE)xmlnode.cpp
xmlnodeattribute.o: $(SOURCE)xmlnodeattribute.cpp $(SOURCE)xmlnodeattribute.h
$(CXX) $(CFLAGS) -c -o xmlnodeattribute.o $(SOURCE)xmlnodeattribute.cpp
gui.o: $(SOURCE)gui.cpp $(SOURCE)gui.h $(SOURCE)xmltree.h
$(CXX) $(CFLAGS) -c -o gui.o $(SOURCE)gui.cpp
clean:
rm -f glazafil main.o xmlparser.o xmltree.o xmlnode.o xmlnodeattribute.o gui.o; rm -r -i doc
This is make compile output:
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o main.o src/main.cpp
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o xmlparser.o src/xmlparser.cpp
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o xmltree.o src/xmltree.cpp
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o xmlnode.o src/xmlnode.cpp
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o xmlnodeattribute.o src/xmlnodeattribute.cpp
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o gui.o src/gui.cpp
g++ -o main.o xmlparser.o xmltree.o xmlnode.o xmlnodeattribute.o gui.o -lncurses -lmenu -lform
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 22
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [glazafil] Error 1
The main.o file is not created, but in NetBeans it works. WHen I run this g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o main.o src/main.cpp It makes main.o, but it still doesn't work. This is main.cpp:
#include "xmlparser.h"
#include "xmltree.h"
#include "gui.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
/*if( argc < 2 ) {
return 0;
}
string in(argv[1]);
fstream file;
file.open(argv[1], ios_base::out | ios_base::in);
if(!file.is_open()) {
cout << "The input file doesn't exist" << endl;
return 0;
}
file.close();
string out = "";
if(argc > 2) {
string out(argv[2]);
}*/
XMLParser parser;
XMLTree tree = parser.ParseFile("/home/figa/out.xml", "/home/figa/out.xml");
//XMLTree tree = parser.ParseFile(in, out);
GUI gui = GUI(tree);
tree.delNode(tree.root);
return 0;
}
Where can be a problem? Thanks for help.
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -c -o main.o src/main.cpp
does? – user529758