Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1057092 Posts in 42936 Topics- by 34883 Members - Latest Member: PTlGhOsT

October 24, 2014, 09:33:42 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Suppressing terminal/command line?
Pages: [1]
Print
Author Topic: Suppressing terminal/command line?  (Read 883 times)
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« on: February 29, 2012, 10:40:30 AM »

Note: this applies to windows, Mac os x, and Linux
I'm doing my first project compiling with makefiles and compiler commands rather than an IDE. I've encountered the problem that my output executables always launch through a command-line, which has been problematic. Should I be using a compiler other than g++ to achieve this? Are there some flags I'm missing? Furthermore on Mac the compiled application is referred to as a "Unix Executable" and not a native Application. I have a strong feeling I'm more than a bit off the mark here--can anyone lead me in the right direction?
Logged

rivon
Level 10
*****



View Profile
« Reply #1 on: February 29, 2012, 10:45:50 AM »

Post the commands you're using.
Logged
zacaj
Level 3
***


void main()


View Profile WWW Email
« Reply #2 on: February 29, 2012, 10:51:20 AM »

Mac Executables need to be packaged as apps.  An app is actually a folder with a certain structure, including the executable
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
ThemsAllTook
Moderator
Level 10
******


Alex Diener


View Profile WWW
« Reply #3 on: February 29, 2012, 10:56:35 AM »

If you put your Mac executable in a directory structure like this, it'll launch from Finder: MyApplication.app/Contents/MacOS/MyApplication

You may also want to put an Info.plist and PkgInfo in Contents.

For Windows, you need to pass -mwindows to the linker. Not sure about Linux, it's always worked for me in Ubuntu to just open the executable.
Logged
marksands
Manbaby
*


View Profile Email
« Reply #4 on: February 29, 2012, 12:42:12 PM »

I'm no windows guru, but if you want to suppress the command line on windows, try adding this line in your project file:

Code:
// Disable console on WIN_32

#if defined(__WIN32__) || defined(_WIN32)
#pragma comment(linker, "/subsystem:\"windows\" \
/entry:\"mainCRTStartup\"")
#endif
Logged
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #5 on: March 01, 2012, 12:29:38 AM »

Alright, another related issue:

When I run the SFML executable(be it via app package or otherwise) it'll crash for not being able to locate the resource files the game is looking for. Turns out it's some terminal execution directory issue because when I cd to the binary directory(where the resources are also located) and run the app from terminal it'll find the resources just fine.

Ideas?
Logged

Mikademus
Level 10
*****


The Magical Owl


View Profile
« Reply #6 on: March 01, 2012, 12:53:14 AM »

Obtain the executable location and always provide full paths to your resources. See here:
http://www.cplusplus.com/forum/general/11104/
Logged

\\\"There\\\'s a tendency among the press to attribute the creation of a game to a single person,\\\" says Warren Spector, creator of Thief and Deus Ex. --IGN<br />My compilation of game engines for indies
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #7 on: March 01, 2012, 01:08:20 AM »

Haha... Of course.  Facepalm
Thanks!
Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW Email
« Reply #8 on: March 01, 2012, 05:48:45 AM »

Be extremely cautious about using argv[0] for this sort of thing.  argv[0] is the command used to execute your program, which doesn't necessarily have anything to do with its location, or even the actual binary.

If someone makes a link or shortcut to your program and executes it using that, argv[0] will be the path to the link/shortcut.  This has burned me in the past.

The best Mac way I've found to switch to your resources directory is this:

Code:
NSFileManager *fm = [[NSFileManager alloc] init];
   
[fm changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];

[fm release];
Logged

Franchise - The restaurant wars begin!

What would John Carmack do?
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #9 on: March 01, 2012, 12:14:52 PM »

Alright, I'll do that.
I was hoping to keep a single code base for all platforms, but at this point it looks like it's in my best interests to work with some platform specific code too.
Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW Email
« Reply #10 on: March 01, 2012, 12:35:30 PM »

I was hoping to keep a single code base for all platforms,

I used to do that too, but then I realized that it's far easier to use a back-end/front-end system.  I keep a platform neutral back-end that probably contains 95% of my code, and write platform specific front-ends to interface with it.  Much easier to deal with in the long run.
Logged

Franchise - The restaurant wars begin!

What would John Carmack do?
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic