Showing posts with label cmake. Show all posts
Showing posts with label cmake. Show all posts

University of Illinois CS_400: Object-Oriented Data Structures in C++

I decided to take a refresher on my C++ skills.

The University of Illinois (U-C) had a class on Coursera: "Object-Oriented Data Structures in C++"

https://www.coursera.org/learn/cs-fundamentals-1

The funny thing is, that I actually learned C/C++ at the University of Illinois (UIC), just over 20 years ago!


Getting the instructor's code:
Uki@iMac 18:38 Coursera_OO_data_structures_Cpp $ cd ..
Uki@iMac 18:38 _REPOS $ git clone https://github.com/wadefagen/coursera.git coursera-cs400
Cloning into 'coursera-cs400'...


Setting up macOS for C++

I am following these instructions:

Install Apple XCode


$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates


IMPORTANT, if you get Xcode errors when running the make command, execute this command:

sudo xcode-select --reset




by the way, I cannot get XCode IDE because my 2012 iMac is outdated and does not support higher macOS:





Getting BREW


$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


the above will take quite a few minutes.

Once BREW is installed, install the following:

brew install ghostscript
brew link --overwrite freetype
 
brew install imagemagick

brew link --overwrite libtool

 

brew install graphviz 
brew install cmake


brew edit valgrind



This will open your default code editor. In the opened file, change the URL in the head section from https://sourceware.org/git/valgrind.git 
to 
git://sourceware.org/git/valgrind.git 
and run the following:

brew update brew install --HEAD valgrind


Test MAKE



$ cd /Volumes/GoogleDrive/My\ Drive/_REPOS/coursera_wadefagen/cpp-std
cpp-std $ make




xcrun: error: active developer path ("/Volumes/SSD500GB/Applications/Xcode.app/Contents/Developer") does not exist
...





Uki@iMac 02:03 cpp-std $ sudo xcode-select --reset
Password:

Uki@iMac 02:07 cpp-std $ make
g++ -std=c++14 -O0 -pedantic -Wall -Wfatal-errors -Wextra -MMD -MP -g -c main.cpp -o .objs/main.o
g++ -std=c++14 -O0 -pedantic -Wall -Wfatal-errors -Wextra -MMD -MP -g -c Cube.cpp -o .objs/Cube.o
g++ .objs/main.o .objs/Cube.o -std=c++14 -o main
g++ cout.cpp -std=c++14 -o cout
g++ cout2.cpp -std=c++14 -o cout2
Uki@iMac 02:08 cpp-std $ open .



Uki@iMac  02:10 cpp-std $ ls -alt

total 96

drwx------@ 1 Uki  staff    16K Aug 12 02:10 ../

drwx------@ 1 Uki  staff    16K Aug 12 02:08 ./

-rwx------@ 1 Uki  staff    54K Aug 12 02:08 cout*

-rwx------@ 1 Uki  staff    54K Aug 12 02:08 cout2*

-rwx------@ 1 Uki  staff    61K Aug 12 02:08 main*

drwx------@ 1 Uki  staff    16K Aug 12 02:08 .objs/

-rwx------@ 1 Uki  staff    26B Aug 10 18:37 .gitignore*

-rwx------@ 1 Uki  staff   368B Aug 10 18:37 Cube.cpp*

-rwx------@ 1 Uki  staff   312B Aug 10 18:37 Cube.h*

-rwx------@ 1 Uki  staff   228B Aug 10 18:37 Makefile*

-rwx------@ 1 Uki  staff   209B Aug 10 18:37 cout.cpp*

-rwx------@ 1 Uki  staff   248B Aug 10 18:37 cout2.cpp*

-rwx------@ 1 Uki  staff   395B Aug 10 18:37 main.cpp*

Uki@iMac  02:14 cpp-std $ ./main

Volume: 13.824

Surface Area: 34.56





Week 2




2.1 Stack Memory and Pointers
https://www.coursera.org/learn/cs-fundamentals-1/lecture/Iccq3/2-1-stack-memory-and-pointers


I got to use Microsoft Code and Terminal properly




How to make the compiled files execute in the command line?


