I am using the cmakelists.txt below, that exists in the top folder of my project, and I am trying to connect mpg123 and ao to my project. In one .cpp file of the source folder I added a code with mpg123 and ao to play a song. This code can be compiled with this line:
*g++ mpg.cpp -lmpg123 -lao -o mpg* I also added this line: target_link_libraries(emotime ${LIBAO_LIBRARIES} ${MPG123_LIBRARIES}) in the cmakelists that exists in my source folder. When I am running make I get errors like "undefined reference to `ao_initialize'" and "undefined reference to `mpg123_init'". Am I doing something wrong? cmake_minimum_required(VERSION 2.8) project(emotime) find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) FIND_PATH( MPG123_INCLUDE_DIR1 NAMES mpg123.h PATH_SUFFIXES include PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw # Fink /opt/local # DarwinPorts /opt/csw # Blastwave /opt extern/mpg123/ports/MSVC++ extern/mpg123/ports/Xcode ) IF( MPG123_INCLUDE_DIR1 ) SET( MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIRS} ${MPG123_INCLUDE_DIR1} ) ENDIF( MPG123_INCLUDE_DIR1 ) # Include dir (May not be necessary on all platforms) FIND_PATH( MPG123_INCLUDE_DIR2 NAMES mpg123.h.in PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw # Fink /opt/local # DarwinPorts /opt/csw # Blastwave /opt extern/mpg123/src/libmpg123 ) IF( MPG123_INCLUDE_DIR2 ) SET( MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIRS} ${MPG123_INCLUDE_DIR2} ) ENDIF( MPG123_INCLUDE_DIR2 ) #MESSAGE( "MPG123_INCLUDE_DIR1: " ${MPG123_INCLUDE_DIR1} ) #MESSAGE( "MPG123_INCLUDE_DIR2: " ${MPG123_INCLUDE_DIR2} ) #MESSAGE( "MPG123_INCLUDE_DIRS: " ${MPG123_INCLUDE_DIRS} ) FIND_LIBRARY( MPG123_LIBRARIES NAMES mpg123 libmpg123.lib HINTS PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 Release Debug PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw /opt/local /opt/csw /opt extern/mpg123/ports/MSVC++/2005 extern/mpg123/ports/MSVC++/2008 extern/mpg123/ports/MSVC++/2008clr extern/mpg123/ports/MSVC++/2010 ) SET( MPG123_FOUND 0 ) IF( MPG123_LIBRARIES AND MPG123_INCLUDE_DIRS ) SET( MPG123_FOUND 1 ) MESSAGE( STATUS "mpg123 found!" ) ELSE( MPG123_LIBRARIES AND MPG123_INCLUDE_DIRS ) MESSAGE( STATUS "mpg123 not found..." ) ENDIF( MPG123_LIBRARIES AND MPG123_INCLUDE_DIRS ) FIND_PATH(LIBAO_INCLUDE_DIR ao.h /usr/include/ao /usr/local/include/ao) FIND_LIBRARY(LIBAO_LIBRARIES NAMES ao PATH /usr/lib /usr/local/lib) IF (LIBAO_INCLUDE_DIR AND LIBAO_LIBRARIES) SET(LIBAO_FOUND TRUE) ENDIF (LIBAO_INCLUDE_DIR AND LIBAO_LIBRARIES) IF (LIBAO_FOUND) IF (NOT LIBAO_FIND_QUIETLY) MESSAGE(STATUS "Found libao: ${LIBAO_LIBRARIES}") ENDIF (NOT LIBAO_FIND_QUIETLY) ELSE (LIBAO_FOUND) IF (LIBAO_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Could not find libao") ENDIF (LIBAO_FIND_REQUIRED) ENDIF (LIBAO_FOUND) include_directories(${LIBAO_INCLUDE_DIR} ${MPG123_INCLUDE_DIRS}) set(ASSETDIR "${emotime_SOURCE_DIR}/assets" ) set(HEADERDIR "${emotime_SOURCE_DIR}/include" ) set(SRCDIR "${emotime_SOURCE_DIR}/src" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_subdirectory(src)
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake