how to compile github project source code into a .exe using clang and or gcc - c++

I am an artist and would like to have access to Monster Mash (https://github.com/google/monster-mash) even if I can't access the web version due to connectivity issues. As such I would like a desktp version, from what I have read on the github page I would just have to compile the code, but I have no idea how I would go about doing this on a windows machine as I am having trouble with downloading or setting up clang or gcc to begin with (Is gcc only for use on Linux). The Linux approach seems much simpler and is (to my eyes) better explained on the github page, so as a side question, I would like to know if I can compile the program in linux for use on windows? thank you so much for any help.

Related

How to save c++ code file using visual code?

I downloaded the C++ extension of Visual Studio. How do I save it and how do I open it to see my code?
Usually, with HTML, I save as .html and when I open the file, I can see it on google chrome
see image
C++ is very very different from HTML. HTML can, as you know, easily be opened in a browser and viewed.
C++ is a programming language and must be compiled and run. There are many ways to do this and largely depends on the operating system you are using and software you have installed.
Since you are using VSCode you will likely want to use the terminal to compile and run it. Try looking at something like g++. You can find lots of tutorials online just by googling "compiling c++".
You may find it easier when just starting out with C++ to try it out a bit using a site such as repl.it which will let you write simple programs fairly easily.
If you provide a bit more info such as which operating system you are on I can help provide a specific example.
Will split my answer into three main points:
Small introduction.
Installation.
Additional resources.
Small Introduction
C++ works differently than HTML.
The main difference (there are more!) is that C++ files need to be compiled before they can be used. And that requires a compiler.
There are various compilers available for C++.
Installation
Assuming that OP is using Windows, assuming that VS Code is installed, there are a few additional requirements:
Install C++ extension for VS Code (this one).
Install the latest version of Mingw-w64 (from here). This one provides one with up-to date builds of GCC, Mingw-w64, and other C++ tools/libraries. Make sure you follow all the steps mentioned in MSYS2 installation guide (for a detailed installation guide go here).
Add Mingw-w64 bin folder to Windows PATH environment variable.
3.1. Access Settings and type in the search bar "Edit environment variables for your account"
3.2. In the User variables, select the Variable Path and click Edit.
3.3. Add the location of the Bin folder, the default should be C:\msys64\mingw64\bin and click OK.
Note: In order to check if the installation was successful, open a new CMD window, and run g++ --version. The output should look like
If one runs gdb --version the output should be
You are now ready to go.
Additional resources
If you want to learn how to create Hello World using C++ on VS Code, go here.
Additional resources that may be relevant:
GCC on Windows
For GCC on Linux
For GCC on WSL (Windows Subsystem for Linux)
There are plenty of C++ online compilers that one might want to use for faster testing, such as W3Schools. These can be quite handy as they allow one to view the result in one's browser.

Compiling gRPC using MSYS2/Mingw32

I've come across an issue whilst trying to compile the latest branch of grpc under MSYS2, using mingw64 as suggested by the official installation guide.
The latest gcc for msys2 is 5.2.0, which isn't exactly on good terms with grpc. Still, downgrading to 4.9.1 helped a bit. Through a lot of manual editing of the makefile and a couple C headers, I was finally able to compile all the dependencies. As far as I can tell, most objects had successfully compiled. However, make keeps failing with the error "no target to make libgrp.dll, required by shared_c"(might not be perfect wording). I end up with botched static libs that are recognized by Qt as lacking symbols.
I would greatly appreciate a reliable compilation guide for grpc, and/or precompiled binaries fit for Qt 5.5 32-bit. I know the project is not too mature just yet, but it looks very promising and I can't wait to work with it!
Many thanks!
You're right that mingw isn't quite a first class citizen for grpc, but it's something we're looking to work on soon. Please file bugs at http://github.com/grpc/grpc/issues for anything you find!
That said, we do test the C codebase against Visual Studio 2013 regularly. I expect C++ to be tested regularly soon, along with VS2015. Could VS2015 be the solution to your problems, given it's now a free download?

g++ 4.6.3 crashes when building code on 64 bit server

I have been developing a C++ application to run on a 64 bit Ubuntu 12.04. I develop the code on my 32 bit 12.04 Ubuntu laptop, then upload it to a git repository, pull it on the server and build the pulled source natively.
Until recently things worked well and I had no problems but today g++ 4.6.3 crashed when I tried to compile on the 64 bit server and I got an output telling me to submit a crash report (g++ 4.6.3 is the same version I have on my development machine also). The identical code did not cause a crash on my dev machine.
I am not asking why it crashed, but I would like to know what the problem was if possible. Does g++ produce any file logs when it encounters problems?
As far as I can tell my code is doing nothing controversial, I am not creating templates, I simply use a couple of boost libraries, mysql++, openssl and some static libraries I have written myself.
I really need to run this application every day so I want to fix this as soon as I can. I can think of the following ways to deal with things
Try and find out what aspect of my code caused the compiler to crash and rewrite my code accordingly.
Rent another server.
Upgrade (or downgrade) g++ or create an additional g++ on the server and try that. I am reluctant to do this as I have read that you can ruin your system when upgrading g++ on Ubuntu.
I use Eclipse to build everything on my dev machine and simply build code on my server using the Eclipse generated makefile that I have made part of the git project - I could write my own makefile in case something in there is causing the crash on the 64 bit server.
I would really welcome advice on how to proceed. I am not an expert on how compilers work internally and this is the first time I have encountered this kind of error so I am not quite sure what to do next.
I would really welcome advice on how to proceed
One reason for a crash might be hardware problem (faulty disk, disk controller, memory, or something else). This is hard to detect.
Another reason might be a compiler bug, but very unlikely.
What you can do is :
check the hardware of the server (run all possible checks you can think of). Try to compile many times on a different machine
make sure your system is not running out of virtual memory
upgrade or change the compiler, and see if it happens
There are various article explaining that g++ can crash because of HW problems :
crash during compiling - Most likely there is nothing wrong with your installation, your compiler or kernel. It very likely has something to do with your hardware. There are two exceptions to this "rule". You could be running low on virtual memory, or you could be installing Red Hat 5.x, 6.x or 7.x
crash during optimization

Compile C++ code for AIX on Ubuntu?

Question in one sentence: How can I compile code for AIX using G++ on Ubuntu? (Assuming it is possible)
I hope that it is as simple as adding an option to the make file to specify target processor. I am a novice when it comes to most things compiler related.
Thank you in advance.
What you are looking for is a cross-compiling toolchain.
A toolchain includes a cross-compiler (a compiler that runs on the current platform but builds the binary code to run on another, on your case, AIX), the C or C++ library, and some other interesting tools.
I have successfully used buildroot in the past, which is a tool that automates the process of creating a cross-compiling toolchain. I know they support several target platforms, maybe AIX is among them.
If you want to compile your toolchain by hand, take a look at the Roll-your-own section on this page.
Another approach, probably easier on your case, would be to install a AIX system inside a virtual machine on Ubuntu. This way you would have access to a complete AIX system running inside your machine, giving the opportunity to develop and test your application under real conditions (or whatever reasons you may find interesting for doing such a thing).
You'll want to download the right version of g++ (i.e., one that generates code for POWER, or whatever you're running AIX on), and compile that to run under Ubuntu.
Try to compile with -maix32 or -maux64 (like g++ -m32 file.cxx), it it doesn't work it means that it's not supported by your compiller.

