building Gstreamer mpegts project with Cmake - c

We are trying to use Gstreamer's mpegts pluging to record a video stream stream using the following Gstreamer example code https://gstreamer.freedesktop.org/documentation/mpegtsmux/mpegtsmux.html?gi-language=c. When we compile the code using gcc mpegtstest.c -o mpegtstest `pkg-config --cflags --libs gstreamer-1.0 gstreamer-mpegts-1.0` -v everything works as expected and the program records with no issues. We are now trying to compile the code using cmake and make. cmake generates correctly but make fails with error.
/usr/bin/ld: cannot find -lgstreamer-mpegts-1.0.
CMakeLists.txt
##################### STANDARD HEADER #########################
cmake_minimum_required(VERSION 2.6)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "" FORCE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeHelpers/")
##################### PROJECT DEF #############################
project(mpegsttest)
################### VARIABLES #################################
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/../")
set(MPEGTS_TEST_SOURCES
mpegtstest.c
)
####################### Targets ########################
add_executable(${CMAKE_PROJECT_NAME} ${MPEGTS_TEST_SOURCES})
################### Linked Libraries ###################
find_package(GLIB2 REQUIRED)
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories("/usr/include/gio-unix-2.0")
target_link_libraries(${CMAKE_PROJECT_NAME} ${GLIB2_LIBRARIES} gobject-2.0 gio-2.0)
find_package(GStreamer REQUIRED)
include_directories(${GSTREAMER_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GSTREAMER_LIBRARIES})
include_directories(${GSTREAMER-MPEGTS_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} gstreamer-mpegts-1.0)
cmake output
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- 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
-- Detecting C compile features
-- Detecting C compile features - 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
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for one of the modules 'glib-2.0'
-- Found GLib2: glib-2.0 /usr/include/glib-2.0;/usr/lib/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
-- Checking for module 'gstreamer-1.0 >= '
-- Found gstreamer-1.0 , version 1.6.3
-- Checking for module 'gstreamer-base-1.0 >= '
-- Found gstreamer-base-1.0 , version 1.6.3
-- Checking for module 'gstreamer-app-1.0 >= '
-- Found gstreamer-app-1.0 , version 1.6.3
-- Checking for module 'gstreamer-audio-1.0 >= '
-- Found gstreamer-audio-1.0 , version 1.6.3
-- Checking for module 'gstreamer-fft-1.0 >= '
-- Found gstreamer-fft-1.0 , version 1.6.3
-- Checking for module 'gstreamer-mpegts-1.0>=1.4.0'
-- Found gstreamer-mpegts-1.0, version 1.6.3
-- Checking for module 'gstreamer-pbutils-1.0 >= '
-- Found gstreamer-pbutils-1.0 , version 1.6.3
-- Checking for module 'gstreamer-tag-1.0 >= '
-- Found gstreamer-tag-1.0 , version 1.6.3
-- Checking for module 'gstreamer-video-1.0 >= '
-- Found gstreamer-video-1.0 , version 1.6.3
-- Found GStreamer: GSTREAMER_INCLUDE_DIRS;GSTREAMER_LIBRARIES;GSTREAMER_VERSION;GSTREAMER_BASE_INCLUDE_DIRS;GSTREAMER_BASE_LIBRARIES
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dev3lx/build/mpegts
make --trace output
Makefile:176: target 'cmake_check_build_system' does not exist
/usr/bin/cmake -H/home/dev3lx/Development/mptestsrc -B/home/dev3lx/build/mpegts --check-build-system CMakeFiles/Makefile.cmake 0
Makefile:83: update target 'all' due to: cmake_check_build_system
/usr/bin/cmake -E cmake_progress_start /home/dev3lx/build/mpegts/CMakeFiles /home/dev3lx/build/mpegts/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
CMakeFiles/Makefile2:67: target 'CMakeFiles/mpegsttest.dir/all' does not exist
make -f CMakeFiles/mpegsttest.dir/build.make CMakeFiles/mpegsttest.dir/depend
CMakeFiles/mpegsttest.dir/build.make:112: target 'CMakeFiles/mpegsttest.dir/depend' does not exist
cd /home/dev3lx/build/mpegts && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dev3lx/Development/mptestsrc /home/dev3lx/Development/mptestsrc /home/dev3lx/build/mpegts /home/dev3lx/build/mpegts /home/dev3lx/build/mpegts/CMakeFiles/mpegsttest.dir/DependInfo.cmake --color=
Scanning dependencies of target mpegsttest
make -f CMakeFiles/mpegsttest.dir/build.make CMakeFiles/mpegsttest.dir/build
CMakeFiles/mpegsttest.dir/build.make:62: update target 'CMakeFiles/mpegsttest.dir/mpegtstest.c.o' due to: /home/dev3lx/Development/mptestsrc/mpegtstest.c /usr/include/glib-2.0/glib-object.h /usr/include/glib-2.0/glib.h /usr/include/glib-2.0/glib/deprecated/gallocator.h /usr/include/glib-2.0/glib/deprecated/gcache.h /usr/include/glib-2.0/glib/deprecated/gcompletion.h /usr/include/glib-2.0/glib/deprecated/gmain.h /usr/include/glib-2.0/glib/deprecated/grel.h /usr/include/glib-2.0/glib/deprecated/gthread.h /usr/include/glib-2.0/glib/galloca.h /usr/include/glib-2.0/glib/garray.h /usr/include/glib-2.0/glib/gasyncqueue.h /usr/include/glib-2.0/glib/gatomic.h /usr/include/glib-2.0/glib/gbacktrace.h /usr/include/glib-2.0/glib/gbase64.h /usr/include/glib-2.0/glib/gbitlock.h /usr/include/glib-2.0/glib/gbookmarkfile.h /usr/include/glib-2.0/glib/gbytes.h /usr/include/glib-2.0/glib/gcharset.h /usr/include/glib-2.0/glib/gchecksum.h /usr/include/glib-2.0/glib/gconvert.h /usr/include/glib-2.0/glib/gdataset.h /usr/include/glib-2.0/glib/gdate.h /usr/include/glib-2.0/glib/gdatetime.h /usr/include/glib-2.0/glib/gdir.h /usr/include/glib-2.0/glib/genviron.h /usr/include/glib-2.0/glib/gerror.h /usr/include/glib-2.0/glib/gfileutils.h /usr/include/glib-2.0/glib/ggettext.h /usr/include/glib-2.0/glib/ghash.h /usr/include/glib-2.0/glib/ghmac.h /usr/include/glib-2.0/glib/ghook.h /usr/include/glib-2.0/glib/ghostutils.h /usr/include/glib-2.0/glib/giochannel.h /usr/include/glib-2.0/glib/gkeyfile.h /usr/include/glib-2.0/glib/glib-autocleanups.h /usr/include/glib-2.0/glib/glist.h /usr/include/glib-2.0/glib/gmacros.h /usr/include/glib-2.0/glib/gmain.h /usr/include/glib-2.0/glib/gmappedfile.h /usr/include/glib-2.0/glib/gmarkup.h /usr/include/glib-2.0/glib/gmem.h /usr/include/glib-2.0/glib/gmessages.h /usr/include/glib-2.0/glib/gnode.h /usr/include/glib-2.0/glib/goption.h /usr/include/glib-2.0/glib/gpattern.h /usr/include/glib-2.0/glib/gpoll.h /usr/include/glib-2.0/glib/gprimes.h /usr/include/glib-2.0/glib/gqsort.h /usr/include/glib-2.0/glib/gquark.h /usr/include/glib-2.0/glib/gqueue.h /usr/include/glib-2.0/glib/grand.h /usr/include/glib-2.0/glib/gregex.h /usr/include/glib-2.0/glib/gscanner.h /usr/include/glib-2.0/glib/gsequence.h /usr/include/glib-2.0/glib/gshell.h /usr/include/glib-2.0/glib/gslice.h /usr/include/glib-2.0/glib/gslist.h /usr/include/glib-2.0/glib/gspawn.h /usr/include/glib-2.0/glib/gstrfuncs.h /usr/include/glib-2.0/glib/gstring.h /usr/include/glib-2.0/glib/gstringchunk.h /usr/include/glib-2.0/glib/gtestutils.h /usr/include/glib-2.0/glib/gthread.h /usr/include/glib-2.0/glib/gthreadpool.h /usr/include/glib-2.0/glib/gtimer.h /usr/include/glib-2.0/glib/gtimezone.h /usr/include/glib-2.0/glib/gtrashstack.h /usr/include/glib-2.0/glib/gtree.h /usr/include/glib-2.0/glib/gtypes.h /usr/include/glib-2.0/glib/gunicode.h /usr/include/glib-2.0/glib/gurifuncs.h /usr/include/glib-2.0/glib/gutils.h /usr/include/glib-2.0/glib/gvariant.h /usr/include/glib-2.0/glib/gvarianttype.h /usr/include/glib-2.0/glib/gversion.h /usr/include/glib-2.0/glib/gversionmacros.h /usr/include/glib-2.0/glib/gwin32.h /usr/include/glib-2.0/gobject/gbinding.h /usr/include/glib-2.0/gobject/gboxed.h /usr/include/glib-2.0/gobject/gclosure.h /usr/include/glib-2.0/gobject/genums.h /usr/include/glib-2.0/gobject/glib-types.h /usr/include/glib-2.0/gobject/gmarshal.h /usr/include/glib-2.0/gobject/gobject-autocleanups.h /usr/include/glib-2.0/gobject/gobject.h /usr/include/glib-2.0/gobject/gparam.h /usr/include/glib-2.0/gobject/gparamspecs.h /usr/include/glib-2.0/gobject/gsignal.h /usr/include/glib-2.0/gobject/gsourceclosure.h /usr/include/glib-2.0/gobject/gtype.h /usr/include/glib-2.0/gobject/gtypemodule.h /usr/include/glib-2.0/gobject/gtypeplugin.h /usr/include/glib-2.0/gobject/gvalue.h /usr/include/glib-2.0/gobject/gvaluearray.h /usr/include/glib-2.0/gobject/gvaluetypes.h /usr/include/gstreamer-1.0/gst/glib-compat.h /usr/include/gstreamer-1.0/gst/gst.h /usr/include/gstreamer-1.0/gst/gstallocator.h /usr/include/gstreamer-1.0/gst/gstatomicqueue.h /usr/include/gstreamer-1.0/gst/gstbin.h /usr/include/gstreamer-1.0/gst/gstbuffer.h /usr/include/gstreamer-1.0/gst/gstbufferlist.h /usr/include/gstreamer-1.0/gst/gstbufferpool.h /usr/include/gstreamer-1.0/gst/gstbus.h /usr/include/gstreamer-1.0/gst/gstcaps.h /usr/include/gstreamer-1.0/gst/gstcapsfeatures.h /usr/include/gstreamer-1.0/gst/gstchildproxy.h /usr/include/gstreamer-1.0/gst/gstclock.h /usr/include/gstreamer-1.0/gst/gstcompat.h /usr/include/gstreamer-1.0/gst/gstcontext.h /usr/include/gstreamer-1.0/gst/gstcontrolbinding.h /usr/include/gstreamer-1.0/gst/gstcontrolsource.h /usr/include/gstreamer-1.0/gst/gstdatetime.h /usr/include/gstreamer-1.0/gst/gstdebugutils.h /usr/include/gstreamer-1.0/gst/gstdevice.h /usr/include/gstreamer-1.0/gst/gstdevicemonitor.h /usr/include/gstreamer-1.0/gst/gstdeviceprovider.h /usr/include/gstreamer-1.0/gst/gstdeviceproviderfactory.h /usr/include/gstreamer-1.0/gst/gstelement.h /usr/include/gstreamer-1.0/gst/gstelementfactory.h /usr/include/gstreamer-1.0/gst/gstelementmetadata.h /usr/include/gstreamer-1.0/gst/gstenumtypes.h /usr/include/gstreamer-1.0/gst/gsterror.h /usr/include/gstreamer-1.0/gst/gstevent.h /usr/include/gstreamer-1.0/gst/gstformat.h /usr/include/gstreamer-1.0/gst/gstghostpad.h /usr/include/gstreamer-1.0/gst/gstinfo.h /usr/include/gstreamer-1.0/gst/gstiterator.h /usr/include/gstreamer-1.0/gst/gstmacros.h /usr/include/gstreamer-1.0/gst/gstmemory.h /usr/include/gstreamer-1.0/gst/gstmessage.h /usr/include/gstreamer-1.0/gst/gstmeta.h /usr/include/gstreamer-1.0/gst/gstminiobject.h /usr/include/gstreamer-1.0/gst/gstobject.h /usr/include/gstreamer-1.0/gst/gstpad.h /usr/include/gstreamer-1.0/gst/gstpadtemplate.h /usr/include/gstreamer-1.0/gst/gstparamspecs.h /usr/include/gstreamer-1.0/gst/gstparse.h /usr/include/gstreamer-1.0/gst/gstpipeline.h /usr/include/gstreamer-1.0/gst/gstplugin.h /usr/include/gstreamer-1.0/gst/gstpluginfeature.h /usr/include/gstreamer-1.0/gst/gstpoll.h /usr/include/gstreamer-1.0/gst/gstpreset.h /usr/include/gstreamer-1.0/gst/gstprotection.h /usr/include/gstreamer-1.0/gst/gstquery.h /usr/include/gstreamer-1.0/gst/gstregistry.h /usr/include/gstreamer-1.0/gst/gstsample.h /usr/include/gstreamer-1.0/gst/gstsegment.h /usr/include/gstreamer-1.0/gst/gststructure.h /usr/include/gstreamer-1.0/gst/gstsystemclock.h /usr/include/gstreamer-1.0/gst/gsttaglist.h /usr/include/gstreamer-1.0/gst/gsttagsetter.h /usr/include/gstreamer-1.0/gst/gsttask.h /usr/include/gstreamer-1.0/gst/gsttaskpool.h /usr/include/gstreamer-1.0/gst/gsttoc.h /usr/include/gstreamer-1.0/gst/gsttocsetter.h /usr/include/gstreamer-1.0/gst/gsttypefind.h /usr/include/gstreamer-1.0/gst/gsttypefindfactory.h /usr/include/gstreamer-1.0/gst/gsturi.h /usr/include/gstreamer-1.0/gst/gstutils.h /usr/include/gstreamer-1.0/gst/gstvalue.h /usr/include/gstreamer-1.0/gst/gstversion.h /usr/include/gstreamer-1.0/gst/mpegts/gst-atsc-section.h /usr/include/gstreamer-1.0/gst/mpegts/gst-dvb-descriptor.h /usr/include/gstreamer-1.0/gst/mpegts/gst-dvb-section.h /usr/include/gstreamer-1.0/gst/mpegts/gst-scte-section.h /usr/include/gstreamer-1.0/gst/mpegts/gstmpegts-enumtypes.h /usr/include/gstreamer-1.0/gst/mpegts/gstmpegtsdescriptor.h /usr/include/gstreamer-1.0/gst/mpegts/gstmpegtssection.h /usr/include/gstreamer-1.0/gst/mpegts/mpegts.h /usr/lib/glib-2.0/include/glibconfig.h /usr/lib/gstreamer-1.0/include/gst/gstconfig.h CMakeFiles/mpegsttest.dir/flags.make
/usr/bin/cmake -E cmake_echo_color --switch= --green --progress-dir=/home/dev3lx/build/mpegts/CMakeFiles --progress-num=1 "Building C object CMakeFiles/mpegsttest.dir/mpegtstest.c.o"
[ 50%] Building C object CMakeFiles/mpegsttest.dir/mpegtstest.c.o
/usr/bin/cc -I/home/dev3lx/build/mpegts -I/home/dev3lx/Development/mptestsrc/.. -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gio-unix-2.0 -I/usr/include/gstreamer-1.0 -I/usr/lib/gstreamer-1.0/include -o CMakeFiles/mpegsttest.dir/mpegtstest.c.o -c /home/dev3lx/Development/mptestsrc/mpegtstest.c
CMakeFiles/mpegsttest.dir/build.make:95: update target 'mpegsttest' due to: CMakeFiles/mpegsttest.dir/link.txt CMakeFiles/mpegsttest.dir/mpegtstest.c.o CMakeFiles/mpegsttest.dir/build.make /usr/lib64/libgstreamer-1.0.so
/usr/bin/cmake -E cmake_echo_color --switch= --green --bold --progress-dir=/home/dev3lx/build/mpegts/CMakeFiles --progress-num=2 "Linking C executable mpegsttest"
[100%] Linking C executable mpegsttest
/usr/bin/cmake -E cmake_link_script CMakeFiles/mpegsttest.dir/link.txt --verbose=
/usr/bin/ld: cannot find -lgstreamer-mpegts-1.0
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/mpegsttest.dir/build.make:96: mpegsttest] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/mpegsttest.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
After searching online and trying a few different things found online like here and looking at Github code we don't know why or how to fix it. Any advice or assistance is much appreciated. thanks in advance.
Solution
Thanks to nega's comment and solution, changing include_directories(${GSTREAMER-MPEGTS_INCLUDE_DIRS}) to include_directories(${GSTREAMER_MPEGTS_INCLUDE_DIRS}) worked.

