How to execute a graphics C++ program on macOS Sierra - c++

I'm working on a project for my graphics class, which the professor provided the base code. He coded it up with our lab computers (Ubuntu 16.04 LTS) in mind. I wanted to work on this project from my own computer at home, but I cant seem to figure out how to run it.
I do know the Makefile he gave us is specific to the lab computers, once again, but I'm not skilled enough to figure out how to alter it for a macOS.
Makefile
CPP = g++ -std=c++11
INC = -I../glslutil -I../mvcutil -I.
C_FLAGS = -fPIC -g -c -DGL_GLEXT_PROTOTYPES $(INC)
LINK = g++ -fPIC -g
LOCAL_UTIL_LIBRARIES = ../lib/libglsl.so
GL_LIB_LOC = -L/usr/lib/nvidia-375
GL_LIBRARIES = $(GL_LIB_LOC) -lglfw -lGLU -lGL
OBJS = project1.o ModelView.o Controller.o GLFWController.o
project1: $(OBJS) $(LOCAL_UTIL_LIBRARIES)
$(LINK) -o project1 $(OBJS) $(LOCAL_UTIL_LIBRARIES) $(GL_LIBRARIES)
../lib/libglsl.so: ../glslutil/ShaderIF.h ../glslutil/ShaderIF.c++
(cd ../glslutil; make)
project1.o: project1.c++
$(CPP) $(C_FLAGS) project1.c++
ModelView.o: ModelView.h ModelView.c++
$(CPP) $(C_FLAGS) ModelView.c++
Controller.o: ../mvcutil/Controller.h ../mvcutil/Controller.c++
$(CPP) $(C_FLAGS) ../mvcutil/Controller.c++
GLFWController.o: ../mvcutil/GLFWController.h
../mvcutil/GLFWController.c++
$(CPP) $(C_FLAGS) ../mvcutil/GLFWController.c++
Although, I'm not even sure that's the problem. I just want to see the graphics on my laptop! :) I appreciate any help!
Overall, I would like to see something similar to this on my mac.
My errors when compiling on my mac.

I, personally, wouldn't go that way, unless you really have to.
I'd go a different path:
download VirtualBox from here: https://www.virtualbox.org/wiki/Downloads
download Ubuntu 16.04 LTS: http://releases.ubuntu.com/16.04/ubuntu-16.04.3-desktop-amd64.iso
ask your teacher what exact packages does he use for the class
install Ubuntu 16.04 inside VirtualBox
install all packages required by your teacher
use VirtualBox installation for this particular class
This way, you will save lots of time and effort.

I suspect this is going to be rather hard to do, and this is only a partial answer, so maybe some other kind folk will know how to do the other half, or 80% - not even sure how much I am missing.
The Makefile looks like it is using glslang and glfw and some Nvidia library. To get some of those packages on a Mac, you would need to:
install Xcode - start AppStore, find and download Xcode for free
install Command Line Tools with xcode-select --install in Terminal
install homebrew - goto Homebrew website
Then you could search for your packages with
brew search glfw
brew search glslang
Then you can find out what the packages are with:
brew info glfw
Sample Output
glfw: stable 3.2.1 (bottled), HEAD
Multi-platform library for OpenGL applications
http://www.glfw.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/glfw.rb
==> Dependencies
Build: cmake ✘
==> Options
--with-examples
Build examples
--with-test
Build test programs
--without-shared-library
Build static library only (defaults to building dylib only)
--HEAD
Install HEAD version
Then install it with:
brew install glfw
You will still probably have a load of problems and I cannot find the Nvidia stuff... maybe someone else can add more help.

Related

How to uninstall mod_wsgi when installed with make?

I have installed mod_wsgi on Ubuntu 14.04 as described in their documentation. While I don't get any errors from Apache or anything my Django setup does not work (no idea why exactly) so I would like to start over and use libapache2-mod-wsgi.
However, I don't know how to uninstall mod_wsgi. This answer to a more general question on the subject advises trying make uninstall which does not work in this case.
make -n install gives me the following output:
/usr/bin/apxs2 -c -I/usr/include/python2.7 -DNDEBUG -D_FORTIFY_SOURCE=2 -Wc,-g -Wc,-O2 src/server/mod_wsgi.c src/server/wsgi_*.c -L/usr/lib -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm
/usr/bin/apxs2 -i -S LIBEXECDIR=/usr/lib/apache2/modules -n 'mod_wsgi' src/server/mod_wsgi.la
What exactly do I have to do to uninstall this?
Thanks!
Edit: I'm using mod_wsgi-4.5.3.
Remove any configuration you added to Apache configuration files and also run:
sudo rm /usr/lib/apache2/modules/mod_wsgi.so
I would strongly recommend against using the system provided mod_wsgi package as it is generally out of date by many many versions and is also thus not supported. You are better off using the latest from source code and trying to work out what the problem is, exact details of which you haven't posted.

