Wednesday, August 24, 2016

How to install Objective C 2.0 and GNUstep under Windows SubSystem for Linux - Bash Shell

Install Objective C 2.0 and GNUstep under Windows 10 bash shell
Follow the steps below (make sure the steps are followed in order, that is build libobjc2 before GNUstep) to install required packages and build scripts

bash    Select all
sudo apt-get update sudo apt-get install build-essential libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev gobjc libxml2-dev libjpeg-dev libtiff-dev libpng12-dev libcups2-dev libfreetype6-dev libcairo2-dev libxt-dev libgl1-mesa-dev sudo apt-get install clang-3.6 cmake git sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100 cd $HOME git clone --depth=1 https://github.com/gnustep/libobjc2 cd libobjc2 rm -fr Build mkdir Build && cd Build cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLIB_INSTALL_PATH=/usr/local/lib make sudo make install cd $HOME wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.6.7.tar.gz tar xvf gnustep-make*.tar.gz cd gnustep-make* CC=clang CXX=clang++ ./configure --prefix=/usr/local make sudo make install cd $HOME wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-base-1.24.8.tar.gz tar xvf gnustep-base*.tar.gz cd gnustep-base* CC=clang CXX=clang++ ./configure --prefix=/usr/local make sudo make install sudo ldconfig -v # no gnustep-gui installation here. sudo apt-get install libdispatch-dev # testing cd $HOME cat > blocktest.m << EOF #include <stdio.h> int main() { void (^hello)(void) = ^(void) { printf("Hello, block!\n"); }; hello(); return 0; } EOF clang `gnustep-config --objc-flags` -fblocks -o blocktest -x objective-c blocktest.m `gnustep-config --base-libs` ./blocktest cat > main.m << EOF // // main.m // Just a little test case for Objective-C 2.0 on Ubuntu // #import <Foundation/Foundation.h> #import <dispatch/dispatch.h> int main(int argc, const char * argv[]) { @autoreleasepool { int multiplier = 7; int (^myBlock)(int) = ^(int num) { return num * multiplier; }; NSLog(@"%d", myBlock(3)); dispatch_queue_t queue = dispatch_queue_create(NULL, NULL); dispatch_sync(queue, ^{ printf("Hello, world from a dispatch queue!\n"); }); dispatch_release(queue); } @autoreleasepool { NSLog(@"Wow it works!"); } return 0; } EOF # command line for locale generation sudo locale-gen en_US.UTF-8 # command line to reset timezone if not yet configured sudo dpkg-reconfigure tzdata clang `gnustep-config --objc-flags` -fblocks -o main -x objective-c main.m `gnustep-config --base-libs` -ldispatch ./main # to compile objective c++, you would need extra parameters and use clang++ clang++ -std=c++11 -stdlib=libc++ -x objective-c++ clang++ -std=c++11 -stdlib=libstdc++ -x objective-c++



GNUstep documentation is here -> http://www.gnustep.org/developers/documentation.html


No comments: