Code runs perfect in g++ but not in Xcode - Cannot find File

后端 未结 2 1408
梦如初夏
梦如初夏 2020-11-28 15:37

I have created a text file with content. It is located in the same folder as the cpp files. And I have confirmed several times that the file exists. When I run g++, compile

相关标签:
2条回答
  • 2020-11-28 16:02

    Try to add files to the project in XCode or use the absolute path instead.

    0 讨论(0)
  • 2020-11-28 16:13

    Your file fails to open because XCode launches from the IDE in the default build location, which is actually a temporary directory off somewhere on your disk. If you want change the working directory at launch-time to something else (like the location where your files can be found):

    1. Select the Product/Edit Scheme... menu option.
    2. Select the Run schema in the left list.
    3. At the bottom Options tab on the right pane should be a "Working Directory" option. Check the checkbox and set the custom working directory to someplace you know (your "/Users/yourname" home directory is a decent place that I use).
    4. Make sure any "current directory" data files you need for your program execution from the IDE are in this directory.

    And in case you didn't see it, this is also the place where you can configure command-line arguments (on another tab) of the same dialog.

    0 讨论(0)
提交回复
热议问题