Missing jpeglib.h when building pygame in Cygwin

I'm trying to install pygame with cygwin with the step by step below
http://msdl.cs.mcgill.ca/people/tfeng/svmsccdoc/node49.html
Things are going fine until the last part when I'm running theses 3 lines
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
export CPATH=/usr/local/include/SDL:$CPATH
python setup.py install build
I have this issue
gcc -fno-strict-aliasing -ggdb -O2 -pipe -Wimplicit-function-declaration - fdebug-prefix-map=/usr/src/ports/python/python-2.7.8-1.i686/build=/usr/src/debug/python-2.7.8-1 -fdebug-prefix-map=/usr/src/ports/python/python-2.7.8-1.i686/src/Python-2.7.8=/usr/src/debug/python-2.7.8-1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/NEED_INC_PATH_FIX -I/usr/include/python2.7 -c src/imageext.c -o build/temp.cygwin-1.7.33-i686-2.7/src/imageext.o
src/imageext.c:35:21: erreur fatale: jpeglib.h : No such file or directory
#include <jpeglib.h>
As you can see, the file jpeglib.h is missing
I tried to install the missing file by downloading the lib
apt-cyg install libjpeg62
But to no avail
Does anyone have seen that issue before? I browsed the net but found nothing relevant.
TIA
libjpeg62 doesn't have jpeglib.h. You need libjpeg-devel instead.
You can search for specific files in packages using the package search function on the Cygwin website.
You can download an already compiled version of PyGame and skip these steps. This can be painful sometimes.
Just check this page : http://www.lfd.uci.edu/~gohlke/pythonlibs/
or
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame , to get directly to PyGame section.
The Python extension unofficial windows binaries. You can find alot of Python libraries on this page.
Using theses packages will make you save a lot of time.

trouble installing old 2005 BOOST library

