Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / November 2006



Tip: Looking for answers? Try searching our database.

C++ std::cout -> Where does it go?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
silversurfer - 27 Nov 2006 15:31 GMT
Hello world,
I have written a program, which uses QT as GUI and which runs happily
in OS X and Linux. I can start the program in Ubuntu using
./myApp
and all the output I send with std::cout << "Test" (etc) can be seen
directly in the Shell-Window.

In OS X Terminal, I use
open myApp.app
to start the program. However, the terminal is accessable right away,
because the program is started as a new process (outside the terminal).
Thus, the output from std::cout cannot be seen anywhere.

How can I start a program in OS X such that the std::cout elements can
be seen somewhere or how can I make it visible?

Thanks a lot in advance
Tim
brianhray@gmail.com - 27 Nov 2006 15:38 GMT
I think it might go to your "console.log". The usual way to get to this
is to open the Console.app located in /Applications/Utilities. The
physical file is located under /Library/Logs/Console/<uid>/. Someone
correct me if I am wrong or TIAS.

-- Brian Ray (http://kazavoo.com/)
Daniel Höpfl - 27 Nov 2006 20:35 GMT
Hello!

> I have written a program, which uses QT as GUI and which runs happily
> in OS X and Linux. I can start the program in Ubuntu using
[quoted text clipped - 10 lines]
> How can I start a program in OS X such that the std::cout elements can
> be seen somewhere or how can I make it visible?

Go into the bundle: cd myApp.app/Contents/MacOS and start the executable
from there (should be ./myApp).

open sends the given file to the default application which is - for
applications - the Finder. Starting applications with the Finder
connects stdout with /dev/null and everything written to stderr is sent
to console.log.

HTH,
  Daniel
silversurfer - 28 Nov 2006 10:08 GMT
Thanks a lot for the tips, this is how I solved it...

Daniel H?pfl wrote:
> Hello!
>
[quoted text clipped - 15 lines]
> Go into the bundle: cd myApp.app/Contents/MacOS and start the executable
> from there (should be ./myApp).

At first, this did not work because some files were leaded from other
sources, and the relative paths did not work from within
myApp.app/Contents/... However, in Qt there is the option not to build
the files as a bundle but directly. This gives more Linux-Style files
which can be started directly by typing ./myApp

Having changed this option in the project file by CONFIG-=app_bundle
and rebuilt the whole thing, I can now start the application by ./myApp
and the output goes where it belongs: The terminal.

> open sends the given file to the default application which is - for
> applications - the Finder. Starting applications with the Finder
> connects stdout with /dev/null and everything written to stderr is sent
> to console.log.

Good to know, thanks!

Greetings
Tim

> HTH,
>    Daniel
Michael Ash - 28 Nov 2006 15:56 GMT
> At first, this did not work because some files were leaded from other
> sources, and the relative paths did not work from within
> myApp.app/Contents/... However, in Qt there is the option not to build
> the files as a bundle but directly. This gives more Linux-Style files
> which can be started directly by typing ./myApp

If you want something that acts like a normal Mac applicaiton then you
should continue to build a bundled .app. (You should also avoid Qt, but
that's a topic for another day.) The problem is not the bundled app, but
rather that Mac applications cannot depend on the working directory to be
set to anything useful when they start. If your code needs the working
directory to be set to, for example, your Contents/Resources directory,
then you should set it yourself. You can do this by using CFBundle to
get/construct the path, then set the working directory appropriately early
on in your code.

Signature

Michael Ash
Rogue Amoeba Software

David C. - 28 Nov 2006 15:56 GMT
> I have written a program, which uses QT as GUI and which runs happily
> in OS X and Linux. I can start the program in Ubuntu using
[quoted text clipped - 10 lines]
> How can I start a program in OS X such that the std::cout elements can
> be seen somewhere or how can I make it visible?

If this is just for debugging, you can run your app from within the
Xcode environment.  It redirects all this output to a window.

-- David
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.