• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Basicsof c make and git for a hello qt application
 

Basicsof c make and git for a hello qt application

on

  • 750 views

These are the slides i have used for my talk in

These are the slides i have used for my talk in
http://ayana.pes.edu/speakers/

Statistics

Views

Total Views
750
Views on SlideShare
750
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
2

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Basicsof c make and git for a hello qt application Basicsof c make and git for a hello qt application Presentation Transcript

    • Basics of CMake and Git for a Hello Qt Application :Dinesh
    • Hello world#include <stdio.h>#include <stdlib.h>#include <math.h>int main (int argc, char *argv[]){ if (argc < 2) { printf("Usage: %s numbern",argv[0]); return 1; } double inputValue = atof(argv[1]); double outputValue = sqrt(inputValue); printf("The square root of %g is %gn", inputValue, outputValue); return 0;} /* How to Compile? --------------------------------------------------------------------------------------- $ gcc -c hello.c $ gcc -o hello hello.o -lm */
    • A little flashback...
    • Hello CMakeCMakeLists.txt:cmake_minimum_required (VERSION 2.6)project (Hello)add_executable(Hello hello.c)target_link_libraries(Hello m)--------------------------------------------------------------------------------------------------------# What to do? :$ mkdir build$ cd build$ cmake ..$ make
    • Other nice little things with CMake? IF (UNIX) CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/libvsxu.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libvsxu.pc @ONLY) INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/libvsxu.pc DESTINATION ${VSXU_INSTALL_LIB_DIR}/pkgconfig) ENDIF (UNIX) ##################### find_package( OpenCV ) if(OpenCV_FOUND) add_subdirectory(src/video.camera) endif(OpenCV_FOUND) ######################################## #For the make install... install (TARGETS MathFunctions DESTINATION bin) install (FILES MathFunctions.h DESTINATION include)
    • Hello Qt#include <QApplication>#include <QLabel> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("Hello Qt!"); label->show(); return app.exec(); }/* How to Compile?---------------------------------------------------------------------------------------$ g++ -I/usr/include/qt4/QtGui -I/usr/include/qt4/ -c helloqt.cpp$ g++ -o helloqt helloqt.o -L/usr/lib/i386-linux-gnu -lQtCore -lQtGui -lpthread*/
    • CMake to the rescue...cmake_minimum_required (VERSION 2.6)project (Hello)#Find our needed librariesfind_package(Qt4 REQUIRED)#Tell our compiler to get the headers from the found headersinclude(${QT_USE_FILE})#Tell the compiler how to compile our codeadd_executable(HelloQt helloqt.cpp)#Tell the compiler to link our code with the found librariestarget_link_libraries(HelloQt ${QT_LIBRARIES})
    • And other Qt Modules?QT_DONT_USE_QTCOREQT_DONT_USE_QTGUIQT_USE_QT3SUPPORTQT_USE_QTASSISTANTQT_USE_QAXCONTAINERQT_USE_QAXSERVERQT_USE_QTDESIGNERQT_USE_QTMOTIFQT_USE_QTMAINQT_USE_QTNETWORKQT_USE_QTNSPLUGINQT_USE_QTOPENGLQT_USE_QTSQLQT_USE_QTXMLQT_USE_QTSVGQT_USE_QTTESTQT_USE_QTUITOOLSQT_USE_QTDBUSQT_USE_QTSCRIPTQT_USE_QTASSISTANTCLIENTQT_USE_QTHELPQT_USE_QTWEBKITQT_USE_QTXMLPATTERNSQT_USE_PHONON# set (QT_USE_QTOPENGL TRUE)
    • But moc?SET(foo_MOC_HDRS Class1.h Class2.h Class3.h)# After this call, foo_MOC_SRCS = moc_Class1.cxx moc_Class2.cxx moc_Class3.cxx.QT4_WRAP_CPP(foo_MOC_SRCS ${foo_MOC_HDRS})ADD_EXECUTABLE(foo ${foo_SRCS} ${foo_MOC_SRCS})
    • and uic and rcc?SET(qtproject_UIS main_window.ui)SET(QtApp_RCCS application.qrc)QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS})QT4_WRAP_UI(qtproject_UIS_H ${qtproject_UIS})# Dont forget to include output directory, otherwise the UI file wont be wrapped!include_directories(${CMAKE_CURRENT_BINARY_DIR})#Now add these generated files to the ADD_EXECUTABLE step# If this is NOT done, then the ui_*.h files will not be generatedadd_executable( qtproject ${qtproject_SRCS} ${qtproject_UIS_H} ${QtApp_RCC_SRCS})
    • Hello GitBecause this is just too ridiculous!
    • The Git object model...
    • So... git?#Creating an empty repository$git init# Viewing changes$ git diff$ git status# Asking git to store files$ git add hello.c# Finally Saving a state$ git commit -m "Commit Message"# Listing all branches$ git branch#Creating a Local branch$ git branch mywork#Switching to a local branch$ git checkout mywork# deleting a branch$ git branch -d mywork
    • and now... git merge$ git checkout mywork$ git merge origin
    • and... git rebase$ git checkout mywork$ git rebase origin
    • Useful resources:● http://www.cmake.org/cmake/help/cmake_tutorial.html● http://qtnode.net/wiki/Qt4_with_cmake● http://qt.nokia.com/learning/education/course-materials● http://book.git-scm.com/3_distributed_workflows.html● http://www.tenouk.com/ModuleW.html