Use cmake to compile the GTK program: gssdp

Source: Internet
Author: User

Reprinted please indicate the source and the author contact: http://blog.csdn.net/mimepp
Contact information: Yu Tao <yut616 at Sohu dot com>

Use cmake to compile the GTK program: gssdp

Use cmake to compile the GTK program. Here we will use the gssdp example in gupnp to explain it.

1. gssdp code
SVN Co http://svn.o-hand.com/repos/gupnp/trunk/gssdp gssdp

2. Install cmake
Apt-Get install cmake

3rd compile cmakelists.txt

project (GSSDP)include_directories (/usr/include/glib-2.0 /usr/lib/glib-2.0/include/usr/include/gtk-2.0 /usr/lib/gtk-2.0/include /usr/include/atk-1.0/usr/include/cairo /usr/include/pango-1.0 /usr/include/freetype2/usr/include/libpng12 /usr/include/pixman-1 ./ /usr/local/include/gssdp-1.0/usr/include/libglade-2.0 /usr/include/libsoup-2.4)aux_source_directory (libgssdp LIB_FILE)add_library (gssdp SHARED ${LIB_FILE})set (TOOL_FILE tools/gssdp-device-sniffer.c)add_executable (gssdp-device-sniffer ${TOOL_FILE} ${LIB_FILE} )target_link_libraries (gssdp-device-sniffer gssdp soup-2.4 gtk-x11-2.0gdk-x11-2.0 atk-1.0 gdk_pixbuf-2.0 m pangocairo-1.0 pango-1.0 cairogobject-2.0 gmodule-2.0 dl glib-2.0 glade-2.0)

4. Explanation
The include content and Connection Library content can be obtained using PKG-config -- cflags GTK +-2.0 and PKG-config -- libs GTK +-2.0, and drop the "-I", "-l" in front of them and add them to the corresponding cmakelists.txt.

5. Compile
Create a build directory under the gssdp directory

gssdp/build# cmake ..-- Check for working C compiler: /usr/bin/gcc-- Check for working C compiler: /usr/bin/gcc -- works-- Check size of void*-- Check size of void* - done-- Check for working CXX compiler: /usr/bin/c++-- Check for working CXX compiler: /usr/bin/c++ -- works-- Configuring done-- Generating done-- Build files have been written to: /home/yutao/study/gupnp_svn/gssdp/buildgssdp/build# makeScanning dependencies of target gssdp[  7%] Building C object CMakeFiles/gssdp.dir/libgssdp/gssdp-socket-source.o[ 15%] Building C object CMakeFiles/gssdp.dir/libgssdp/gssdp-marshal.o[ 23%] Building C object CMakeFiles/gssdp.dir/libgssdp/gssdp-error.o[ 30%] Building C objectCMakeFiles/gssdp.dir/libgssdp/gssdp-resource-browser.o[ 38%] Building C object CMakeFiles/gssdp.dir/libgssdp/gssdp-resource-group.o[ 46%] Building C object CMakeFiles/gssdp.dir/libgssdp/gssdp-client.oLinking C shared library libgssdp.so[ 46%] Built target gssdpScanning dependencies of target gssdp-device-sniffer[ 53%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/tools/gssdp-device-sniffer.o[ 61%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/libgssdp/gssdp-socket-source.o[ 69%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/libgssdp/gssdp-marshal.o[ 76%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/libgssdp/gssdp-error.o[ 84%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/libgssdp/gssdp-resource-browser.o[ 92%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/libgssdp/gssdp-resource-group.o[100%] Building C objectCMakeFiles/gssdp-device-sniffer.dir/libgssdp/gssdp-client.oLinking C executable gssdp-device-sniffer[100%] Built target gssdp-device-sniffer

6. Run
# CD ../tools
# ../Build/gssdp-device-sniffer

7. Link information
# LDD ../build/gssdp-device-sniffer
Linux-gate.so.1 => (0xb7f80000)
Libgssdp. So =>/home/yutao/study/gupnp_svn/gssdp/build/libgssdp. So (0xb7f74000)
That is, the link content is self-compiled libgssdp. So.

8. Compile directory information

build# ls CMakeCache.txt  CMakeFiles  cmake_install.cmake  gssdp-device-sniffer  libgssdp.so  Makefile

9. libraries that may be required during compilation
Apt-Get install libsoup2.4-Dev

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.