ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

"multiple definition of `main'" error

asked 2011-12-22 02:09:23 -0500

alfa_80 gravatar image

updated 2011-12-22 02:25:27 -0500

I have 2 nodes/files(one node for each file) in my package. It's like in talker and listener tutorial. However, after adding a new one (second node/file), I received an error of "multiple definition of `main'". I've check all the braces, they are well-placed.

What could be the possible culprits?

edit retag flag offensive close merge delete

Comments

Could you be more clear? You added a second what?
DimitriProsser gravatar image DimitriProsser  ( 2011-12-22 02:18:39 -0500 )edit
I've just updated the question.
alfa_80 gravatar image alfa_80  ( 2011-12-22 02:28:17 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2011-12-22 02:34:59 -0500

alfa_80 gravatar image

I just forgot to change the node name in the "rosbuild_add_executable" parameter in the CMakeList.txt. I only added the different name for both of them, but not the node name.

edit flag offensive delete link more
0

answered 2011-12-22 02:19:53 -0500

DimitriProsser gravatar image

My first guess would be that there are two main functions in your .cpp file. You're only allowed one main per C++ executable. So if you're trying to build one executable with two nodes in it, it won't work.

edit flag offensive delete link more

Comments

@DimitriProsser: Thanks for trying. But, I have only one main per source file (In total I have 2 mains, but they are separated by those 2 files). That is not the case. Strange behavior though.
alfa_80 gravatar image alfa_80  ( 2011-12-22 02:27:56 -0500 )edit
Are you trying to build two source files into a single executable?
DimitriProsser gravatar image DimitriProsser  ( 2011-12-22 02:35:20 -0500 )edit
@DimitriProsser: It's just fixed, into 2 executables anyway. Thanks a lot.
alfa_80 gravatar image alfa_80  ( 2011-12-22 03:55:24 -0500 )edit

Question Tools

Stats

Asked: 2011-12-22 02:09:23 -0500

Seen: 2,356 times

Last updated: Dec 22 '11