I'd like to use all the power of Xcode for generic C/C++ projects but I can't figure out what are the basic steps to configure a new Xcode project and attach it to an existing source tree of a legacy, plain, C/C++ project.
Creating a new empty project, attaching it to a source tree and configuring a build target (using GNU Make) was a really silly task.
I can't figure out how to enable source code indexing in order to enable source refactoring tools, searching and fast-jumping and all the amenities that makes the Xcode programmer's life great.
Moreover I'd like to use the internal debugging facilities…
Does anyone point me to a tutorial, a hint or whatever could be useful?
Thanx
I've found a (dirty) path to enable refactoring tools:
I've added a new standard «console target» to the project and added all the source files under the Build Phases > Compiled Sources.
Refactoring tools now works. Having two targets doesn't seem to be a relevant issue (elegance apart)
Personally, I wouldn't attempt to use legacy Makefiles, even though I think there's some support for that.
Typically what I do with a traditional C/C++ project is to store my XCode project folder at the root of the project. So it might look like:
--myApp
--src
--inc
--myApp Xcode
I then drag the src folder and inc folder into the project navigator. This gives me an Xcode project to compile with on the Mac, and then I have the traditional Makefile for compiling on Linux (actually, I prefer CMake for other platforms, but either way works).
Related
I have recently started with my plan to develop a simple game and for that, I have installed SDL for VS. But Every time I create a new project I have to go to properties-> Compiler and properties-> Linker of that project to add my SDL libraries. Can I permanently include these settings.
Also, does it necessary to include ".dll" every time in my project or I can link them too for anytime usage.
I have been using CMake with VS and SDL lately and it reduces this annoyance a bit. Your top directory (and additional directories, depending on how you organize your project) will have a CMakeLists.txt file which handles include directories, finding libraries and DLLs, and building any dependencies. The one for my current project looks like this:
cmake_minimum_required(VERSION 3.19)
project(chip8emu VERSION 1.0 DESCRIPTION "Chip-8 Emulator" LANGUAGES CXX)
set(SDL2_INCLUDE_DIR "C:/dev/vclibs/SDL2-2.0.14/include")
set(SDL2_LIBRARY "C:/dev/vclibs/SDL2-2.0.14/lib/x64")
FIND_PACKAGE(Boost REQUIRED COMPONENTS log)
FIND_PACKAGE(wxWidgets)
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
add_executable(chip8emu chip8emu.cpp chip8.cpp chip8.h "logger.h" "logger.cpp" "emuWindow.h" "emuWindow.cpp" "beeper.h" "beeper.cpp" "cApp.h" "cApp.cpp" "cMain.h" "cMain.cpp" )
target_link_libraries(chip8emu PRIVATE Boost::log_setup Boost::log ${SDL2_LIBRARY}/SDL2main.lib ${SDL2_LIBRARY}/SDL2.lib ${wxWidgets_LIB_DIR})
I can basically copy and paste this into each project directory (changing the add_executable() line).
There are positives and negatives to this approach, but I like it because it makes it easy to integrate libraries and it makes me less dependent on VS. This is a good tutorial to start with (although it looks intimidating, its pretty simple).
I've written a small library as a Qt project using Qt Creator, now I want to create a small GUI application that can be used to test it as part of the development process, so it could be like this:
Project root at:
~/code/mylib
Library project and associated code:
~/code/mylib/corelib/corelib.pro
GUI test tool and associated code:
~/code/mylib/libgui/guitool.pro
So far I've only been able to make things work by setting up LIBS+= in the GUI project's .pro file, manually building the library, copying the library's .a file to the GUI directory, and rebuilding the GUI project. A tedious process. Worse: I'm developing the project now on Linux but need to make it build on Linux and Windows, and this manual build style will probably make that harder.
I suppose there's a way to do make Qt Creator aware of the relationships between the projects, so for example building the GUI tool in debug mode use the debug version of the library, or making changes to the corelib would necessitate a build in the GUI, building on some OS would use the libraries OS-configuration...etc
This kind of thing is a couple of clicks away in Eclipse and Visual Studio, but I can't seem to get it working in QtCreator. I've tried "Add library->Internal library" and creating a 'subdirs' project but neither seems to work. I feel it's probably a simple step that I'm missing somewhere, any help?
Try again to use subdirs feature. It have own wizard "Project with subdirectories", but in your case it's easier to write it manually (in example I've added "ordered" to ensure that order of compilation is always correct).
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = corelib guitool
Than you can add libary to your GUI application with wizard (accessible from context menu inside .pro).
I'm using Xcode 3.2.1 on OSX 10.6.8, and I want to study how Avogadro works by debugging its source code. There is a CMake guide here:
https://web.archive.org/web/20160816105549/http://avogadro.cc/wiki/Compiling_on_Linux_and_Mac_OS_X
that explains how to do it (and the sources are provided), but I am not very familiar with debugging. How do I organize the source files into a new Xcode project and step through a compiled version?
Here is the git clone command:
git clone --recursive git://github.com/cryos/avogadro-squared.git
I spot a folder called /Users/Eric/Desktop/avogadro-squared/avogadro/avogadro/src but I'm unsure as to how to proceed with setting flags etc., since the project is originally compiled in Cmake.
I'm not familiar with Avogadro but I just downloaded the source. There are not any xcode projects that I could find. So if you want to use Xcode to debug it you will need to create the necessary projects. How do you do that? Well, Avogadro seems to be built up with several other sub modules, openqube, openbabel, and eigen in particular. So you will need to create xcode projects for them also (if they don't have them already.)
This is not a small job, you'll need to read the makefiles and see what libraries they need etc...
But, and this is the good news, once it is done you will have learn a lot about how Avogadro is built which will help you learn how Avogadro works, which was your goal.
And when you are done, you can then offer up your changes to the community, after all, that is what open source is all about, right?
Avogadro uses CMake, and CMake is a build system generator (part of the reason we chose it). So you can use its generator mechanism to request an Xcode build system. There is a general answer on StackOverflow to generate an Xcode project using CMake. You are looking at the superbuild which gathers/builds all dependencies - you really want to go into the avogadro subfolder and open that in Xcode.
I know how to build an existing Xcode project using xcodebuild, but I also need to generate Xcode projects from maybe a Python/Shell script. Is there any document somewhere that describes the process?
From personal experience generating xcode projects by hand is a pain; I've never seen a clear format defined anywhere, besides Apple keeps changing/adding stuff to it with each new version of Xcode.
I think the easiest way would be to use cmake/qmake or scons to generate your xcode project for you. For example, using cmake for this is pretty simple: you can have your script generate cmake makefiles, then run "cmake -G xcode" on those and it will create an xcode project for you. Also, since you mentioned python you could probably look into using scons for this purpose.
One possible way is to generate a project with Xcode and recreate the file hierarchy with your script.
I have a large exiting C++ project involving:
4 applications
50+ libraries
20+ third party libraries
It all builds fine on Windows using VS8, Linux using QMake (project uses Qt a lot). I also build it on OS X using QMake but I was wanting to setup an Xcode project to handle it in an IDE. I'm struggling to setup proper configuration to easily define dependencies, both to internal libraries and to the third party. I can do property sheets and .pri files in my (disturbed) sleep, but would appreciate some advice on building such large projects in Xcode.
I've been experiencing with Xcode configuration files and #including one from another but it does not seem to work as I would expect, especially when defining standard locations for header files etc.
Is there some good book describing the process of setting up Xcode (remember it's C++, I'm not wanting to learn ObjC at this time)?
Or maybe a good open source project I could learn from?
Thanks!
Step in to Xcode may be the book you're looking for. It's got a whole section devoted to using AppleScript to automate configuration includes. I've been going through the book myself on O'Reilly Safari as I've found myself in a situation similar to yourself!