I am a student who is turning in homework (no, I'm not trying to get you guys to do my homework for me). When I compile my code in Linux Mint, I use the terminal command:
g++ -std=c++11 Main.cpp
my TA uses:
g++ -std=c++11 *.cpp
When I compile using my command, no problems. But when I compile using his command, I get an error:
/tmp/ccf6C4Rx.o: In function `ShellSorter::ShellSort(std::vector<Item, std::allocator<Item> >&, int)':
ShellSort.cpp:(.text+0x0): multiple definition of `ShellSorter::ShellSort(std::vector<Item, std::allocator<Item> >&, int)'
/tmp/ccqq9ape.o:main.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
I can post my code here if you guys want, but I was just wondering in general if anybody knew anything about this type of error.
You can substitute MyProgName with whatever you want to call your program, it's better than running the default ./a.out
It's worth reading the compiler manual, there are even more options that aren't enabled by the above command. I know there are a zillion lines, but it is still worth it IMO.
If you have multiple files, you are better off with using some kind of make file, but that may be a bit advanced right now.
> it's better than running the default ./a.out
¿why?
Well, you know - so it has it's own name :+) Imagine one has written a bunch of utility programs: they exist in their own development directories; but one may want to collect them together into one directory.
The OP may not have known about this feature, and one day they may want to produce the assembler code, or make a library file.