Gooday everyone
I'm fairly new to ubuntu C programing although I'm
rather experienced in C programing in windows.
I have recently come accross a number of codes written
in 2005 which I'm interested in learning how they work.
Those codes needs BOOST library to compile, however they won't
compile on the newest BOOST version present on my ubuntu 12.04.
I set the gcc compiler on lenient so that it ignores all those error
messages. The code did compile and ran afterwards.
However, when I used GDB debugger to watch how the program flows
I noticed that there are likely errors in the way the program runs
due to using a different BOOST version rather than it's original. Hence
I like to install the BOOST version corresponding to the code I downloaded.
To do that, I installed Ubuntu 5.04 and BOOST 1.33.0 which seemed to have been created in late 2005. I downloaded it
but I didnt found any detailed instruction on how to install it.
Only vague description on using BOOST jam, I played around with BOOST
jam for quite awhile without success.
And this old BOOST does not have installation commands like
"sudo apt-install boost-dev" style option
Thus I like to ask if anyone can give a easy to understand step by step instruction
on how to install the BOOST library downloaded from the above link.
like.....
step1: download boost jam from boost webpage
step2: unpack it in home/boost/ then type make configure
...and so on...
Big thanks for any useful info.
New Contents appended here
in response to the comments given
Hi, I went through the info given by your link and
managed to run the boost library examples given by your link.
That is, I can compile a single cpp file with the command
g++ -I boost_1_33_0 test.cpp -o test
(I'm keeping the boost library and the cpp file to be compiled in the
same folder)
However, the program package I'm interested in is build with make (not cmake).
I have some experience writting cmake files but not make files.
And I do not see any link to boost library command in the make file of the
program package. The readme file only has one sentence that says I
need to have boost installed without explaining what that meant.
I assume it means that either I have to build and do makeinstall the boost or
I could add some lines in the makefile for a link. I thought
maybe you can quickly point out whats missing in the makefile.
The readme file:
To compile, go into the moses directory and do 'make'. You'll need the
latest boost libraries. If compilation still fails for weird reasons,
you could try g++ with the -fpermissive (newer versions reject lots of
code that was ok with older ones). If you are going to be making
changes and recompiling frequently you'll probably want to disable -O3
in the makefile (I use templates liberally, so -O3 really speeds up
the code, but really slows down compilation).
And the makefile:
CC = g++
PROJ_NAME = moses
LINK_FLAGS = -Wall -Iutils/ -Itrees/ -Irewrite -I./ -Imodeling/ -Ifitness/ \
-Ialignment/ -Isim/ -Ilocal/ -O3
COMP_FLAGS = -Wall -Wno-sign-compare -Iutils/ -Itrees/ -Irewrite -I./ \
-Imodeling/ -Ifitness/ -Ialignment/ -Isim/ -Ilocal/ -O3
src := $(wildcard *.cc) $(wildcard utils/*.cc) $(wildcard trees/*.cc) $(wildcard modeling/*.cc) $(wildcard fitness/*.cc) $(wildcard alignment/*.cc) $(wildcard main/*.cc) $(wildcard rewrite/*.cc) $(wildcard sim/*.cc) $(wildcard local/*.cc)
obj := $(patsubst %.cc,%.o,$(src))
all: $(PROJ_NAME)
%.o: %.cc
$(CC) $(COMP_FLAGS) $< -c -o $#
$(PROJ_NAME): $(obj)
$(CC) $(LINK_FLAGS) $^ -o $(PROJ_NAME)
run:
$(PROJ_NAME)
clean:
find -regex ".*~\|.*\.o"|xargs rm -f
rm -f $(PROJ_NAME)
rm -f $(PROJ_NAME).exe*
depend:
makedepend -Y -- $(COMP_FLAGS) -- $(src)
utils/exceptions.o: utils/exceptions.h utils/utils.h
utils/io_util.o: utils/io_util.h utils/tree.h utils/basic_types.h
# ......lots more lines like that.........
I have an old instruction flying around here for Boost 1.34.1, which reads like this (project-specific stuff cut away):
unpack boost sources
cd into tools/jam/src
run ./build.sh to build bjam
cd into the main source directory
tools/jam/src/bin.linux/bjam threading=multi --layout=system --toolset=gcc --without-python variant=release --prefix=/usr/local install
The --without-python was necessary as the target system didn't have Python installed, which caused the build to fail messily.
Obviously you can / need to fiddle with the individual settings (like threading support, release vs. debug variant) to suit your needs, but it should be a good starting point.
If you need ICU support (for Boost.Regex and Boost.Locale), it gets more complicated...
Note that the build process has changed over the years; you shouldn't use the same procedure for more up-to-date boost versions. It's just what I used back then.
Edit:
As for the second part of your question, the Makefile doesn't need to refer to Boost explicitly if boost is installed in the standard system directories.
You do not have to state -I /usr/include for compilation as that is searched automatically; the same goes for -L /usr/lib during linkage.
The fact that the author of the Makefile copied the compiler flags into the linker flags verbatim doesn't really help intuitivity either... ;-)
If you have Boost in a custom directory (either the headers only, or by stating a custom directory in the --prefix option of my build instructions), you need to make the following modifications (look for "boost"):
LINK_FLAGS = -Wall -Iutils/ -Itrees/ -Irewrite -I./ -Imodeling/ -Ifitness/ \
-Ialignment/ -Isim/ -Ilocal/ -L /path/to/boost/libs -O3
COMP_FLAGS = -Wall -Wno-sign-compare -Iutils/ -Itrees/ -Irewrite -I./ \
-Imodeling/ -Ifitness/ -Ialignment/ -Isim/ -Ilocal/ \
-I /path/to/boost/includes -O3
That should do the trick. As the Makefile does not link any of the Boost binaries (e.g. -l boost_program_options or somesuch), it seems that it makes use of the Boost headers only, which would make the -L /path/to/boost/libs part (and, actually, the whole compilation step detailed above) superfluous. You should be able to get away with simply unpacking the sources and giving the header directory as additional include directory using -I /path/to/boost/headers.

Installing GTK2.0 on ubuntu?

so I've been working on a project on the university lab computers, and I want to be able to work on it at home on my laptop. My laptop runs ubuntu 11.10.
I used
sudo apt-get install gnome-core-devel build-essential libgtk2.0-dev libgtk2.0-doc devhelp
and that's all done.
Yet when I try compile my program, it gives me a bunch of
undefined reference to [all the gtk functions]
What's going on here? What am I doing wrong?
Program compiles fine on the lab computers.
makefile is here http://pastebin.com/H7Pi55NQ
The library arguments should now come after the files you want to link or they are ignored:
$(CC) -o mainout main.o draw.o floyds.o simpletools.o graph.o tads.o bucket.o $(LIBS)
Reason: The new version of GCC that comes in U11.10 passes the --as-needed switch for the linker by default. This means that if the library is not needed by anything that precedes it in the command line it is ignored. You can change this behaviour if you use the --no-as-needed linker switch.

Getting PyUblas sample working in Ubuntu

I would like to call C++ functions in python which return uBLAS vector/matrices.
There is a package to do this called PyUblas,
but am having trouble getting this to work in Ubuntu.
Can anyone walk me through the steps to get this sample to work?
Also, I am somewhat confused with the installation instructions. I did not follow the instructions to install boost and numpy since I have already installed them from the Ubuntu repositories.
I guess that wasn't so hard. Here's what I did to run the small sample on the website and in test/samply.py.
After downloading and unpacking PyUblas, and having the necessary libraries installed, cd into PyUblas-VERSION
./configure.py --help
./configure.py --some-options
sudo python setup.py install
cd test/
g++ -I/usr/include/python2.7 -fPIC -g -fpic -shared sample_ext.cpp -lboost_python -lpython2.7 -o sample_ext.so
python sample.py
It's going to be difficult to help without knowing what exactly your issues are. My first guess if the tests aren't working would be that your config file is not pointing to the right directories/files.