Based on your cmake output, I'd guess that you're using a version of FindGStreamer.cmake cribbed from WebKit. If that's the case, the variable you want to use is GSTREAMER_MPEGTS_INCLUDE_DIRS. Note the lack of a hyphen in the variable name.
If that's not the case, use a simple message() statement before the use of a variable to show you its value during the cmake step.
In your CMakeLists.txt:
message("GMID: ${GSTREAMER_MPEGTS_INCLUDE_DIRS}")
include_directories(${GSTREAMER_MPEGTS_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} gstreamer-mpegts-1.0)
In your shell:
$ cmake ../src |grep -i ^gmid
GMID: /usr/local/Cellar/libffi/3.3_2/include;/usr/local/Cellar/gst-plugins-bad/1.18.3/include/gstreamer-1.0;/usr/local/Cellar/gstreamer/1.18.3/include/gstreamer-1.0;/usr/local/Cellar/glib/2.66.7/include;/usr/local/Cellar/glib/2.66.7/include/glib-2.0;/usr/local/Cellar/glib/2.66.7/lib/glib-2.0/include;/usr/local/opt/gettext/include;/usr/local/Cellar/pcre/8.44/include
Another easy debugging step is to grep the cache after running cmake.
$ grep -i ^gstream CMakeCache.txt
GSTREAMER_APP_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgstapp-1.0.dylib
GSTREAMER_AUDIO_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgstaudio-1.0.dylib
GSTREAMER_BASE_LIBRARIES:FILEPATH=/usr/local/Cellar/gstreamer/1.18.3/lib/libgstbase-1.0.dylib
GSTREAMER_CODECPARSERS_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-bad/1.18.3/lib/libgstcodecparsers-1.0.dylib
GSTREAMER_FFT_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgstfft-1.0.dylib
GSTREAMER_FULL_LIBRARIES:FILEPATH=GSTREAMER_FULL_LIBRARIES-NOTFOUND
GSTREAMER_GL_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgstgl-1.0.dylib
GSTREAMER_LIBRARIES:FILEPATH=/usr/local/Cellar/gstreamer/1.18.3/lib/libgstreamer-1.0.dylib
GSTREAMER_MPEGTS_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-bad/1.18.3/lib/libgstmpegts-1.0.dylib
GSTREAMER_PBUTILS_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgstpbutils-1.0.dylib
GSTREAMER_TAG_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgsttag-1.0.dylib
GSTREAMER_VIDEO_LIBRARIES:FILEPATH=/usr/local/Cellar/gst-plugins-base/1.18.3/lib/libgstvideo-1.0.dylib

