XCode C++ source code print issue on Mac - c++

I am using MacBook Pro Mac OS 10.5 with related version of XCode. I am new to this development environment. I am developing C++ console/terminal applications (File->New project, then from the list on the left "Command line utility", and on the right "C++ tool".).
For C++ source code file, I want to print source file content with line number. Any ideas how to do this?
thanks in advance,
George

I found this article A Recipe to Pretty-Print Your iPhone Source in Xcode it uses enscript which is installed by Apple for Xcode on Snow Leopard so no need for macports etc.
You can get linenumbers by passing -C as an argument to the enscript executable called in the shell script

Related

Error: Could not resolve SDK path for 'macosx10.8'

So I just installed qt around 5 minutes ago, and when I wanted to code a simple line of text in the Push Button and try to run it, I got this error:
:-1: error: Could not resolve SDK path for 'macosx10.8'
Could anyone help? Also, if you need me to do something, could you explain like I'm five please. (Not actually like I"m five but I hope you know what i mean)
The problem is that the online installer for Qt currently supports OSX 10.8 (Mountain Lion) by default, and I'm guessing you are on 10.9 (Mavericks) or greater.
There is a workaround:
Navigate to where you installed Qt (default /Users/your username/Qt) using finder
Go to the subdirectory 5.3/clang_64/mkspecs directory
Open the file called qdevice.pri with a text editor
Change the line
!host_build:QMAKE_MAC_SDK = macosx10.8
to:
!host_build:QMAKE_MAC_SDK = macosx10.9 if you are on OS X 10.9 (Mavericks), or
!host_build:QMAKE_MAC_SDK = macosx if you are on OS X 10.10 (Yosemite)
Save the file and restart Qt Creator
I'm running Qt 5.7.1 on Mac OS 10.12.2.
None of the above answers involving adding !host_build:QMAKE_MAC_SDK = macosx10.12 to a file worked for me.
What did work was a small reconfigure on the XCode side of things as described here, the key step being entering
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
in the command line.
What caused the problem for me was that I installed the XCode command line tools before installing XCode itself which apparently makes it hard for Qt to find the Mac OS SDK.
For Qt 5.7 and macOS Sierra
Navigate to where you installed Qt (default /Users/your username/Qt) using finder
Go to the subdirectory 5.7/clang_64/mkspecs directory
Open the file called qdevice.pri with a text editor
Add line on end file
!host_build:QMAKE_MAC_SDK = macosx10.12
add
QMAKE_MAC_SDK = macosx10.12
to your .pro file. Done and Done. (for some, qdevice.pri does not contain the !host_build line, and adding it does nothing, so just set the variable directly in the .pro file).
I have confirmed that you will eventually also have to implement this https://github.com/Homebrew/formula-patches/blob/master/qt5/xcrun-xcode-8.patch: which is just a matter of changing one line in your default_pre.prf file (for your appropriate machine aka Mac/PC, etc...)
I recently upgraded from OSX 10.8 to 10.12 and ran into this using Qt 5.7
The issue was resolved by a combination of:
1) FranklinA's suggestion:
Open Xcode->Preferences->Locations->command line tools..select the CLT
xcode-select active developer directory error
..and..
2) adding to the .pro file the following line:
QMAKE_MAC_SDK = macosx10.12
Coming to this late.
I had this error an all I needed to do was open up the actual Xcode app (which for some reason was not findable by spotlight but was in the applications folder), accept some terms, and let it do some config.
In QT 5.7.0, Xcode 8.0 (8A218a), Mac OSX El Capitan (10.11.6), this issue happened from sudden in already configured environment. 5.7/clang_64/mkspecs/qdevice.pri no longer contains QMAKE_MAC_SDK line to modify.
I suspect some XCode part got silent update and I issue appeared again. This worked:
open XCode and let it reconfigure again (automatic action upon start)
delete .pro.user file from the project
reopen project in QT
Using QT 5.7.0, Mac OSX Sierra (10.12), XCode 8.0, I got the typical error coming from searching in:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
instead of:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
Adding the line
!host_build:QMAKE_MAC_SDK = macosx10.12
to the Qt/5.7/clang_64/mkspecs/qdevice.pri file, worked for me.
In my case , I have just opened xcode again. It start installing some components. Once it finished , I open Qt again and everything start working fine.
All I had to do was accept the Xcode licence by running: sudo xcodebuild -license accept

