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

tinyxml lib cmake error

asked 2016-02-12 14:59:44 -0600

jester gravatar image

Hi,

I want to compile my project, but I dont get it running. include <tinyxml.h> is included in roc_choice.cpp. I have no idea, what I could try.

Please, can help me someone?

[ 52%] Linking CXX executable /media/jester/e5ff9dd5-b341-d101-e043-9dd5b341d101/home/jester/Dropbox/Programming/ClionProjects/face_detection/image_transport_ws/devel/lib/image_transport_tutorial/roc_choice
[ 52%] Built target _image_transport_tutorial_generate_messages_check_deps_ResizedImage
[ 58%] Built target image_transport_tutorial_generate_messages_cpp
[ 64%] Built target image_transport_tutorial_generate_messages_lisp
[ 76%] Built target image_transport_tutorial_generate_messages_py
[ 76%] Built target image_transport_tutorial_generate_messages
CMakeFiles/roc_choice.dir/src/overlapping_rect.cpp.o: In function `main':
overlapping_rect.cpp:(.text+0x16b0): multiple definition of `main'
CMakeFiles/roc_choice.dir/src/roc_choice.cpp.o:roc_choice.cpp:(.text+0x20fa): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [/media/jester/e5ff9dd5-b341-d101-e043-9dd5b341d101/home/jester/Dropbox/Programming/ClionProjects/face_detection/image_transport_ws/devel/lib/image_transport_tutorial/roc_choice] Error 1
make[1]: *** [tedusar_detector_evaluator/CMakeFiles/roc_choice.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j8 -l8" failed

This is my Makefilelist.txt

cmake_minimum_required(VERSION 2.8)
project(image_transport_tutorial)

find_package(catkin REQUIRED cv_bridge genmsg image_transport sensor_msgs)
find_package(OpenCV)
find_package(TinyXML)

if(CMAKE_COMPILER_IS_GNUCXX)
   execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
   if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
        message(STATUS "C++11 activated.")
        add_definitions("-std=gnu++11")
   elseif(GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3)
        message(WARNING "C++0x activated. If you get any errors update to a compiler which fully supports C++11")
        add_definitions("-std=gnu++0x")
   else ()
        message(FATAL_ERROR "C++11 needed. Therefore a gcc compiler with a version higher than 4.3 is needed.")
   endif()
else(CMAKE_COMPILER_IS_GNUCXX)
   add_definitions("-std=c++0x")
endif(CMAKE_COMPILER_IS_GNUCXX)



add_message_files(DIRECTORY msg
   FILES ResizedImage.msg)
generate_messages(DEPENDENCIES sensor_msgs)
catkin_package()
include_directories(include)
include_directories(${catkin_INCLUDE_DIRS})
include_directories(include ${OpenCV_INCLUDE_DIRS})
include_directories(include ${TinyXML_INCLUDE_DIRS})


add_executable(image_publisher src/image_publisher.cpp src/abstract_choice.cpp src/my_exception.cpp)
target_link_libraries(image_publisher ${catkin_LIBRARIES} ${TinyXML_LIBRARIES})
#target_link_libraries(image_publisher ${catkin_LIBRARIES} /*${OpenCV_LIBRARIES}*/)

# add the subscriber example
#add_executable(my_subscriber src/my_subscriber.cpp)
#target_link_libraries(my_subscriber ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})


add_executable(overlapping_rect src/abstract_choice.cpp src/my_exception.cpp src/overlapping_rect.cpp)
target_link_libraries(overlapping_rect ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${catkin_INCLUDE_DIRS})

add_executable(roc_choice src/roc_choice.cpp src/abstract_choice.cpp src/my_exception.cpp src/overlapping_rect.cpp)
target_link_libraries(roc_choice ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${catkin_INCLUDE_DIRS} ${TinyXML_LIBRARIES})

catkin_add_gtest(utest test/test.cpp include/image_transport_tutorial/overlapping_rect.h)
target_link_libraries(utest ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${catkin_INCLUDE_DIRS})
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-02-13 11:19:29 -0600

duck-development gravatar image

The error is the multiple definition of main function.

A Program has only one main function.

edit flag offensive delete link more
0

answered 2016-02-13 16:04:21 -0600

jester gravatar image

in the cmakelists.txt, just deleted src/overlapping_rect.cpp

before: add_executable(roc_choice src/roc_choice.cpp src/abstract_choice.cpp src/my_exception.cpp src/overlapping_rect.cpp)

after: add_executable(roc_choice src/roc_choice.cpp src/abstract_choice.cpp src/my_exception.cpp)

because overlapping_rect.cpp also contains a main function.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-02-12 14:59:44 -0600

Seen: 1,376 times

Last updated: Feb 13 '16