Getting A Compiler To Work

As I get to the point in my education where tutorialspoint cannot do what my programs need to do, and the projects are long enough where a dozen hours a week in class is not enough time to actually finish what I need to finish...a problem I've had for several months is finally at a breaking point that I can't just find workarounds anymore.

For months now I have not been able to get any compilers working from scratch. I've tried on both PC and Mac dozens of IPEs and nothing works. It feels silly that something so basic is giving me such a hard time, but I've literally put in several six to hour days just trying to figure out this single issue before to no avail (hence why, up until now, I've always eventually given up and just worked around it). I've found plenty of Q&As on google dealing with similar issues if not identical ones, but none of those proposed solutions has netted me even closer to an answer let alone finding one.

I've tested on PC to see if it was a Mac-specific problem, but I am ultimately aiming to get a fully functional c++ -specific compiler for Mac (as I rarely have access to a PC). I have Xcode, Eclipse, and a few others that aren't considered nearly as good as either of those (from what I've read at least).

I've heard Eclipse was good from knowledgable sources, so I'm trying to focus on that, but honestly don't know where to start in asking for help. One error code is "The selection cannot be launched, as there are no recent launches." The other is "Cannot Find Binary." I have not been able to replicate third error code.
Last edited on
closed account (E0p9LyTq)
Have you tried code::blocks? It works on Windows, Linux and Macs:
http://codeblocks.org/
Codeblocks is a compiler, right? So, somehow, if I understand it correctly I'd download it and then run it with (for example) Eclipse? If this is what I'm supposed to do, I have yet to find a source that explains how this process is supposed to work in a coherent manner before.
closed account (E0p9LyTq)
code:blocks is an Integrated Development Environment (IDE). You can download a version with a compiler or download code::blocks itself and use a separate compiler.

I personally don't use code::blocks, I use Visual Studio 2015 and MinGW GCC 6.10 for Windows.

If you want to use Eclipse here's a tutorial you might not have seen?
Installing Eclipse on Mac OS X - Dartmouth Computer Science - http://cs.dartmouth.edu/~cs5/install/eclipse-osx/index.html
For months now I have not been able to get any compilers working from scratch.


Just wondering what you meant by that exactly - what have you been using to compile the code in your other questions? Problems with the code itself != problems with compiler / IDE. If the compiler doesn't work, then it probably doesn't work at all.

I would recommend an IDE that does background compilation, so that errors and problems are highlighted as you type in the code. AFAIK, C::B doesn't do this. But you could and should compile frequently it only takes a second, so you could even do it after every few LOC.

The other thing is to try and get hold a clang++ compiler - it has nice error messages, which could be helpful in being able to decipher the compiler output yourself. It is also a good idea to use different compilers, you could test things out on coliru-stacked which allows one to select different compilers and command line options.

Also, make sure you have all the warning levels turned on - warnings are your friend to writing good code.

http://www.cplusplus.com/forum/general/183731/#msg899203

http://clang.llvm.org/

I use QtCreator with clang and gcc. I can still do console apps, without having to get involved with Qt itself. I sometimes use KDevelop - it has the advantage of being able to used to code in over 60 different languages / scripting, providing one has a compiler / interpreter for each particular language /script . But it doesn't yet work with clang.

Hope that helps :+)
If the compiler doesn't work, then it probably doesn't work at all.


Yeah, the compiler doesn't work at all. Even with Hello World test code it won't work. No error messages, just a popup window that either says:

"The selection cannot be launched, as there are no recent launches." or "Cannot Find Binary."

But this has pretty much been the case for every single compiler I've ever tried to use outside of the pre-fitted ones they use in the classroom.
Last edited on
Does anyone know how to get the terminal to open and run c++? I know the g++ and -o commands, but no matter what I type (even copying the entire directory from the Get Info screen) I cannot get the terminal to actually open the directory.
It sounds like you have bigger problems than the compiler.
What version of OS X are you using?
How are you installing software?
Have you modified your OS in any way?
Have you moved directories around any? Deleted any?
What are the steps you take to run your compiler?
(What again is wrong with XCode? -- it uses Clang/LLVM, which is the best there is.)
What version of OS X are you using?

10.11.5 El Capitan
How are you installing software?

Installing software from the host's site (never through third-party sources) and then running the standard installation process.
Have you modified your OS in any way?

Have no modified my OS in any way whatsoever.
Have you moved directories around any? Deleted any?

I've renamed files to rid the file names of any spaces, and I've copied files over to see if I'd have better luck in a shorter file directory; but I've not actually moved anything.
What are the steps you take to run your compiler?

With Eclipse, I'm hitting the "build" function, and nothing whatsoever happens (no error messages even when I know it shouldn't compile), and then it pops up one of the two stated error messages when I try to "run." I have tried every single setting from the C/C++ > Build and the Editor as well as many other Preferences tabs that I honestly don't know what they mean to try and see what sticks. When nothing works, I always restore to default settings afterwards.
(What again is wrong with XCode? -- it uses Clang/LLVM, which is the best there is.)