Xcode 4 Mavericks Creating Universal Binary for OSX hangs

was it ever possbile to create a C++ command line tool as a fat binary in XCode (32bit and 64bit in one file)? I thought it was, but if I try it now, XCode hangs during "Creating Universal Binary."
I updated to OSX Mavericks and I am using XCode 4.6.2. It doesn't matter which compiler I choose. As soon as I set "Build Active Architecture Only" to false, the compiler hangs during "Creating Universal Binary".
Additionally I am building a static C++ library in my project which has no problems to be build for 32 and 64 bit in one file.
I hope you can help me.
Cheers
Georg
I had the same problem after updating to Mavericks. Both Xcode 4.6.3. and Xcode 3.2.6 were hanginig endlessly during "Creating Universal Binary."
As it's the lipo command line tool that's creating the universal binaries I did some research and found this discussion which solved my problems:
Installing psycopg2 has it stuck between xcrun and lipo
According to the answers given there Xcode apparently didn't find lipo in the end but unfortunately shows no error message in this case.
After backing up the 10.9 version of /usr/bin/lipo and linking in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo as described in the post creating the universal binaries was working again.

xcode 4.2 + xcode project from makefile

I am trying to build c++ xcode application from makefile.
I am using xcode 4.2, and in this version i dont see command line utility->standard tool.. All the help says "If you are just trying to build a command-line utility, selectone of the tools—for example, Standard Tool."
I have installed command line tools from preferences->downloads->components
Can some one help me on this?
You should have "Command Line Tool" available when starting a new project in "OS X"->"Application". If you don't, try updating your softwares, including XCode.

C++ Eclipse Mac Hello World

I am using Lion, Mac OX X 10.7.5 and Eclipse Juno to try and learn to program using C++. I created a new project using the hello world template. When I tried running the hello world program I got 3 errors:
Program "make" not found in PATH
Program "gcc" not found in PATH
Program "g++" not found in PATH
I have Xcode downloaded also. I selected the toolchain MACOSX GCC.
Once you downloaded Xcode, you also need to download the command line tools package from within Xcode which will install the necessary make program and clang compiler.
To download it go to Xcode >> Preferences >> 'Downloads Tab' and install Command line tools.

IntelliJ IDEA 12 setup for C/C++ on OSX

I recently decided to try IntelliJ IDEA 12 CE.
I Successfully installed their C/C++ plugin and restarted the IDE.
Now after I click File->New Project->C/C++ Module, next window prompts me to "Choose Cpp SDK".
I'm stuck at this window, tried entering many paths and failed.
My system is OSX Mountain Lion, Xcode 4.5.2 with command-line tools installed.
Compiling from command line with gcc works just fine.
I can confirm that using Idea 12.0.1 Ultimate (Build Id 123.94) and Xcode 4.5.1 on OSX this simply works. At the dialog for "Choose Cpp SDK" I wrote /usr/bin/gcc (which was what "which gcc" returns on my system. I used version 0.8 build 4.
There is a nice C++/Obj-C IDE from JetBrains for development on OSX - AppCode. Not so long ago it updated to 2.0 version. Most IDEA functionality and plugins are supported.
This error message is displayed when running IDEA from command line:
ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(449,630),absolute(903,739),button=1,modifiers=Button1,clickCount=1] on dialog0
Probably bug in the plugin for IDEA 12.
Try to use IDEA 11.