If you get a similar error, you might have to change the mode to execute the file..

zsh: permission denied: ./addressOf

cpp-memory % chmod +x addressOf
cpp-memory % ./addressOf
Value: 7
Address: 0x7ff7b9eef878



















As an Amazon Associate I earn from qualifying purchases.

Ubuntu build C++ project ND313

Install C++ Compiler on Ubuntu (command line)

-- The CXX compiler identification is unknown
No CMAKE_CXX_COMPILER could be found.


$ sudo apt-get update && sudo apt-get install build-essentialOR$ sudo apt install cmake

Install Point Cloud Library (PCL)

The Point Cloud Library (or PCL) is a large scale, open project for point cloud processing.
The PCL framework contains numerous state-of-the art algorithms including filtering, feature estimation, surface reconstruction, registration, model fitting and segmentation.
PCL is released under the terms of the BSD license and is open-source software. It is free for commercial and research use. We are financially supported by Willow Garage, NVidia, and Google.

$ sudo apt install libpcl-dev$ sudo apt-get update




Prepare Workspace for ND313

GITHUB:
$ pwd
/media/uki/REPO/SFND313_Lidar_Obstacle_Detection/
$ mkdir build$ cd buildSFND313_Lidar_Obstacle_Detection/build$ cmake ../CMakeLists.txt 



CMake Error: The current CMakeCache.txt directory /media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeCache.txt is different than the directory /Volumes/DATA/_Drive/_REPOS/SFND_Lidar_Obstacle_Detection where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txtCMake Error: The source "/media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeLists.txt" does not match the source "/Volumes/DATA/_Drive/_REPOS/SFND_Lidar_Obstacle_Detection/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
$ rm ../CMakeCache.txt $ cmake ../CMakeLists.txt

-- Configuring done-- Generating done-- Build files have been written to: /media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection

$ cd ..$ make
make: *** No targets specified and no makefile found.  Stop.
$ cd ..$ pwd/media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection$ make

[100%] Linking CXX executable environment[100%] Built target environment> ls -alt environment -rwxr-xr-x 1 uki uki 506464 Jul 15 07:34 environment
$ ./environment starting enviroment







As an Amazon Associate I earn from qualifying purchases.

Ubuntu build C++ project ND313

Install C++ Compiler on Ubuntu (command line)

-- The CXX compiler identification is unknown
No CMAKE_CXX_COMPILER could be found.


$ sudo apt-get update && sudo apt-get install build-essentialOR$ sudo apt install cmake

Install Point Cloud Library (PCL)

The Point Cloud Library (or PCL) is a large scale, open project for point cloud processing.
The PCL framework contains numerous state-of-the art algorithms including filtering, feature estimation, surface reconstruction, registration, model fitting and segmentation.
PCL is released under the terms of the BSD license and is open-source software. It is free for commercial and research use. We are financially supported by Willow Garage, NVidia, and Google.

$ sudo apt install libpcl-dev$ sudo apt-get update




Prepare Workspace for ND313

GITHUB:
$ pwd
/media/uki/REPO/SFND313_Lidar_Obstacle_Detection/
$ mkdir build$ cd buildSFND313_Lidar_Obstacle_Detection/build$ cmake ../CMakeLists.txt 



CMake Error: The current CMakeCache.txt directory /media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeCache.txt is different than the directory /Volumes/DATA/_Drive/_REPOS/SFND_Lidar_Obstacle_Detection where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txtCMake Error: The source "/media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeLists.txt" does not match the source "/Volumes/DATA/_Drive/_REPOS/SFND_Lidar_Obstacle_Detection/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
$ rm ../CMakeCache.txt $ cmake ../CMakeLists.txt

-- Configuring done-- Generating done-- Build files have been written to: /media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection

$ cd ..$ make
make: *** No targets specified and no makefile found.  Stop.
$ cd ..$ pwd/media/psf/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection$ make

[100%] Linking CXX executable environment[100%] Built target environment> ls -alt environment -rwxr-xr-x 1 uki uki 506464 Jul 15 07:34 environment
$ ./environment starting enviroment







As an Amazon Associate I earn from qualifying purchases.

apt quotation..