GMP(MPIR) linker errors on linux - c++

I wrote a public-private key generator using mpir(on windows) and it works fine.
When I try to compile it on a linux machine using gmp library, it throws a whole bunch of linker errors.
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invali
d symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invali
d symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invali
d symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invali
d symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invali
d symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invali
d symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invali
d symbol index 13
...
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start'
:
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
I'm using g++ -lgmp prime.cpp. I haven't used any non-gmp function. Any idea? I'm not adding code as there's a lot of it.

I'm using g++ -lgmp prime.cpp
This command line is broken in two ways:
You neglected to provide definiton of main
You specified library before source that references it. Should be:
g++ main.cpp prime.cpp -lgmp
The order of libraries and sources/objects on command line matters.
Update:
There are several files.. main file depends on them, so before building it.. I was trying to build the other files.
In that case, correct command is:
# Compile, but don't link, prime.cpp
g++ -c prime.cpp

Related

g++ crashed when I tried to compile a program with ONE LINE

My program is this:
#include <iostream>
That's it. That's the entire program, just one line.
I tried to compile it with this:
g++ CVB--OpenPic--00.cpp -o cv
and I got this:
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
I've compiled dozens of other .cpp files over the past few weeks, and many, many other programs. What exactly is happening here?
You haven't defined main() function in your program.
As said in error:
(.text+0x20): undefined reference to `main'
PS:
This is not crash of g++, it just shows error message when can't find definition of main().
Your g++ did not crash. It has just and rightfully emitted some error message, then it completed successfully (with a failure exit code). Actually the error message is given by the linker ld (which g++ has run after running the cc1plus compiler proper).
Your code does not has any main function (which is the function that starts execution, after construction of static variables, in C++), so you cannot compile it into an executable.
BTW, you should always compile your code with all warnings & debug info, so use
g++ -Wall -g CVB--OpenPic--00.cpp -o cv
Once you did debug your program (using the gdb debugger) you might want to benchmark it. Then ask the compiler to optimize (e.g. by adding -O2 option to g++).
Notice that order of arguments to g++ matters a big lot.
Once your program becomes larger and made of several translation units (e.g. several .cpp files, probably all #include-ing your header file[s]), you'll want to use a build automation tool (like make). Learn also to use a version control system like git and a memory leak detector like valgrind.

Linkage error using gtest in eclipse

I'm trying to use gtest in my cpp project, and there's probably a linkage error.
It also does not recognize the main that is in test folder.
Building target: MovieSystem
Invoking: Cross G++ Linker
g++ -o "MovieSystem" ./src/Actor.o ./src/Director.o ./src/Menu.o ./src/Movie.o ./src/Producer.o ./src/Professional.o ./src/ScreenWriter.o ./src/System.o ./src/factorial.o -lpthread
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
...
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [MovieSystem] Error 1
Just to mention, I followed the instructions in here completely:
http://www.codeproject.com/Articles/811934/Cplusplus-unit-test-start-guide-how-to-set-up-Goog
So what did I do wrong?
Thank you!

undefined reference to main in code blocks

A bit of the backstory: I first used Eclipse but it had trouble resolving namespace std so I switched to code::blocks and now I'm having this problem.
Everything went through debugging just fine except for one error: In function '_start': undefined reference to 'main' (.text+0x20). However, I have the main() defined and there's nothing fancy in it.
code::blocks version: 13.12
compiler: GNU gcc, have the g++ follow c++11
Thanks in advance.
There's nothing special in the main function
//: "main.cpp"
#include "bar.h"
#include "foo.h"
#include <iostream>
using namespace std;
int main() {
int num;
bar bar_;
foo foo_;
num = calc(bar_, foo_);
cout << num << endl;
return 0;
}
This is the Build Log:
g++ -o bin/Debug/test obj/Debug/bar.o obj/Debug/foo.o
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
cout << << num << endl; is invalid (note the two repeated <<). This means your main.cpp shouldn't even compile.
In your linking command, you're not linking main.o (the compiled object file for main.cpp). You're linking foo.o and bar.o, but you're missing main.o.
How you need to fix this:
Fix your code in main.cpp
Compile main.cpp to get the object file main.o
Link all the object files together.
Hmmm..
As per code block website, when such error occure,
"Dont look at Build Message tab, look at Build log tab"
In my case:
it was showing one .so file which is missing in linker.
Here is quick solution:
Setting>>compiler>>Linker Setting tab>>add path to .so file (which was pointed in build log)
Just ensure that the .so to add is really exist on your system.
Hope this helps.Cheers.

Boost Unit Test Entry Point Issue

Here's the code I'm working with in Eclipse CDT (from the official boost doc http://www.boost.org/doc/libs/1_55_0/libs/test/doc/html/tutorials/hello-the-testing-world.html):
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
int add(int i, int j) {
return i + j;
}
BOOST_AUTO_TEST_CASE( my_test ) {
// seven ways to detect and report the same error:
BOOST_CHECK(add(2, 2) == 4); // #1 continues on error
BOOST_REQUIRE(add(2, 2) == 4); // #2 throws on error
if (add(2, 2) != 4)
BOOST_ERROR("Ouch..."); // #3 continues on error
if (add(2, 2) != 4)
BOOST_FAIL("Ouch..."); // #4 throws on error
if (add(2, 2) != 4)
throw "Ouch..."; // #5 throws on error
BOOST_CHECK_MESSAGE(add(2, 2) == 4, // #6 continues on error
"add(..) result: " << add( 2,2 ));
BOOST_CHECK_EQUAL(add(2, 2), 4); // #7 continues on error
}
When I try to build it in Eclipse or the terminal, I get an error message regarding the lack of an entry point or main function:
08:33:51 **** Incremental Build of configuration Debug for project Test_C++ ****
make all
Building target: Test_C++
Invoking: GCC C++ Linker
g++ -o "Test_C++" ./src/test.o -lboost_unit_test_framework
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [Test_C++] Error 1
08:33:52 Build Finished (took 742ms)
Putting a main function in the code causes the program to build fine, but then the tests are skipped entirely. I installed boost test using synaptic package manager so it should be almost plug and play minus the part where I specify the library(-l) as boost_unit_test_framework.
I've been able to get boost/test/minimal.hpp linking and working just fine, but unfortunately I haven't got boost/test/unit_test.hpp working nicely in Eclipse in which the unit test output is shown within the C/C++ Unit view. I've tried going through several official and unofficial boost documentation/tutorials and haven't been too successful. I'm trying to get to a point where I can start unit testing within Eclipse where it's somewhat similar to the comfortability of using JUnit inside Eclipse. Any help or suggestions is appreciated. Thanks.
Figured it out. Turns out I should have avoided installing framework libraries through the package manager. It's best to install from source so you know where everything is. These two docs helped:
http://ubuntuforums.org/showthread.php?t=1180792
and for generic situations dealing with shared libraries (i.e. right after the bjam installation phase):
http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html
I'm not exactly sure where the package manager put the libraries, but I needed to verify the integrity of linking at link-time and at run-time by making sure I put the library files in /usr/local/lib and then following up with ldconfig.

Segmentation fault in g++ without -o option

When I compile my program without the g++ -o options, it fails with the following errors:
None of the symbols it is complaining about is in my program. Why would it compile well with -o option, but fail to compile without that option?
integer: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20 has invalid symbol index 20
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o:/build/buildd/eglibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:109: first defined here
integer: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crti.o:(.fini+0x0): first defined here
integer:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
integer: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o:(.data+0x0): first defined here
integer: In function `__data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbegin.o:(.data+0x0): first defined here
integer: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crti.o:(.init+0x0): first defined here
/tmp/ccWZQo46.o: In function `main':
/home/imarembo/source/zaffire1/integer.cc:839: multiple definition of `main'
integer:(.text+0xe4): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
integer:(.dtors+0x8): first defined here
/usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
/usr/bin/ld: error in integer(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status
Is there an explanation? Am I missing something here?
Using g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3
Thanks
-o expects a parameter (output file), you cannot simply remove just the -o part.
g++ -g integer integer.cc tries to compile integer.cc and then link it with the already existing executable (integer). It's no surprise you have symbol collisions.
The correct command is: g++ -g integer.cc or `g++ integer.cc