In this lab you will practice working with QT, RGB colors, and png images using the RGBImage class.
cd ~/cs40/code git checkout masterif there are any complaints about unsaved changes, use git add and git commit to save changes in the working branch, or git checkout -- [file] to discard changes. You may also want to read about git stash
git pull git checkout working git merge master git pushTo practice creating branches and to get over the fear of branching, create a new project1 branch, push it to your private remote, and track it.
$ git checkout -b project1 Switched to a new branch 'project1' $ git push -u private project1 To gitrepos:cs40_username * [new branch] project1 -> project1 Branch project1 set up to track remote branch project1 from private.If you are sharing code with a partner, or just confused about git in general, I have updated the Git Documentation on the CS40 wiki.
cd ~/cs40/code/build make clean; rm CMakeCache.txt cmake .. make -j8Note, if you have a separate build folder for QT, you may want to cd into that directory and run the make clean and rm CMakeCache.txt there too. Alternatively, the nuclear option is just to remove your build directory entirely and rebuilding, e.g.,
cd ~/cs40/code rm -rf build mkdir build cd build cmake .. make -j8
cd ~/cs40/code/projects/01 cp ../../w01-intro/pngtest/png* ./ cp ../../w01-intro/pngtest/rgb* ./Next, modify your CMakeLists.txt in your projects/01 folder to add the RGB sources to the build, and create the rgb library. You can do this mostly by copying relevant sections from w01-into/pngtest/CMakeLists.txt
include_directories(PNG_INCLUDE_DIRS) set(RGBHDRS rgbColor.h rgbImage.h png_reader.h png_writer.h) set(RGBSRC rgbImage.cpp png_reader.cpp png_writer.cpp) add_library(proj1_rgb ${RGBHDRS} ${RGBSRC})Note: in the last line above, I changed the library name from rgb to proj1_rgb. CMake gets grumpy if there are multiple libraries or executable targets with the same name, so verify that the first argument in any add_library or add_executable has a unique name. The four lines above can go anywhere in the CMakeLists.txt file before the add_executable command for colorTest. Finally, modify the colorTest targets to compile and link against the PNG and RGB libraries
ADD_EXECUTABLE(colorTest ${SRC} ${MYQTFILES} ${RGBSRC}) TARGET_LINK_LIBRARIES(colorTest proj1_rgb ${PNG_LIBRARIES} ${EXT_LIBS} )Go into your build directory and run make. If all went well, CMake should compile and link your library. You should see lines like the following
Scanning dependencies of target proj1_rgb Building... Linking CXX static library libproj1_rgb.a Generating... Scanning dependencies of target colorTest Building... Linking CXX executable colorTest [100%] Built target colorTest
$ git status # On branch project1 # Changes not staged for commit: # (use "git addAdd the png* and rgb* files to version control, and commit..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: CMakeLists.txt # # Untracked files: # (use "git add ..." to include in what will be committed) # # ../../CMakeLists.txt.user # png_reader.cpp # png_reader.h # png_writer.cpp # png_writer.h # rgbColor.h # rgbImage.cpp # rgbImage.h
git add png_* rgb* CMakeLists.txt git commit -a -m "Added rgb library" git pushThe -m option on git commit allows you to type the log message directly only the command line. If you leave it off, git will open an editor for you to type the message.