Intel Performance Primitive (IPP) runtime error

I have source code that was not written by me, and I cannot contact the author. It is written in C++ and requires libjpeg, boost, and the Intel Performance Primitives.
Compilation was a chore, but after days of problem solving, it compiles. Now, I get the following runtime error: error while loading shared libraries: libippi.so.5.1: cannot open shared object file: No such file or directory. The error occurs immediately regardless of the command line arguments.
I downloaded the trial version of IPP for Ubuntu 9.04. Under /opt/intel/ipp/6.1.2.051/ia32/sharedlib/, I see a bunch of files beginning with lib* and libippi*, including libippi.so.6.1. So I thought I would try to create a link libippi.so.5.1 that points to libippi.so.6.1, but that doesn't work. I tried creating a similar link in the local directory, and that does not work either.
I am not familiar with any of these libraries, so I don't know what else to try. I could not find any solutions on the net or SO. If you could kindly help me fix this error, I would greatly appreciate it. Thank you.
I know its been a while, but theres a solution here that helps with the problem
http://www.w-bremer.de/en/howtos/72-opencv-ubuntu-ipp :)
Looks like the app is compiled against an older version of IPP. Since 6.1.2 is called libippi.so.6.1, it may be as simple installing IPP 5.1.x (though linux library versioning isn't as simple as this.)
If you create a login for the intel non-commercial IPP download area, you can dig around and see if they offer older builds.
Alternatively, doing a quick google search I found this FTP site which seems to have it but note I have not actually downloaded or tried this code, and can not verify if this is a legal mirror or not or if it is the original Intel libraries, you will need to do your own due dilligence before using this code
http://21cma.bao.ac.cn/software/21cma/intel/ipp-5.1.1.005/
Note that to use this older version of IPP in a modern Ubuntu, you may need to get older versions of other libraries it depends on (the requirements are listed in the Release Notes), or even just run it under a chroot of a supported Linux Distro at least to test if it fixes your issue.