Can anyone tell me what the file "/usr/include/c++/4.4/exception" would have to do with this error. There is no main defined in that file. I am not sure how to read the error message.
./libfoo.a(main.o): In function `main':
/usr/include/c++/4.4/exception:62: multiple definition of `main'
interface-wx/App.o:/usr/include/c++开发者_StackOverflow中文版/4.4/exception:62: first defined here
collect2: ld returned 1 exit status
Any help would be greatly appreciated.
Well, like it says. there are multiple definitions of 'main'. check these two files. main.cpp
and interface-wx/App.cpp
.
So I figured out what was going on...just in case someone else runs into this. A good way to find out where that duplicate definition is coming from in your code is to use the command:
nm -l name_of_object_file.o
nm is used to print the symbol table of an object file. I piped the output to a file and searched for main. The -l switch will print out line numbers for the symbols. This allowed me to see where that other pesky main definition was coming from.
For wxWidgets users:
The macro IMPLEMENT_APP(App)
was defining a main for App when I really wanted it to use my main. The original code(which I didn't write) had a #define IMPLEMENT_WXWIN_MAIN
at the top of the App file and as I said earlier, used IMPLEMENT_APP(App). Everything worked fine with wxWidgets 2.8.6, but when I tried to use wxWidgets 2.9.1, I started having this issue.
Solution:
Replace IMPLEMENT_APP(App)
with wxIMPLEMENT_APP_NO_MAIN(App);
精彩评论