Where does Xcode save preprocessor macro settings - xcode

I am working on a project that was created using cmake. (It's a project that is built for lots of different platforms, including Linux Mac OS, and now iOS.)
The cmake process creates an Xcode project which I then am modifying manually.
One of the things the project contains is dozens of preprocessor macros that drive #ifdefs in the code.
The cmake tool only defines these macros for debug builds. I need to build a release version so I can profile the project. however, the release build fails because of missing preprocessor macros, which cause the #ifdef/#ifndef compiler directives to be set wrong.
I'd really rather not manually enter 35 preprocessor settings, especially since the Xcode editor displays this awkward popup with + and - buttons to add/remove one at a time, and when I'm editing release symbols, I can't see the debug symbols, and copy/paste doesn't work.
What I really want to do is find the internal file in the xcode project that sets these macros, copy it out of the debug settings, and either paste it into the release version, or at the very least, manually enter one macro at a time into the release version by copying it from a textfile containing the macros that were defined in the debug version.
Can somebody tell me where the debug and release preprocessor macros are saved in the Xcode project file hierarchy so I can go read the raw file and possibly modify it?

In your project.pbxproj, search for GCC_PREPROCESSOR_DEFINITIONS. That should be a list of the macros. It should be pretty easy to copy and paste the list from one configuration to the other.

Related

How can I install GLUT, GLUI, GLEW, and, GLFW so that I don't need to pull hairs every time I create a new project in VS?

I have solved the GL and GLUT part by installing NVidia CG toolkit. But, having continuous trouble with GLEW, GLFW, GL WTF W, etc.....
I want to install .h, .lib,and, .dll files related to GLUT, GLUI, GLEW, and, GLFW in such a location so that I don't need to pull my hairs every time I create a new project in Visual Studio 2003/2005/2008/2010/2012/20....... .
I am using 64 bit Windows-7.
But, others are bothering and confusing me every time I create a new project.
Create an empty project in which you will once setup once all necessary properties in:
C/C++ -> General -> Additional Include Directories
Linker -> General -> Additional Library Directories
Linker -> Input -> Additional Dependencies
All additional properties if any are required ...
Then, use File -> Export Template from the VS menu to export project template, so you can use it every time you are creating a new project. More information about project templates can be found here:
https://msdn.microsoft.com/library/xkh1wxd8(v=vs.100).aspx
EDIT:
Create an environment variable that will hold the path to your directory which contains the necessary libraries and headers (for example, GL_LIBS). Then, when setting up properties of the project to be exported, use this variable value instead an absolute path (for example: %GL_LIBS%\xyz_headers_dir). This way, if you want to change the location of the libraries, the only thing necessary is to change the environment variable and it will work. This is also helpful in situations when several team members work on the same project and don't want to keep these files in the same location.
One more thing, since "Export template" does not work on VS2010 or older, you will have to do additional steps. In case you are using VS2010, it is only a small issue since there is a VS extension which you can use to export project templates:
https://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24/
If you are using an even older version, then you will have to create a custom wizard which enables you to export a VC++ project template:
https://msdn.microsoft.com/en-IN/library/96xz4cw2(v=vs.90).aspx
I do not advise this at all, since if you want to build a project without these libraries, you'll still have them cluttering up your include paths. This can cause conflicts with other libraries if they happen to use the same include files as one of these. But if you insist...
Visual studio has default paths that every project gets. You can simply add the include and library paths of your choice to these paths. In older versions of Visual Studio, they live in Tools->Options->Projects and Solutions->VC++ Directories or something like that. In newer Visual Studio versions, they live in the VC++ Directories property page of the project/solutions property sheet.

VS2010 - add custom compiler for certain file extensions

I've written a command-line OpenCL compiler. I'd like to have VS compile my kernel source files using this whenever I build the C# project that includes them. I've looked around and found information and custom build tasks, custom tools, etc, but I haven't been able to get it to work correctly.
How can I tell VS to run my exe on the source files in the same way that it runs the c# compiler, etc for other files in the project?
I report errors from this tool by calling Console.Error.WriteLine(). This dutifully places the errors in the Output pane, where I can double-click them, taking me to the appropriate place in the .cl kernel source file. However, the errors don't appear in the VS error panel. ??
Alternatively, if anyone's aware of an existing OpenCL compiler - it's annoying to have to run the host application just to compile the kernel - I'd appreciate a link.
I've managed to get this working by adding a post-build step to the project options. However, I'd really prefer for this exe to be run for every *.cl file in the project.
Update I had neglected to include an error code when formatting my error messages. Correcting them to match any of the formats listed here took care of that issue. Still trying to figure out how to associate an exe with a given file extension, though.

VStudio 2010 custom build issue

I use an Oracle precompiler for embedded SQL. I'm moving some code from VC++ 6.0 to VStudio 2010.
I place database calls in a single source code module named "dbcalls.pc" - that gets passed to the precompiler which produces "dbcalls.cpp" which then gets passed on to the compiler and linker like all other .cpp files.
Under VC6 I do a compile on my custom build .pc file manually - ie; rt click the dbcalls.pc file and choose compile. Then due to a bug in the specific version of the Oracle precompiler I use I have to open the .cpp and insert #include "stdafx.h" at the top of the .cpp produced by by the precompiler - I have a macro that does this. Then I can perform a build on the entire project and the VC6 IDE will NOT attempt to re-run the custom build.
In VStudio 2010, I have replicated this with one important exception/problem - if I configure the dbcalls.pc file to be excluded from the build under properties (where it is specified as being of type custom build) then I am unable to rt click the file and choose compile.
If I set the property to be included in the build I can rt click and manually build the .pc into the .cpp but then after I alter the .cpp when I run a build for the project it reruns the custom build and removes my changes. I'm forced to go back and forth with the properties dialog and change the "exclude from build" setting. This is a royal PITA that does not happen in VC6.
Can anyone suggest workaround? Obviously if the precompiler did not have this bug then all would be good but moving to another version of the pc is not currently in the cards.
thoughts?
OK - I'm not sure why - perhaps I swung the chicken over my head just the right amount of times.. - but it's working correctly now.
I resolved another issue I had with macro arguments to the precompiler in the custom build dialog and once I did that it started doing the conditional build correctly (or at least as I expected it to work).
Shrugged my shoulders a few times and said "case closed".

creating an XCode project with existing code

I'm in the process of porting a Linux application to Mac. I have different files with the source code that can get compiled and linked using the standard Makefile.
I'm going to be porting that code to Mac and continue writing code in C (sorry, no obj-c). Is there a way to create a project on XCode, add the existing code so I can use XCode and the IDE, compile and debug the code and generate Mac Makefiles?
Thanks for the help
New Project -> Other -> External Build System
(in new project)
Expand "Targets"
select the target the template created
press return
edit the target settings:
by default, it uses /usr/bin/make for invocation. if you want to use some other build system, then you'll have more to configure.
for a Makefile, you will need to set the 'Directory' field of the build settings window to the directory which contains the appropriate makefile to build.
note that you'll lose some integration when using a makefile.
you can regain some of that by adding the sources to the project (drag and drop), and not associating them with a target.
to improve navigation and code completion, you may want to create a second (dummy) target (such as a static library) so the ide parses your programs. you would then add the sources to the dummy static library, and set the makefile as a 'dependency' of the static library (so it gets built, and so it gets built first).
The Apple Developer docs have a section on porting makefile based projects into XCode.
"Porting UNIX/Linux Applications to OS X"
This subsection is most relevant: "Building makefile projects with XCode"
https://developer.apple.com/library/content/documentation/Porting/Conceptual/PortingUnix/preparing/preparing.html#//apple_ref/doc/uid/TP40002849-BBCJABGC
You can build using your existing makefiles and create a wrapper project with a custom target with a 'Run Script' build phase that just calls down to your makefile. This means that you'll also be able to use the debugger, but you probably won't get the full benefit of the editor with autocompletion etc.
To import C code into Xcode:
start xcode
new project
pick something like Standard Tool. Should read c command line tool.
drag you file or files onto main project window. This is the first window that comes up when you create a new project. My project name is xaBitHoist. I dropped the files on xaBitHoist > src.
just build. Seems to default to main.c
to change start program or add argues Project > New Project Executable.
the online help for xcode is good.
Good luck.
Robert

Why compile button is disabled in VisualStudio?

For some reason when I open my project Compile button is disabled. I'm in C++ file and Ctrl+F7 doesn't work, Menu/Build/Compile is disabled and Compile in context menu in SolutionExplorer is disabled too. I can build project with F7, but I can't compile single file. It used to work just fine.
Any ideas why?
Had the same problem just because my project wasn't set as startup Project in my solution. Setting it solve the issue.
It seems that problem is on my side: someone in my team introduced some build scripts, which apparently work only for building whole project.
It might also be that a referenced property sheet could not be found. You can check this by attempting to view the properties of the project (Alt-Enter). A warning will be shown then when the property sheet cannot be found. Fix the property sheet reference, and probably you can compile again.
Note: question was asked/answered a while ago, but maybe it is useful for other persons.
My project was using an intermediate version of a unity build (sometimes called blob build) where groups of ~10 cpp files are put in the same compilation unit by being included in some blob_xxx.cpp. The project only considers the blob_xxx.cpp as source files, so technically the .cpp I was working on was not a source file for the project, so the Compile command was disabled (this is similar to what Paulius experienced).
In this case, you need to either select the blob_xxx.cpp file and Compile this single file, or switch to a non-blob build.
If your objective is to quickly test for compilation errors, you can comment out the includes for all the files you are not working on.
Alternatively, you may setup your project generation script to isolate the files you are working on in a separate blob (it's up to you to define what "working on" means; it may be a manual list or the list of cpp files that are checked out in Perforce if using it).

Resources