From: Richard V. <va...@sf...> - 2010-06-18 14:41:40
|
Attached is a CMake file that works for me on OS X. The only tricky bit is expanding out the pkg-config variables. There may be a nicer way to use them without expansion, which I'd be very happy to learn about. - rtv On Fri, Jun 18, 2010 at 3:05 PM, Tyler Gunn <ty...@eg...> wrote: > > Hello, > I've been trying to get a stage plugin to build/link properly outside of > the stage source and have been having some problems. > When I build the wander_wifi controller (same as wander for sake of > arguments) within the stage example/ctrl directory, the resulting plugin > works fine. > However, when I build the same thing outside of the stage source tree, in > my own source tree, the attempts to call certain methods in stage from my > plugin result in segmentation faults. > It looks to me like > > When I look at how CMake is generating stuff for the plugin via the stage > source tree I notice the link.txt file references the libstage.3.2.2.dylib > library, which seems to indicate a dynamic linking. > wander_wifi.dir/link.txt:/usr/bin/g++ -arch x86_64 -isysroot > /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -ggdb -Wall > -bundle -headerpad_max_install_names -o wander_wifi.so > CMakeFiles/wander_wifi.dir/wander_wifi.o -L/opt/local/lib > ../../libstage/libstage.3.2.2.dylib -framework AGL -framework OpenGL > /opt/local/lib/libltdl.dylib > > Where when I look at the link.txt for my standalone compile I see: > ty_wifi.dir/link.txt:/usr/bin/c++ -mmacosx-version-min=10.6 -O3 > -DNDEBUG -Wall -bundle -headerpad_max_install_names -o ty_wifi.so > CMakeFiles/ty_wifi.dir/ty_wifi.cc.o -L/Users/tyler/thesis/local/lib > -L/usr/X11R6/lib -lstage -lpng -lz -ljpeg -lGLU -lGL -lXft -lpthread -lXext > -lX11 > > > My CMakeFile is as below; any hints on this are GREATLY appreciated as > I've spent too many all-nighters trying to get it to work. Lol. > > THanks, > Tyler > > > cmake_minimum_required( VERSION 2.6 ) > > PROJECT(GunnThesis) > > SET( V_MAJOR 0 ) > SET( V_MINOR 1 ) > SET( V_BUGFIX 0 ) > > SET( VERSION ${V_MAJOR}.${V_MINOR}.${V_BUGFIX} ) > > MESSAGE (STATUS "${PROJECT_NAME} version ${VERSION}") > > # Enable -Wall by default unless on Win or Solaris > IF (NOT PROJECT_OS_WIN AND NOT PROJECT_OS_SOLARIS) > # Using -Wall on Windows causes MSVC to produce thousands of warnings > in its > # own standard headers, dramatically slowing down the build. > SET (WALL "-Wall" ) > ENDIF (NOT PROJECT_OS_WIN AND NOT PROJECT_OS_SOLARIS) > > ##################################### > # Build type cflags > SET (CMAKE_CXX_FLAGS_RELEASE " -O3 -DNDEBUG ${WALL} " CACHE INTERNAL "C > Flags for release" FORCE) > SET (CMAKE_CXX_FLAGS_DEBUG " -ggdb ${WALL} " CACHE INTERNAL "C Flags for > debug" FORCE) > SET (CMAKE_CXX_FLAGS_PROFILE " -O3 -ggdb -pg ${WALL} " CACHE INTERNAL "C > Flags for profile" FORCE) > > ##################################### > # Set the default build type > IF (NOT CMAKE_BUILD_TYPE) > SET (CMAKE_BUILD_TYPE "release" CACHE STRING > "Choose the type of build, options are: release (default) debug > profile" FORCE) > ENDIF (NOT CMAKE_BUILD_TYPE) > STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) > > MESSAGE( STATUS "Build type ${CMAKE_BUILD_TYPE}" ) > > SET (PROJECT_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake CACHE PATH "Location of > CMake scripts") > > # Find the stage libary we need to link in > include(FindPkgConfig) > pkg_search_module( STAGE REQUIRED stage ) > > IF( STAGE_FOUND ) > MESSAGE( STATUS ${INDENT} "Stage version ${STAGE_VERSION} detected at > ${STAGE_PREFIX}" ) > SET (HAVE_STAGE TRUE CACHE INTERNAL "Is Stage installed?") > SET (Stage_LIB_DIR ${STAGE_LIBRARY_DIRS} CACHE FILEPATH "Path to lib > directory of stage to use.") > SET (Stage_INC_DIR ${STAGE_INCLUDE_DIRS} CACHE FILEPATH "Path to include > directory of stage to use.") > > MESSAGE( "Stage at ${STAGE_INCLUDE_DIRS}..") > MESSAGE( "Stage libs ${STAGE_LIBRARIES}") > ELSE( STAGE_FOUND ) > MESSAGE( ${INDENT} "Stage not detected. If Stage is installed but not > detected, check your PKG_CONFIG_PATH." ) > SET (HAVE_STAGE FALSE CACHE INTERNAL "Is Stage installed?") > SET (Stage_LIB_DIR "" CACHE FILEPATH "Path to lib directory of stage to > use.") > SET (Stage_INC_DIR "" CACHE FILEPATH "Path to include directory of stage > to use.") > > ENDIF( STAGE_FOUND ) > > MARK_AS_ADVANCED( > Stage_LIB_DIR > Stage_INC_DIR ) > > # GEt ready to build the plugin!!! > include_directories( . > ${Stage_INC_DIR} > ) > #${OPENCV_INC_DIR} > #${GTKMM_INCLUDE_DIRS} > link_directories( ${Stage_LIB_DIR} > ) > > > #--------------------------- GunnPlugin > ------------------------------------------------ > # Set the source files to be included in my thesis plugin. > SET( GUNN_SRCS > ty_wifi > ) > > # Set the name of the plugin > SET( CTRL_PLUGIN ty_wifi ) > > # Define that we're going to build the gunn_plugin controller module > ADD_LIBRARY( ${CTRL_PLUGIN} MODULE ${GUNN_SRCS} ) > > > # Now, set the link libraries to include the state libs > TARGET_LINK_LIBRARIES( ${CTRL_PLUGIN} > ${STAGE_LIBRARIES} > ) > > # Remove the "lib" prefix to the target lib > SET_TARGET_PROPERTIES( ${CTRL_PLUGIN} PROPERTIES PREFIX "" > ) > > #install in <prefix>/lib > install( TARGETS ${CTRL_PLUGIN} DESTINATION lib) > > -- > -- > Tyler Gunn > ty...@eg... > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > -- Richard Vaughan Autonomy Lab / Computing Science / Simon Fraser University |