Hey guys,
I'm trying to compile my code on OSX Snow Leopard (Virtual Machine). I'm using the GCC compiler WITHOUT XCode (http://kennethreitz.org/xcode-gcc-and-homebrew/). My code is all ISO C++ with no external libraries and compiles fine. However, when I run the program, ifstream does not read anything from the file. (I get blank lines where there should be stats for the game characters).
After DuckDuckGo-ing the problem I found a solution that has worked for developers using Xcode: Delete the preprocessor macros _GLIBCXX_DEBUG=1 and _GLIBCXX_DEBUG_PEDANTIC=1 from the project settings.
However, I am only using the GCC compiler derived from the one packaged with XCode, not the actual IDE. Does anyone know how to remove these options while compiling from the terminal?
Mac GCC and ifstream command line fix? [SOLVED]
Moderator: Coders of Rage
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Thu Mar 28, 2013 1:02 pm
Mac GCC and ifstream command line fix? [SOLVED]
Last edited by jmcintyretech on Tue Aug 13, 2013 9:40 am, edited 1 time in total.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Mac GCC and ifstream command line fix?
Code: Select all
-D_GLIBCXX_DEBUG=0 -D_GLIBCXX_DEBUG_PEDANTIC=0
edit: Actually, this isn't necessary. Those aren't defined by default... which means this can't be your problem.
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Thu Mar 28, 2013 1:02 pm
Re: Mac GCC and ifstream command line fix?
Hmm. I'll add some code to check and see if the file is being opened and read, etc. Like I said this code is working properly in Linux and Windows, and the file is in the same directory as the executable. I'll see if I can further pinpoint where the problem lies. Thanks for the reply Falco!
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Thu Mar 28, 2013 1:02 pm
Re: Mac GCC and ifstream command line fix?
Looked into this further tonight and found an odd solution. If I navigate to the program directory in the terminal and execute it from there, it works fine. I only have this issue when clicking on the executable to run it. Huh. Maybe when you execute an application by double clicking it runs from a different location? I'll do some research and see why that is Thanks again for the help.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Mac GCC and ifstream command line fix?
Interesting.
Try this at the command-line to display the working directory of your processes:
Try this at the command-line to display the working directory of your processes:
Code: Select all
lsof -d cwd
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Thu Mar 28, 2013 1:02 pm
Re: Mac GCC and ifstream command line fix?
Tried that handy command.
Turns out that when I double click the executable, it starts it in the home directory /Users/josh
No shit! There's the source of my problem
Thanks again
Turns out that when I double click the executable, it starts it in the home directory /Users/josh
No shit! There's the source of my problem
Thanks again
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Mac GCC and ifstream command line fix?
Why the fuck... I wonder if there's some OSX-specific flags you can pass to GCC on OSX to make it disable retardism...
-
- Chaos Rift Newbie
- Posts: 34
- Joined: Thu Mar 28, 2013 1:02 pm
Re: Mac GCC and ifstream command line fix?
g++ main.cpp -o main_osx -quit_being_a_dumb_os