I get a build error when trying to build a flex and lemon project with CMake. Can you help me find what is wrong?
$ make
/usr/bin/cmake -H/home/dac/ClionProjects/openshell -B/home/dac/ClionProjects/openshell --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/dac/ClionProjects/openshell/CMakeFiles /home/dac/ClionProjects/openshell/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/lemon.dir/build.make CMakeFiles/lemon.dir/depend
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
cd /home/dac/ClionProjects/openshell && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell/CMakeFiles/lemon.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/lemon.dir/build.make CMakeFiles/lemon.dir/build
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
make[2]: Nothing to be done for 'CMakeFiles/lemon.dir/build'.
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 1
[ 16%] Built target lemon
make -f CMakeFiles/openshell.dir/build.make CMakeFiles/openshell.dir/depend
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
cd /home/dac/ClionProjects/openshell && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell/CMakeFiles/openshell.dir/DependInfo.cmake --color=
Scanning dependencies of target openshell
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/openshell.dir/build.make CMakeFiles/openshell.dir/build
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 2
[ 33%] Building C object CMakeFiles/openshell.dir/main.c.o
/usr/bin/cc -Wall -Werror -O3 -std=c99 -I/usr/include/readline -o CMakeFiles/openshell.dir/main.c.o -c /home/dac/ClionProjects/openshell/main.c
Linking C executable openshell
/usr/bin/cmake -E cmake_link_script CMakeFiles/openshell.dir/link.txt --verbose=1
/usr/bin/cc -Wall -Werror -O3 -std=c99 CMakeFiles/openshell.dir/main.c.o CMakeFiles/openshell.dir/errors.c.o CMakeFiles/openshell.dir/util.c.o CMakeFiles/openshell.dir/stack.c.o CMakeFiles/openshell.dir/flex/shellparser.c.o -o openshell -rdynamic -lreadline
CMakeFiles/openshell.dir/main.c.o: In function `main':
main.c:(.text.startup+0xef): undefined reference to `yylex_init'
main.c:(.text.startup+0x100): undefined reference to `yyset_in'
main.c:(.text.startup+0x12e): undefined reference to `yylex'
main.c:(.text.startup+0x13a): undefined reference to `yyget_text'
main.c:(.text.startup+0x178): undefined reference to `yylex_destroy'
collect2: error: ld returned 1 exit status
CMakeFiles/openshell.dir/build.make:188: recipe for target 'openshell' failed
make[2]: *** [openshell] Error 1
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/openshell.dir/all' failed
make[1]: *** [CMakeFiles/openshell.dir/all] Error 2
make[1]: Leaving directory '/home/dac/ClionProjects/openshell'
Makefile:78: recipe for target 'all' failed
make: *** [all] Error 2
My CMake build file is
cmake_minimum_required (VERSION 2.6)
project (openshell)
set(CMAKE_VERBOSE_MAKEFILE on)
include_directories(/usr/include/readline)
#### Lemon bootstrap ####
ADD_EXECUTABLE(lemon lemon.c)
file(GLOB SOURCES "./*.c")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -O3 -std=c99")
add_executable(openshell main.c openshell.h errors.c errors.h util.c util.h stack.c stack.h flex/shellparser.c flex/shellscanner.l flex/shellscanner.h)
target_link_libraries(openshell readline)
You're not linking the Flex library, so you will get linker errors for any Flex functions you use, such as yyset_in.
You can use find_package(FLEX) and after using FLEX_TARGET to define your Flex targets, you can then use something like the following:
# Note: I use "ShellScanner" below as in FLEX_TARGET(ShellScanner flex/shellscanner.l ...)
add_executable(openshell
...
flex/shellparser.c
${FLEX_ShellScanner_OUTPUTS}
)
target_link_libraries(openshell ${READLINE_LIBRARY} ${FLEX_LIBRARIES})
See FindFLEX for more information.
However, I don't see a FindReadline.cmake module with the other modules that CMake provides by default, so you might have to create one yourself or use an existing one such as the one I just linked. There's also the Editline library, which provides similar functionality, and you can use an existing FindEditline.cmake file for that too.
Related
I have the following CMakeLists.txt, trying to build my software on Windows with MinGW-w64:
#
# Initial CMake and project setup
#
# Required CMake version (ExternalProject)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
INCLUDE(ExternalProject)
SET(PROJECT_NAME Khronos)
PROJECT(${PROJECT_NAME})
# Set software version
SET(APPLICATION_VERSION_MAJOR "0")
SET(APPLICATION_VERSION_MINOR "4")
SET(APPLICATION_VERSION_PATCH "0")
SET(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/library-build)
#
# Setup compiler flags
#
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE Release FORCE)
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -std=gnu11 -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=gnu11 -O3")
if (GCC_VERSION VERSION_GREATER "4.8")
elsif (GCC_VERSION VERSION_GREATER "4.1.2")
SET (GCC_COMMON_WARNING_FLAGS "-pedantic -Wall -Wextra -Wconversion -Wfloat-equal -Wformat=2 -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstack-protector -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum")
SET (GCC_COMMON_WARNING_FLAGS "${GCC_COMMON_WARNING_FLAGS} -Wno-unused-parameter")
SET (GCC_CXX_WARNING_FLAGS "-Wctor-dtor-privacy")
else ()
SET(GCC_COMMON_WARNING_FLAGS "-pedantic -Wall -Wextra -Wconversion -Wfloat-equal -Wformat=2 -Winit-self -Winline -Winvalid-pch -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstack-protector -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum")
SET(GCC_COMMON_WARNING_FLAGS "${GCC_COMMON_WARNING_FLAGS} -Wno-unused-parameter")
SET(GCC_CXX_WARNING_FLAGS "-Wctor-dtor-privacy")
endif ()
#
# Find Doxygen for documentation
#
# add a target to generate API documentation with Doxygen
FIND_PACKAGE(Doxygen)
if (DOXYGEN_FOUND)
ADD_CUSTOM_TARGET(DOC
${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif ()
#
# Find/install dependencies
#
IF(WIN32)
INCLUDE(${CMAKE_MODULE_PATH}/Win32-ExternalProjects.txt)
ELSE(UNIX)
INCLUDE(${CMAKE_MODULE_PATH}/Unix-ExternalProjects.txt)
ENDIF()
#
# Final project settings
#
INCLUDE_DIRECTORIES(include)
ADD_SUBDIRECTORY(src)
ADD_EXECUTABLE(${PROJECT_NAME}
$<TARGET_OBJECTS:audio>
$<TARGET_OBJECTS:util>
$<TARGET_OBJECTS:main>
)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS})
if (DEPENDENCIES)
MESSAGE (STATUS "Any missing dependencies will be downloaded upon running \"make\"")
ADD_DEPENDENCIES(${PROJECT_NAME} ${DEPENDENCIES})
endif ()
I'm able to compile everything, but I'm having trouble linking the executable to the libraries:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -HC:\Users\syb0rg\Downloads\Khronos -BC:\Users\syb0rg\Downloads\Khronos\build --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_start C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\progress.marks
make -f CMakeFiles\Makefile2 all
make[1]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\sphinxbase.dir\build.make CMakeFiles/sphinxbase.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\sphinxbase.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\sphinxbase.dir\build.make CMakeFiles/sphinxbase.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/sphinxbase.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 17%] Built target sphinxbase
make -f CMakeFiles\LibSndFile.dir\build.make CMakeFiles/LibSndFile.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\LibSndFile.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\LibSndFile.dir\build.make CMakeFiles/LibSndFile.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/LibSndFile.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 35%] Built target LibSndFile
make -f CMakeFiles\pocketsphinx.dir\build.make CMakeFiles/pocketsphinx.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\pocketsphinx.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\pocketsphinx.dir\build.make CMakeFiles/pocketsphinx.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/pocketsphinx.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 53%] Built target pocketsphinx
make -f CMakeFiles\PortAudio.dir\build.make CMakeFiles/PortAudio.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\PortAudio.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\PortAudio.dir\build.make CMakeFiles/PortAudio.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/PortAudio.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 71%] Built target PortAudio
make -f src\audio\CMakeFiles\audio.dir\build.make src/audio/CMakeFiles/audio.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\src\audio C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\src\audio C:\Users\syb0rg\Downloads\Khronos\build\src\audio\CMakeFiles\audio.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f src\audio\CMakeFiles\audio.dir\build.make src/audio/CMakeFiles/audio.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `src/audio/CMakeFiles/audio.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 73%] Built target audio
make -f src\util\CMakeFiles\util.dir\build.make src/util/CMakeFiles/util.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\src\util C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\src\util C:\Users\syb0rg\Downloads\Khronos\build\src\util\CMakeFiles\util.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f src\util\CMakeFiles\util.dir\build.make src/util/CMakeFiles/util.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `src/util/CMakeFiles/util.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 75%] Built target util
make -f src\CMakeFiles\main.dir\build.make src/CMakeFiles/main.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\src C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\src C:\Users\syb0rg\Downloads\Khronos\build\src\CMakeFiles\main.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f src\CMakeFiles\main.dir\build.make src/CMakeFiles/main.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `src/CMakeFiles/main.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 80%] Built target main
make -f CMakeFiles\tritium.dir\build.make CMakeFiles/tritium.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\tritium.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\tritium.dir\build.make CMakeFiles/tritium.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/tritium.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 97%] Built target tritium
make -f CMakeFiles\Khronos.dir\build.make CMakeFiles/Khronos.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\Khronos.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\Khronos.dir\build.make CMakeFiles/Khronos.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
[100%] Linking C executable Khronos.exe
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\Khronos.dir\link.txt --verbose=1
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E remove -f CMakeFiles\Khronos.dir/objects.a
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\ar.exe cr CMakeFiles\Khronos.dir/objects.a #CMakeFiles\Khronos.dir\objects1.rsp
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\gcc.exe -Wl,--whole-archive CMakeFiles\Khronos.dir/objects.a -Wl,--no-whole-archive -o Khronos.exe -Wl,--out-implib,libKhronos.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\Khronos.dir\linklibs.rsp
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0xd2): undefined reference to `ps_start_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x109): undefined reference to `ps_process_raw'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x115): undefined reference to `ps_get_in_speech'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x161): undefined reference to `ps_end_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x172): undefined reference to `ps_get_hyp'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x185): undefined reference to `ps_start_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x1ce): undefined reference to `ps_end_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x1e8): undefined reference to `ps_get_hyp'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x24b): undefined reference to `getPathFromDescriptor'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x61c): undefined reference to `err_set_logfp'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x626): undefined reference to `err_set_debug_level'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x678): undefined reference to `ps_args'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x6d7): undefined reference to `cmd_ln_init'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x71f): undefined reference to `ps_init'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x7fb): undefined reference to `ps_free'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x807): undefined reference to `cmd_ln_free_r'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Khronos.exe] Error 1
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[1]: *** [CMakeFiles/Khronos.dir/all] Error 2
make[1]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make: *** [all] Error 2
Here's the ${LIBS} output from message() (in a more human readable form):
C:/Users/syb0rg/Downloads/Khronos/lib/sphinxbase/bin/Debug/Win32/sphinxbase.dll
C:/Users/syb0rg/Downloads/Khronos/lib/pocketsphinx/bin/Debug/Win32/pocketsphinx.dll
C:/Users/syb0rg/Downloads/Khronos/lib/PortAudio/libportaudio_x86.dll
C:/Users/syb0rg/Downloads/Khronos/lib/LibSndFile/libsndfile.dll
C:/Users/syb0rg/Downloads/Khronos/lib/tritium/libtritium.a
For reference, ${LIBS} is set here:
FIND_PACKAGE(sphinxbase)
if (${SPHINXBASE_FOUND})
INCLUDE_DIRECTORIES(${SPHINXBASE_INCLUDE_DIR}/sphinxbase/)
else ()
ExternalProject_Add(
sphinxbase
GIT_REPOSITORY "https://github.com/cmusphinx/sphinxbase.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/sphinxbase
CONFIGURE_COMMAND ""
BUILD_COMMAND msbuild sphinxbase.sln /p:PlatformToolset=v140
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(sphinxbase SOURCE_DIR)
ExternalProject_Get_Property(sphinxbase BINARY_DIR)
SET(SPHINXBASE_SOURCE_DIR ${SOURCE_DIR})
SET(SPHINXBASE_BINARY_DIR ${BINARY_DIR})
SET(SPHINXBASE_LIBRARIES ${SPHINXBASE_BINARY_DIR}/bin/Debug/Win32/sphinxbase.dll)
SET(DEPENDENCIES ${DEPENDENCIES} sphinxbase)
INCLUDE_DIRECTORIES(${SPHINXBASE_SOURCE_DIR}/include/win32)
INCLUDE_DIRECTORIES(${SPHINXBASE_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${SPHINXBASE_LIBRARIES})
FIND_PACKAGE(pocketsphinx)
if (${POCKETSPHINX_FOUND})
INCLUDE_DIRECTORIES(${POCKETSPHINX_INCLUDE_DIR}/pocketsphinx/)
add_definitions( -DMODELDIR="/usr/local/share/pocketsphinx/model") # more portable?
else ()
ExternalProject_Add(
pocketsphinx
DEPENDS sphinxbase
GIT_REPOSITORY "https://github.com/cmusphinx/pocketsphinx.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/pocketsphinx
CONFIGURE_COMMAND ""
BUILD_COMMAND msbuild pocketsphinx.sln /p:PlatformToolset=v140
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(pocketsphinx SOURCE_DIR)
ExternalProject_Get_Property(pocketsphinx BINARY_DIR)
SET(POCKETSPHINX_SOURCE_DIR ${SOURCE_DIR})
SET(POCKETSPHINX_BINARY_DIR ${BINARY_DIR})
SET(POCKETSPHINX_LIBRARIES ${POCKETSPHINX_BINARY_DIR}/bin/Debug/Win32/pocketsphinx.dll)
SET(DEPENDENCIES ${DEPENDENCIES} pocketsphinx)
INCLUDE_DIRECTORIES(${POCKETSPHINX_SOURCE_DIR}/include/)
add_definitions(-DMODELDIR="${POCKETSPHINX_BINARY_DIR}/model")
endif ()
SET(LIBS ${LIBS} ${POCKETSPHINX_LIBRARIES})
FIND_PACKAGE(PortAudio)
if (${PORTAUDIO_FOUND})
INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
else ()
ExternalProject_Add(
PortAudio
GIT_REPOSITORY "https://github.com/syb0rg/PortAudio2.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/PortAudio
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(PortAudio SOURCE_DIR)
ExternalProject_Get_Property(PortAudio BINARY_DIR)
SET(PORTAUDIO_SOURCE_DIR ${SOURCE_DIR})
SET(PORTAUDIO_BINARY_DIR ${BINARY_DIR})
SET(PORTAUDIO_LIBRARIES ${PORTAUDIO_BINARY_DIR}/libportaudio_x86.dll)
SET(DEPENDENCIES ${DEPENDENCIES} PortAudio)
INCLUDE_DIRECTORIES(${PORTAUDIO_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${PORTAUDIO_LIBRARIES})
FIND_PACKAGE(LibSndFile)
if(${LIBSNDFILE_FOUND})
INCLUDE_DIRECTORIES(${LIBSNDFILE_INCLUDE_DIRS})
else ()
ExternalProject_Add(
LibSndFile
GIT_REPOSITORY "https://github.com/syb0rg/libsndfile.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/LibSndFile
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(LibSndFile SOURCE_DIR)
ExternalProject_Get_Property(LibSndFile BINARY_DIR)
SET(LIBSNDFILE_SOURCE_DIR ${SOURCE_DIR}/src)
SET(LIBSNDFILE_BINARY_DIR ${BINARY_DIR})
SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_BINARY_DIR}/libsndfile.dll)
SET(DEPENDENCIES ${DEPENDENCIES} LibSndFile)
INCLUDE_DIRECTORIES(${LIBSNDFILE_SOURCE_DIR})
endif ()
SET(LIBS ${LIBS} ${LIBSNDFILE_LIBRARIES})
FIND_PACKAGE(tritium)
if (${TRITIUM_FOUND})
INCLUDE_DIRECTORIES(${TRITIUM_INCLUDE_DIR}/)
else ()
ExternalProject_Add(
tritium
GIT_REPOSITORY "https://github.com/syb0rg/tritium.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/tritium
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(tritium SOURCE_DIR)
ExternalProject_Get_Property(tritium BINARY_DIR)
SET(TRITIUM_SOURCE_DIR ${SOURCE_DIR})
SET(TRITIUM_BINARY_DIR ${BINARY_DIR})
SET(TRITIUM_LIBRARIES ${TRITIUM_BINARY_DIR}/libtritium.a)
SET(DEPENDENCIES ${DEPENDENCIES} tritium)
INCLUDE_DIRECTORIES(${TRITIUM_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${TRITIUM_LIBRARIES})
All of these libraries exist at the specified location. Any suggestions?
undefined reference to clearly stated you do not provide required object file/library with this (exported!) function to linker. There are two major causes:
You didn't pass this library to linker command line or didn't pass right search path (-L...) to it - check twice the resulting command line, make VERBOSE=1 will show more verbose output.
Path is correct, but file/function itself is invalid - you may compile library for different CPU architecture (e.g. trying to use x86 library when targeting x86_64). Also check function marked as exportable (in most cases it is the problem when using MSVC compiler, but you can hide functions with GCC/MinGW too). And do not forgot to check file is not zero-length :)
Can you try this:
set(CMAKE_BUILD_TYPE CACHE Release FORCE)
ref: https://cmake.org/cmake/help/v2.8.8/cmake.html#variable:CMAKE_CFG_INTDIR
search for : initial-cache
Currently, I am working with Raspberry Pi:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 8.0 (jessie)
Release: 8.0
Codename: jessie
I have some libraries (C language) that look like bellow:
my_app\-my_app.c
\ - CMakeLists.txt
\-lib
\-lib1\- CMakeLists.txt
\- src
\- lib1.c
\- CMakeLists.txt
\- include
\- lib1.h
\- cmake
\- modules
\- FindGLIB2.cmake
\- MacroOutOfSourceBuild.cmake
....................
The lib1 is depends on glib
#include <glib.h>
Here's my CMakeLists.txt for my_app
cmake_minimum_required(VERSION 2.8)
project(my_app)
set(CMAKE_MODULE_PATH ${my_app_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
# Enable C11 or at least C99
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=c11" COMPILER_SUPPORTS_C11)
CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_SUPPORTS_C99)
if(COMPILER_SUPPORTS_C11)
message(STATUS "Using C11.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
elseif(COMPILER_SUPPORTS_C99)
message(STATUS "The compiler ${CMAKE_C_COMPILER} has no C11 support. Using C99 instead.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
else()
message(STATUS "The compiler ${CMAKE_C_COMPILER} has no C11 nor C99 support. Please update your C compiler.")
endif()
SET (CMAKE_C_FLAGS "-lm")
include(MacroOutOfSourceBuild)
include(TargetDistclean)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build.")
add_subdirectory(lib/lib2)
add_subdirectory(lib/lib1)
include_directories(${lib2_SOURCE_DIR}/include)
include_directories(${lib1_SOURCE_DIR}/include)
# Add sources
set(my_app_SOURCES my_app.c)
add_executable(my_app ${my_app_SOURCES})
target_link_libraries(my_app
lib2
lib1
)
install(TARGETS my_app
RUNTIME DESTINATION bin
)
Here's my CMakeLists.txt for my_app/lib1
cmake_minimum_required(VERSION 2.8)
project(lib1)
set(CMAKE_MODULE_PATH ${lib1_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
SET (CMAKE_C_FLAGS "")
include(MacroOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build.")
add_subdirectory(src)
install(DIRECTORY include/lib1 DESTINATION include)
Here's my CMakeLists.txt for my_app/lib1/src
# Include the directory itself as a path to include directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(FindGLIB2)
include_directories(
${lib1_SOURCE_DIR}/include
${GLIB2_INCLUDE_DIRS}
)
set(lib1_SOURCES
lib1.c
)
add_library(lib1 ${lib1_SOURCES})
target_link_libraries(lib1
${GLIB2_LIBRARIES}
)
install(TARGETS lib1
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
Here is the log file:
pi#raspberrypi ~/my_app/build $ cmake ..
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- checking for one of the modules 'glib-2.0'
-- Found GLib2: glib-2.0 /usr/include/glib-2.0;/usr/lib/arm-linux-gnueabihf/glib-2.0/include
-- Looking for include file glib/gregex.h
-- Looking for include file glib/gregex.h - not found
-- Looking for include file glib/gchecksum.h
-- Looking for include file glib/gchecksum.h - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/my_app/build
That means I already have glib on my system.
Now, I have this problems:
If I use #include <glib.h> only for lib1.c. Everything is OK.
If I use #include <glib.h> only for lib1.h. I saw this problem with lib1.h:
lib1.h:2:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
EDITED
The error come from my_app.c which include lib1.h
Here are more log with VERBOSE=yes
ERROR with lib1.h
pi#raspberrypi ~/my_app/build $ make VERBOSE=1
/usr/bin/cmake -H/home/pi/my_app -B/home/pi/my_app/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/my_app/build/CMakeFiles /home/pi/my_app/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/bzle/src /home/pi/my_app/build /home/pi/my_app/build/lib/bzle/src /home/pi/my_app/build/lib/bzle/src/CMakeFiles/bzle.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/bzle/src/CMakeFiles/bzle.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 3 4 5 6 7 8 9 10 11 12 13 14
[ 60%] Built target bzle
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib1/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib1/src /home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/lib1/src/CMakeFiles/lib1.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 1 2
[ 70%] Built target lib1
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib2/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib2/src /home/pi/my_app/build/lib/lib2/src/CMakeFiles/lib2.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/lib2/src/CMakeFiles/lib2.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 20
[ 75%] Built target lib2
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/ini/src /home/pi/my_app/build /home/pi/my_app/build/lib/ini/src /home/pi/my_app/build/lib/ini/src/CMakeFiles/ini.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/ini/src/CMakeFiles/ini.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 18
[ 80%] Built target ini
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app /home/pi/my_app/build /home/pi/my_app/build /home/pi/my_app/build/CMakeFiles/my_app.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 19
[ 85%] Building C object CMakeFiles/my_app.dir/my_app.c.o
/usr/bin/cc -lm -I/home/pi/my_app/lib/bzle/include -I/home/pi/my_app/lib/ini/include -I/home/pi/my_app/lib/lib2/include -I/home/pi/my_app/lib/lib1/include -o CMakeFiles/my_app.dir/my_app.c.o -c /home/pi/my_app/my_app.c
In file included from /home/pi/my_app/my_app.c:53:0:
/home/pi/my_app/lib/lib1/include/lib1/lib1.h:2:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
CMakeFiles/my_app.dir/build.make:54: recipe for target 'CMakeFiles/my_app.dir/my_app.c.o' failed
make[2]: *** [CMakeFiles/my_app.dir/my_app.c.o] Error 1
make[2]: Leaving directory '/home/pi/my_app/build'
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/my_app.dir/all' failed
make[1]: *** [CMakeFiles/my_app.dir/all] Error 2
make[1]: Leaving directory '/home/pi/my_app/build'
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
OK with lib1.c
pi#raspberrypi ~/my_app/build $ make VERBOSE=1
/usr/bin/cmake -H/home/pi/my_app -B/home/pi/my_app/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/my_app/build/CMakeFiles /home/pi/my_app/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/bzle/src /home/pi/my_app/build /home/pi/my_app/build/lib/bzle/src /home/pi/my_app/build/lib/bzle/src/CMakeFiles/bzle.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/bzle/src/CMakeFiles/bzle.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 3 4 5 6 7 8 9 10 11 12 13 14
[ 60%] Built target bzle
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib1/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib1/src /home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/DependInfo.cmake --color=
Dependee "../lib/lib1/include/lib1/other_beacon.h" is newer than depender "lib/lib1/src/CMakeFiles/lib1.dir/other_beacon.c.o".
Dependee "/home/pi/my_app/lib/lib1/src/other_beacon.c" is newer than depends file "/home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/depend.internal".
Clearing dependencies in "/home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/depend.make".
Scanning dependencies of target lib1
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 1
[ 65%] Building C object lib/lib1/src/CMakeFiles/lib1.dir/other_beacon.c.o
cd /home/pi/my_app/build/lib/lib1/src && /usr/bin/cc -I/home/pi/my_app/build/lib/lib1/src -I/home/pi/my_app/lib/lib1/src -I/home/pi/my_app/lib/lib1/include -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/lib1.dir/other_beacon.c.o -c /home/pi/my_app/lib/lib1/src/other_beacon.c
Linking C static library liblib1.a
cd /home/pi/my_app/build/lib/lib1/src && /usr/bin/cmake -P CMakeFiles/lib1.dir/cmake_clean_target.cmake
cd /home/pi/my_app/build/lib/lib1/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/lib1.dir/link.txt --verbose=1
/usr/bin/ar cr liblib1.a CMakeFiles/lib1.dir/other_beacon.c.o CMakeFiles/lib1.dir/ibeacon.c.o
/usr/bin/ranlib liblib1.a
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 1 2
[ 70%] Built target lib1
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib2/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib2/src /home/pi/my_app/build/lib/lib2/src/CMakeFiles/lib2.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/lib2/src/CMakeFiles/lib2.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 20
[ 75%] Built target lib2
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/ini/src /home/pi/my_app/build /home/pi/my_app/build/lib/ini/src /home/pi/my_app/build/lib/ini/src/CMakeFiles/ini.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/ini/src/CMakeFiles/ini.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 18
[ 80%] Built target ini
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app /home/pi/my_app/build /home/pi/my_app/build /home/pi/my_app/build/CMakeFiles/my_app.dir/DependInfo.cmake --color=
Dependee "../lib/lib1/include/lib1/other_beacon.h" is newer than depends file "/home/pi/my_app/build/CMakeFiles/my_app.dir/depend.internal".
Clearing dependencies in "/home/pi/my_app/build/CMakeFiles/my_app.dir/depend.make".
Scanning dependencies of target my_app
make[2]: Leaving directory '/home/pi/my_app/build'
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 19
[ 85%] Building C object CMakeFiles/my_app.dir/my_app.c.o
/usr/bin/cc -lm -I/home/pi/my_app/lib/bzle/include -I/home/pi/my_app/lib/ini/include -I/home/pi/my_app/lib/lib2/include -I/home/pi/my_app/lib/lib1/include -o CMakeFiles/my_app.dir/my_app.c.o -c /home/pi/my_app/my_app.c
Linking C executable my_app
/usr/bin/cmake -E cmake_link_script CMakeFiles/my_app.dir/link.txt --verbose=1
/usr/bin/cc -lm CMakeFiles/my_app.dir/my_app.c.o -o my_app -rdynamic lib/bzle/src/libbzle.a lib/ini/src/libini.a lib/lib2/src/liblib2.a lib/lib1/src/liblib1.a lib/bzle/src/libbzle.a -lglib-2.0
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 19
[ 85%] Built target my_app
make -f lib/bzle/tools/CMakeFiles/hciconfig.dir/build.make lib/bzle/tools/CMakeFiles/hciconfig.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/bzle/tools /home/pi/my_app/build /home/pi/my_app/build/lib/bzle/tools /home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/DependInfo.cmake --color=
Dependee "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/DependInfo.cmake" is newer than depender "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/depend.internal".
Dependee "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/depend.internal".
Scanning dependencies of target hciconfig
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/bzle/tools/CMakeFiles/hciconfig.dir/build.make lib/bzle/tools/CMakeFiles/hciconfig.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 15
[ 90%] Building C object lib/bzle/tools/CMakeFiles/hciconfig.dir/csr.c.o
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cc -Wall -I/home/pi/my_app/build/lib/bzle/tools -I/home/pi/my_app/lib/bzle/tools -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/hciconfig.dir/csr.c.o -c /home/pi/my_app/lib/bzle/tools/csr.c
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 16
[ 95%] Building C object lib/bzle/tools/CMakeFiles/hciconfig.dir/hciconfig.c.o
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cc -Wall -I/home/pi/my_app/build/lib/bzle/tools -I/home/pi/my_app/lib/bzle/tools -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/hciconfig.dir/hciconfig.c.o -c /home/pi/my_app/lib/bzle/tools/hciconfig.c
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 17
[100%] Building C object lib/bzle/tools/CMakeFiles/hciconfig.dir/textfile.c.o
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cc -Wall -I/home/pi/my_app/build/lib/bzle/tools -I/home/pi/my_app/lib/bzle/tools -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/hciconfig.dir/textfile.c.o -c /home/pi/my_app/lib/bzle/tools/textfile.c
Linking C executable hciconfig
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cmake -E cmake_link_script CMakeFiles/hciconfig.dir/link.txt --verbose=1
/usr/bin/cc -Wall CMakeFiles/hciconfig.dir/csr.c.o CMakeFiles/hciconfig.dir/hciconfig.c.o CMakeFiles/hciconfig.dir/textfile.c.o -o hciconfig -rdynamic ../src/libbzle.a -lglib-2.0
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 15 16 17
[100%] Built target hciconfig
make[1]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_start /home/pi/my_app/build/CMakeFiles 0
I have know ideas about this.
Could you please give me some advice?
I'm trying to use libical for a C-project. Unfortunately, the make command gives me the following output:
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in design-data
make[2]: Nothing to be done for `all'.
Making all in doc
make[2]: Nothing to be done for `all'.
Making all in scripts
make[2]: Nothing to be done for `all'.
Making all in test-data
make[2]: Nothing to be done for `all'.
Making all in src
Making all in libical
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-am
/bin/sh ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../src -I../../src -I../../src/libical -I../../src/libical -I. -DPACKAGE_DATA_DIR=\""/usr/local/libical/share/libical"\" -g -O2 -MT icalderivedparameter.lo -MD -MP -MF .deps/icalderivedparameter.Tpo -c -o icalderivedparameter.lo icalderivedparameter.c
mv -f .deps/icalderivedparameter.Tpo .deps/icalderivedparameter.Plo
mv: rename .deps/icalderivedparameter.Tpo to .deps/icalderivedparameter.Plo: No such file or directory
make[4]: *** [icalderivedparameter.lo] Error 1
make[3]: *** [all] Error 2
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I'm not sure whats wrong here. I'm running OS X 10.9 and gcc.
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
You must call ./bootstrap.
./bootstrap
./configure
make
make install
Bootstrap was the key for me.
I have a project (with 3 subprojects) with CMake that builds perfectly when I execute cmake in the same directory as the top CMakeLists.txt. But when I try an out of source build I get the following error:
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi$ mkdir build
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi$ cd build/
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ ls
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ cmake ..
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ make
/usr/bin/cmake -H/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -B/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make -f pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build.make pi_mpireduce/CMakeFiles/pi_mpireduce.dir/depend
make[2]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce/CMakeFiles/pi_mpireduce.dir/DependInfo.cmake --color=
Scanning dependencies of target pi_mpireduce
make[2]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make -f pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build.make pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build
make[2]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
/usr/bin/cmake -E cmake_progress_report /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles 1
[ 20%] Building C object pi_mpireduce/CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && mpicc -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/include -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/include -o CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o -c /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/src/mpi_pi_reduce.c
/usr/bin/cmake -E cmake_progress_report /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles 2
[ 40%] Building C object pi_mpireduce/CMakeFiles/pi_mpireduce.dir/src/dboard.c.o
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && mpicc -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/include -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/include -o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -c /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/src/dboard.c
Linking C executable .
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && /usr/bin/cmake -E cmake_link_script CMakeFiles/pi_mpireduce.dir/link.txt --verbose=1
mpicc CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -o . -rdynamic -lmpi
/usr/bin/ld: cannot open output file .: Is a directory
collect2: error: ld returned 1 exit status
make[2]: *** [pi_mpireduce] Error 1
make[2]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make[1]: *** [pi_mpireduce/CMakeFiles/pi_mpireduce.dir/all] Error 2
make[1]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make: *** [all] Error 2
I found out what the problem was. The executable and the directory of the subproject had the same name. Chaning the executable name did the trick.
The line
mpicc CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -o . -rdynamic -lmpi
tells the linker that the output name of the compilation shall be ., which is not a valid name for an executable or library or anything at all. This may come from you setting a target name from a variable that is empty during configure time or you accidentally wrote a . there.
My problem is the following one:
When installing Axis2/c under the guidance of http://petio.org/ws/web_services_page7.html , which seems to be an adjusted manual from the official site I have a problem right after executing the make command in terminal.
At exactly this point:
$ cd /tmp/axis/axis2c-src-1.6.0
$ ./configure --prefix=${AXIS2C_HOME} --enable-libxml2=yes
$ make
I get this error:
XXX#XXXPC:~/Tools/axis2c/axis2c-src-1.5.0$ make
make all-recursive
make[1]: Entering directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0'
Making all in util
make[2]: Entering directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util'
make all-recursive
make[3]: Entering directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util'
Making all in src
make[4]: Entering directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util/src'
Making all in platforms/unix
make[5]: Entering directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util/src/platforms/unix'
/bin/bash ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../../include -I../../../include/platforms -I../../../include/platforms/unix -g -O2 -D_LARGEFILE64_SOURCE -ansi -Wall -Werror -Wno-implicit-function-declaration -D_GNU_SOURCE -MT uuid_gen_unix.lo -MD -MP -MF .deps/uuid_gen_unix.Tpo -c -o uuid_gen_unix.lo uuid_gen_unix.c
gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../../include -I../../../include/platforms -I../../../include/platforms/unix -g -O2 -D_LARGEFILE64_SOURCE -ansi -Wall -Werror -Wno-implicit-function-declaration -D_GNU_SOURCE -MT uuid_gen_unix.lo -MD -MP -MF .deps/uuid_gen_unix.Tpo -c uuid_gen_unix.c -fPIC -DPIC -o .libs/uuid_gen_unix.o
**uuid_gen_unix.c: In function ‘axutil_uuid_gen_v1’:
uuid_gen_unix.c:62:20: error: variable ‘tv’ set but not used [-Werror=unused-but-set-variable]**
cc1: all warnings being treated as errors
make[5]: *** [uuid_gen_unix.lo] Error 1
make[5]: Leaving directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util/src/platforms/unix'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0/util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/XXX/Tools/axis2c/axis2c-src-1.5.0'
make: *** [all] Error 2
I am not able to understand the reason why this error is being produced.
Because 1.6.0 version is down, I am using the 1.5.0 source version of axis2/c from the official site : http://axis.apache.org/axis2/c/core/download.cgi .
I have additionally installed Apache2 and libxml2, OpenSSL, cURL, libiconv, and zlib.
libraries.
I need your help because I am trying to build a serious project.
Thanks in advance.
Link to mirror of original Axis2/C-1.6.0 source distribution is here.
The main problem is with -Werror flag.
To compile original Axis2/C with modern compiler you must remove -Werror string from build scripts. To do that run this command after unpacking tarball:
find -type f -name configure -exec sed -i '/CFLAGS/s/-Werror//g' {} \;
Then configure and make Axis2/C.
Note: Original Axis2/C-1.6.0 has many issues like memory leaks and crashes. Consider using Axis2/C unofficial project instead. Most critical Axis2/C-1.6.0's issues is fixed within that project.
Also it have additional features https://code.google.com/p/axis2c-unofficial/wiki/IssuesList like JSON support and enhanced CURL-based transport authentication (and some other features).
There is an manual on how to install Axis2/C unofficial on Linux.