Eclipse mentioned using Clang in one of its menu options (but upon trying to re-open it to find the reference again, I have not been able to find where).

Xcode has more or less the same problem. If I open a new project and paste in my file data, even if I save it afterwards, it doesn't recognize having a file to run. If I open the file from Finder and select to open it with Xcode, it opens with Xcode as just a text editor with no compile, run, etc options whatsoever.

It is also worth noting that my Mac is literally under a month old, and basically has factory settings on all fronts. Aside from compilers I only download from first-party sources, system updates, and a few iTunes songs, I have not downloaded a single thing onto my machine.
Last edited on
(With Eclipse) I finally found a Build Settings tab that let me import my .cpp file and now I'm not getting either error when I try to run...but it still doesn't actually run or build anything at all. I'm not sure what processes are actually being performed when I press "Build All" or press what appears to be the "Run" button (that now says "run new_configuration").
This isn't leading to any progress. Have I actually managed to backtrack?
Okay, so you've renamed stuff. You haven't renamed anything outside of your user directory, correct?

It looks like El Capitan has issues with XCode.
https://forums.developer.apple.com/thread/13458

closed account (48T7M4Gy)
SaltLakeAtrocity

You might already have tried this but its sounds like you might not be using XCode as well as you could.

My experience FWIW is you need to open a new project and use that like a sandbox to hold your current working files.

Once that's done you can drag files, usually the left panel, into the project shown at the top of the IDE file structure. It will ask you if you want to just copy the file as a folder reference and that's normally all you want. Then compile and run.

Xcode is no worse than any other IDE I've come across. They all suffer path problems from what I have seen and it's not the worst.

Qt Creator is OK until you have to find a console app/exe - but that's more of an Apple/inexperience thing. It beats the hell out of cb, vs and Eclipse I reckon.

PS I don't doubt there have been conflicts in the past but the current versions of xcode 7.1 and El Capitan work without a hitch.
Last edited on

My experience FWIW is you need to open a new project and use that like a sandbox to hold your current working files.

Once that's done you can drag files, usually the left panel, into the project shown at the top of the IDE file structure. It will ask you if you want to just copy the file as a folder reference and that's normally all you want. Then compile and run.


Thank you. So I've at least gotten Xcode to compile data (Hello World works fine). But it won't work with file i/o's whatsoever (even when they're in the same project folder) in situations where a standard working compiler (that I rarely have access to) handles them just fine.

Okay, so you've renamed stuff. You haven't renamed anything outside of your user directory, correct?


The directories I am typing and/or copying into the terminal are lifted from the new names, and I close terminal and re-open every time I changed a file name.
The directories I am typing and/or copying into the terminal are lifted from the new names,
I don't understand.

and I close terminal and re-open every time I changed a file name.
Changes you make to magnetic media remain even after you close the terminal.
closed account (48T7M4Gy)
The data files are the next and hopefully final killer. But still no more than other IDE's.

A dirty trick is to create via a quick program a text data file and see where it goes. Give it a distinctive name and use Finder. It will be in the project directory you have created, somewhere. That's where input and output files go until you surf through the voluminous preferences later and select a directory of your choice. What the trick means is the data and program are separate but that's not a bad thing anyway.

Once you know where the file is you can organise the directory from the sidebar the same as for the project files. You don't have to drag the data files into the project and you don't need to include the path in the file name.

Glad to hear hello worked - keep at it and the whole lot falls into place. Use qtCreator for GUI stuff, it's not bad, but it's a bit awkward for quick console stuff because of the extra terminal steps required. qt beats Windows vs, CB though by a mile.

Cheers
closed account (48T7M4Gy)
PS Using terminal is OK in Xcode too but it's easier to use the panel, whatever it's called, at the bottom of the IDE itself. The panel is controlled from the icons in the toolbar(s)
A dirty trick is to create via a quick program a text data file and see where it goes. Give it a distinctive name and use Finder. It will be in the project directory you have created, somewhere. That's where input and output files go until you surf through the voluminous preferences later and select a directory of your choice. What the trick means is the data and program are separate but that's not a bad thing anyway.


it's rather bothersome that these IPEs require so many hoops to input files. Every project I make is forcibly (and unnecessarily) nested about four folders deeper than where I'd ideally like to access the file from. But the fact that, after more hours and days and weeks than I care to count, I finally have a compiler in a functional form thanks to the advice you and other have given meā€”means I can't honestly complain. Much thanks.
Last edited on
closed account (48T7M4Gy)
nested about four folders deeper than where I'd ideally like to access the file from


That's where the problem lays with all this stuff but none of it is avoidable from the makers point of view so that's why they give you heaps of preferences. If you decide to change these just make sure you can go back. It's basically lack of familiarity with these packages that bites.

Good to know you have made a start. :)
Topic archived. No new replies allowed.