Related

MinGW CMake make googletest with make error but no hit

I's m trying to compile gtest and gmock on windows10 with MinGW and Cmake;
Tools:
cmake --version
cmake version 3.21.1
gcc -v
gcc version 8.1.0
mingw32-make.exe -v
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Build command as followed:
(base) PS D:\WorkSpace\Codes\GTest_GMock\googletest-master\build> cmake .. -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS=-std=gnu++11
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: D:/ProgramData/Miniconda3/python.exe (found version "3.9.5") found components: Interpreter
-- Configuring done
-- Generating done
-- Build files have been written to: D:/WorkSpace/Codes/GTest_GMock/googletest-master/build
(base) PS D:\WorkSpace\Codes\GTest_GMock\googletest-master\build> mingw32-make.exe
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj
系统找不到指定的路径。(cannot find path)
mingw32-make[2]: *** [googletest\CMakeFiles\gtest.dir\build.make:76: googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
mingw32-make[2]: *** Deleting file 'googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj'
mingw32-make[1]: *** [CMakeFiles\Makefile2:171: googletest/CMakeFiles/gtest.dir/all] Error 2
mingw32-make: *** [Makefile:145: all] Error 2
(base) PS D:\WorkSpace\Codes\GTest_GMock\googletest-master\build>

Check for working C compiler: /usr/bin/cc -- broken

I am having a problem with the installation of a ROS packages on my raspberry pi 3. I really hope you can help me.
<== Finished processing package [10 of 53]: 'fzi_icl_core'
==> Processing plain cmake package: 'fzi_icl_can'
==> Building with env: '/opt/ros/kinetic/env.sh'
==> cmake /home/pi/ros_catkin_ws/src/fzi_icl_can -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G Unix Makefiles in '/home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install'
The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
** The C compiler "/usr/bin/cc" is not able to compile a simple test program.**
It fails with the following output:
Change Dir: /home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_cd4f1/fast"
/usr/bin/make -f CMakeFiles/cmTC_cd4f1.dir/build.make
CMakeFiles/cmTC_cd4f1.dir/build
make[1]: Entering directory
'/home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_cd4f1.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_cd4f1.dir/testCCompiler.c.o -c
/home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install/CMakeFiles/CMakeTmp/testCCompiler.c
cc1: internal compiler error: in next_pass_1, at passes.c:1258
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
CMakeFiles/cmTC_cd4f1.dir/build.make:65: recipe for target
'CMakeFiles/cmTC_cd4f1.dir/testCCompiler.c.o' failed
make[1]: *** [CMakeFiles/cmTC_cd4f1.dir/testCCompiler.c.o] Error 1
make[1]: Leaving directory
'/home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_cd4f1/fast' failed
make: *** [cmTC_cd4f1/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install/CMakeFiles/CMakeOutput.log".
See also "/home/pi/ros_catkin_ws/build_isolated/fzi_icl_can/install/CMakeFiles/CMakeError.log".
<== Failed to process package 'fzi_icl_can':
Command '['/opt/ros/kinetic/env.sh', 'cmake', '/home/pi/ros_catkin_ws/src/fzi_icl_can', '-DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic', '-DCMAKE_BUILD_TYPE=Release', '-G', 'Unix Makefiles']' returned non-zero exit status 1
Reproduce this error by running:
==> cd /home/pi/ros_catkin_ws/build_isolated/fzi_icl_can && /opt/ros/kinetic/env.sh cmake /home/pi/ros_catkin_ws/src/fzi_icl_can -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'
Command failed, exiting.
The output was:
1
cc1: internal compiler error: in next_pass_1, at passes.c:1258
Please submit a full bug report,
If you haven't already, I would try sudo apt-get install build-essential to make sure that all the necessary build components are installed.
Search installed gcc libs:
dpkg -l | grep libgcc | cut -d' ' -f 3 | tr '\n' ' '
My result:
libgcc-5-dev:amd64 libgcc1:amd64
Reinstall it:
apt install --reinstall libgcc1:armhf libgcc-5-dev:armhf

CMake not compile on raspberry

I'm new with cmake.
With cmake I was able to compile my project on my laptop, but on the raspberry is not working.
This is the error i get on raspberry:
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- 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
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- checking for one of the modules 'glib-2.0'
-- Found GLib: /usr/lib/arm-linux-gnueabihf/libglib-2.0.so (found version "2.42.1")
-- Found mhd: /usr/include
CMake Error at cmake/FindGLIB.cmake:39 (add_library): add_library cannot create imported target "glib-2.0" because another target with the same name already exists.
Call Stack (most recent call first):librerie/CMakeLists.txt:2 (find_package)
-- Found GLib: /usr/lib/arm-linux-gnueabihf/libglib-2.0.so (found version "2.42.1")
-- Configuring incomplete, errors occurred!
See also "/home/pi/pl1/CMakeFiles/CMakeOutput.log".
This is my project structure:
src->
---- CMakeLists.txt
---- main.c
---- librerie->
-------------- CMakeLists.txt
-------------- cJSON.c
-------------- cJSON.h
-------------- config.c
-------------- config.h
-------------- server_web.c
-------------- server_web.h
-------------- funzioni_thread.c
-------------- funzioni_thread.h
---- cmake->
-------------- FindGLIB.cmake
-------------- FindMHD.cmake
This is First CMakeLists :
cmake_minimum_required (VERSION 2.6)
project (TestPL)
include_directories("${PROJECT_BINARY_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(GLIB REQUIRED)
find_package(MHD REQUIRED)
add_subdirectory (librerie)
set (EXTRA_LIBS ${EXTRA_LIBS} librerie)
include_directories (${GLib_INCLUDE_DIRS} ${EXTRA_LIBS})
# add the executable
add_executable(TestPL main.c)
target_link_libraries (TestPL ${GLib_LIBRARY} ${MHD_LIBRARY} ${EXTRA_LIBS} m)
This is CMakeLists in librerie directory:
find_package(GLIB REQUIRED)
find_package(MHD REQUIRED)
include_directories (${GLib_INCLUDE_DIRS} ${EXTRA_LIBS})
add_library (librerie cJSON.c config.c generic.c server_web.c funzioni_thread.c)
target_link_libraries (librerie ${GLib_LIBRARY} ${MHD_LIBRARY})
What am I doing wrong?
You call twice
find_package(GLIB REQUIRED)
First time it is called from top-level CMakeLists.txt and defines glib-2.0 target. Second time it is called from librerie/CMakeLists.txt and attempt to create glib-2.0 again. That is why you see that error message: the target is already defined in this scope.
Possible workaround is to step into library subdirectory first, and only then call find_package() in top-level CMakeLists.txt:
add_subdirectory (librerie)
find_package(GLIB REQUIRED)
find_package(MHD REQUIRED)
Because IMPORTED targets has local visibility, glib-2.0 target defined by find_package(GLIB) call from subdirectory librerie/ will not be visible after returning from this subdirectory. So the second call from top-level directory will succeed.

Problems when linking a PETSc program when using CMake

I'm on Ubuntu 13.04 64-bit and I'm attempting to build a "Hello world" program in PETSc using CMake.
I have the following program solve1.c (loosely based on ex1.c from the PETSc examples), which solves a simple system of linear equations:
/* minimal example of solving a linear equation system in petsc
(in serial) */
/* based on http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex1.c.html */
#include <petscksp.h>
#define SIZE 3
int main(int argc,char **argv) {
Vec x,b; /* approx solution, rhs */
Mat A; /* linear system matrix */
KSP ksp; /* linear solver context */
PC pc; /* preconditioner context */
int size;
PetscInt col[3],i;
PetscScalar temp[SIZE];
PetscInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL);
MPI_Comm_size(PETSC_COMM_WORLD,&size);
if(size!=1) PetscPrintf(PETSC_COMM_WORLD,"warning, %d threads\n",size);
/* create vectors */
VecCreate(PETSC_COMM_WORLD,&x);
VecSetSizes(x,PETSC_DECIDE,SIZE);
VecSetFromOptions(x);
VecDuplicate(x,&b);
temp[0]=14.5; temp[1]=54; temp[2]=0.423;
for(i=0;i<3;i++) VecSetValues(b,1,&i,&temp[i],INSERT_VALUES);
/* need to assemble after setting values! do necessary
message passing etc to propagate matrix to all ranks */
VecAssemblyBegin(b);
VecAssemblyEnd(b);
/* create matrix */
MatCreate(PETSC_COMM_WORLD,&A);
MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,SIZE,SIZE);
MatSetFromOptions(A);
MatSetUp(A);
temp[0]=1; temp[1]=1; temp[2]=1;
col[0]=0; col[1]=1; col[2]=2;
for(i=0;i<3;i++) {
MatSetValues(A,1,&i,3,col,temp,INSERT_VALUES);
temp[i]=0;
}
/* need to assemble matrix for the same reasons as above */
MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
/* linear solver context! */
KSPCreate(PETSC_COMM_WORLD,&ksp);
/* operator is A matrix, also set matrix for preconditioning here */
KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);
/* get pc context from ksp context */
KSPGetPC(ksp,&pc);
/* set preconditioner type */
PCSetType(pc,PCJACOBI);
KSPSetTolerances(ksp,1e-6,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);
KSPSetFromOptions(ksp);
/* solve! */
KSPSolve(ksp,b,x);
/* display everything */
MatView(A,PETSC_VIEWER_STDOUT_WORLD);
VecView(b,PETSC_VIEWER_STDOUT_WORLD);
VecView(x,PETSC_VIEWER_STDOUT_WORLD);
KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);
/* get rid of everything */
KSPDestroy(&ksp);
VecDestroy(&x);
VecDestroy(&b);
PetscFinalize();
return 0;
}
This is my attempt at creating CMakeLists.txt (based on various PETSc tutorials and projects found on the web):
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(helloworld)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules")
FIND_PACKAGE(PETSc REQUIRED)
INCLUDE_DIRECTORIES(${PETSC_INCLUDES})
ADD_DEFINITIONS(${PETSC_DEFINITIONS})
ADD_EXECUTABLE(solve1 solve1.c)
TARGET_LINK_LIBRARIES(solve1 ${PETSC_LIBRARIES})
In addition, I have a directory cmake-modules where I have the files CorrectWindowsPaths.cmake, FindPETSc.cmake, FindPackageMultipass.cmake and ResolveCompilerPaths.cmake which I have gotten from https://github.com/jedbrown/cmake-modules (as recommended by the PETSc FAQ).
I'm building the project in this way (initially standing in the root directory of my project, which is /home/ruben/hello):
mkdir build
cd build
cmake ..
make
Unfortunately, the make commands fails with a linker error. Here's the output from CMake (which looks good):
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- 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
-- petsc_lib_dir /home/ruben/petsc-3.4.2/arch-linux2-c-debug/lib
-- Recognized PETSc install with single library for all packages
-- Performing Test MULTIPASS_TEST_1_petsc_works_minimal
-- Performing Test MULTIPASS_TEST_1_petsc_works_minimal - Success
-- Minimal PETSc includes and libraries work. This probably means we are building with shared libs.
-- Found PETSc: /home/ruben/petsc-3.4.2/arch-linux2-c-debug/include;/home/ruben/petsc-3.4.2/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ruben/hello/build
Here's the output from make VERBOSE=1 (which is not good):
/usr/bin/cmake -H/home/ruben/hello -B/home/ruben/hello/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/ruben/hello/build/CMakeFiles /home/ruben/hello/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/ruben/hello/build'
make -f CMakeFiles/solve1.dir/build.make CMakeFiles/solve1.dir/depend
make[2]: Entering directory `/home/ruben/hello/build'
cd /home/ruben/hello/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/ruben/hello /home/ruben/hello /home/ruben/hello/build /home/ruben/hello/build /home/ruben/hello/build/CMakeFiles/solve1.dir/DependInfo.cmake --color=
Dependee "/home/ruben/hello/build/CMakeFiles/solve1.dir/DependInfo.cmake" is newer than depender "/home/ruben/hello/build/CMakeFiles/solve1.dir/depend.internal".
Dependee "/home/ruben/hello/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/ruben/hello/build/CMakeFiles/solve1.dir/depend.internal".
Scanning dependencies of target solve1
make[2]: Leaving directory `/home/ruben/hello/build'
make -f CMakeFiles/solve1.dir/build.make CMakeFiles/solve1.dir/build
make[2]: Entering directory `/home/ruben/hello/build'
/usr/bin/cmake -E cmake_progress_report /home/ruben/hello/build/CMakeFiles 1
[100%] Building C object CMakeFiles/solve1.dir/solve1.c.o
/usr/bin/cc -D__INSDIR__="" -I/home/ruben/petsc-3.4.2/arch-linux2-c-debug/include -I/home/ruben/petsc-3.4.2/include -o CMakeFiles/solve1.dir/solve1.c.o -c /home/ruben/hello/solve1.c
Linking C executable solve1
/usr/bin/cmake -E cmake_link_script CMakeFiles/solve1.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/solve1.dir/solve1.c.o -o solve1 -rdynamic /home/ruben/petsc-3.4.2/arch-linux2-c-debug/lib/libpetsc.so -Wl,-rpath,/home/ruben/petsc-3.4.2/arch-linux2-c-debug/lib
/usr/bin/ld: CMakeFiles/solve1.dir/solve1.c.o: undefined reference to symbol 'MPI_Comm_size'
/usr/bin/ld: note: 'MPI_Comm_size' is defined in DSO /home/ruben/petsc-3.4.2/arch-linux2-c-debug/lib/libmpich.so.10 so try adding it to the linker command line
/home/ruben/petsc-3.4.2/arch-linux2-c-debug/lib/libmpich.so.10: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [solve1] Error 1
make[2]: Leaving directory `/home/ruben/hello/build'
make[1]: *** [CMakeFiles/solve1.dir/all] Error 2
make[1]: Leaving directory `/home/ruben/hello/build'
make: *** [all] Error 2
The PETSc FAQ recommends looking at CMakeLists.txt from the Dohp project. Unfortunately, I found this CMake file to be difficult to understand (Dohp is not a particularly small example and it has additional dependencies other than PETSc) and I have not been able to make use of this file to fix my linker error.
My question: What is wrong with my CMakeLists.txt and how can I fix it? (Or, in the case that my CMake file is correct: What other mistake(s) have I done?)
Some additional information: I'm using PETSc 3.4.2 (installed in /home/ruben/petsc-3.4.2/, installed with MPI which I want to use), CMake 2.8.10.1, gcc 4.8.1, all on Ubuntu 13.04 64-bit on an Intel i7-3930k. I am able to compile and run the above program using a regular makefile, and I'm able to compile and run all PETSc examples I've tried so far.
The cause of the error is that the wrong compiler is invoked. From the make output (with VERBOSE on), it can be seen that /usr/bin/cc is called instead of an MPI capable compiler (mpicc)
A way to fix this is to tell CMake which compiler to use. The updated build instructions are as follows:
mkdir build
cd build
cmake -D CMAKE_C_COMPILER=${PETSC_DIR}/${PETSC_ARCH}/bin/mpicc ..
make
(If this was a C++ project, the correct CMake variable to set would be CMAKE_CXX_COMPILER.)
For subsequent builds in the same build tree, the cmake line above can be replaced with cmake .., as the compiler path is now stored in the config files for this build tree.

building portmidi

I've been tring to build portmidi on OSX 10.8.2
http://sourceforge.net/apps/trac/portmedia/wiki/Installing%20portmidi%20on%20Mac
Anyway, the README tells me to first use the command:
make -f pm_mac/Makefile.osx
but bash returns the following error message:
[~/Desktop/portmedia/portmidi]
DanMoore -> make -f pm_mac/Makefile.osx
rm -f CMakeCache.txt
mkdir -p Release
cd Release; cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is Clang 4.0.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- 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 - failed
-- SYSROOT: /Developer/SDKs/MacOSX10.5.sdk
-- DEFAULT_DEBUG_FLAGS not nil: -g
-- SYSROOT: /Developer/SDKs/MacOSX10.5.sdk
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/DanMoore/Desktop/portmedia/portmidi/Release
cd Release; make
Scanning dependencies of target pmjni
[ 3%] Building C object pm_common/CMakeFiles/pmjni.dir/__/pm_mac/pmmacosxcm.c.o
llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/y4/p_kjk8692z73xy4nhwx6h_100000gn/T//cc73yejt.out
make[3]: *** [pm_common/CMakeFiles/pmjni.dir/__/pm_mac/pmmacosxcm.c.o] Error 255
make[2]: *** [pm_common/CMakeFiles/pmjni.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
I wasn't expecting an easy build, but these errors look foreign to me.
Can anyone explain whats going on??
I'm trying to render a library file for simple C programs. (.a or .la)
Thanks in advance to anyone who takes a look!!

Resources