Xcode 4 not using new builds - build

I've been using Xcode 4 for the last two weeks now, and I'm a little frustrated having to do a clean (shft+cmd+K) every time I change a single line of code before building (cmd+B) and running (cmd+R) again.
In previous versions of Xcode, rebuilding was enough for the simulator to use the latest build.
Am I doing it wrong? A lot of things have really improved but I can't get the hang of this "build and run flow".

Are your library files appearing in red (missing)?
Build the project once for your iOS device, then add the .a to the Link Binary With Libraries again. Now the .a will appear as normal (not red - missing).
Now every time you build/run the project in the simulator, the libraries/subprojects will be build too.
I've had the same problem.

Related

How to set up wxWidgets 3.1.0 with Visual Studio 2015

I am somewhat of a beginner when it comes to open source libraries. I have tried to compile from source and use the pre-built binaries, but in both cases I get a ton of errors when I try to run the simple 'Hello World' program on the tutorial section of the wxWidgets website. After playing around for quite some time, the closest I have got to compiling is by building the libraries from source, but I still have 2 errors remaining:
"_w64 can only be specified on int, long, and pointer types" file: defs.h
"cannot open file 'wxbase31ud.lib" - LINK
It seems strange to me that the header file provided by wx would have an error such as that one, so I imagine both errors are because of something I am doing. I am hoping that someone here can do one of the following for me:
Help me solve these errors
Provide instructions for building libraries from source and subsequently linking my program to the correct directories
Some additional info: I am working on x64 Windows 7, my target will also be x64 exclusively. I do not have admin privileges, so no editing the system PATH for me.
Thanks for your help!
The simplest way to start working with the library is this:
Grab the sources.
Unpack the sources.
Open VS IDE.
Open \build\msw\wx-vc14.sln (adjust as necessary.)
Go to "Build->Batch Build...", click "Select All", "Build".
Go drink some coffee or watch TV.
After the build finishes, open wxWidgets/samples/minimal/minimal_vc9.sln.
Let MSVC convert the solution to become an appropriate format.
Build and run the sample.
If you will acquire any issue during those steps, let us know.
The library build in step 5 should build without any issues and then all you will need is to build the minimal sample.
The next step is to copy the samples\minimal folder somewhere and start writing the code. All you will need to do is to change the Include and Lib search path.
[EDIT]
If you can build the 32-bit libraries (which are default in the provided solutions) all you will need is to convert them to be 64-bit and rebuild.
There is no changes to the $PATH or any environmental variable involved. Moreover you shouldn't build anything with the admin priviledges.
Also as Thomas pointed out you library build has to match whatever sample you are trying to build.
[/EDIT]

VS2015 linker looking for old, nowhere mentioned files

I'm working on a project(game engine) which has a solution with 11 projects(VS projects) in it, 10 of which are static libraries (.lib) and one is an executable (.exe). I'm working on in only from 2 computers - the one at home, and the one at work, both using Visual Studio 2015 Community. The one at home works perfectly well, but the one at work has an issue - when I build the solution the linker is always looking for a "corelib.lib" file. That file existed some time ago, but at some point I starting switching too often between release and debug and I made a new convention to ease the pain of compilation time - now my files are called: corelib_vc14_dbg.lib and corelib_vc14_rls.lib (for debug and release respectively). No matter what I do, the linker always looks for this file. I tried cleaning the solution, I tried full clean up of the svn copy, I tried a fresh checkout, I tried moving the svn copy to another location. I tried looking for "corelib.lib" in the directory (multiple times, using Sublime and Notepad++), and I had zero hits. Files like ".sdf", ".suo", ".user" are not versioned. Object files, libraries, executables and so on, are also excluded from the svn, so there can't be any cached values there (if there should be any). What could be causing the problem? Does Visual Studio cache something like that anywhere? And if so - why couldn't I find it anywhere?
Here are the dependencies of the failing project:
Debug:
AdditionalDependencies>openal.lib;opengl32.lib;engine_vc14_dbg.lib;corelib_vc14_dbg.lib;glfw_vc14_dbg.lib;glew_vc14_dbg.lib;gorilla_vc14_dbg.lib;jsoncpp_vc14_dbg.lib;%(AdditionalDependencies)</AdditionalDependencies>
Release
<AdditionalDependencies>openal.lib;opengl32.lib;engine_vc14_rls.lib;corelib_vc14_rls.lib;glfw_vc14_rls.lib;glew_vc14_rls.lib;gorilla_vc14_rls.lib;jsoncpp_vc14_rls.lib;%(AdditionalDependencies)</AdditionalDependencies>
All .lib files are exported correctly with their new names (example: "corelib_vc14_dbg.lib"), but the linker still looks for the old library file "corelib.lib"
I resolved my problem. It was somewhere I never expected it to be - when I moved from VS2013 to VS2015 some references to the old projects have been left out and were causing this strange issue. Thankfully I keep my project folders organized, so I looked through everything in the trunk for "vs2013" and found a bunch of occurances, replaced them manually with "vs2015" and everything worked fine :)

How to build standalone SDL project with visual C++?

I'm getting ready to enter Ludum Dare this evening, and I'm getting really frustrated because I'm unable to build my project into a standalone .exe.
I feel like this question has been asked at least 100 times but none of the answers I'm finding are helping me out at all... I don't really understand what static linking is or how to do it, and that doesn't even seem like the solution to my problem; I don't mind if I'm shipping out a bunch of .dll files with my program, I just want the program to run on its own so I can submit it at the end of the competition.
Basically, my visual studio (2010 express) configuration follows exactly LazyFoo's tutorial on setting it up. Everything runs fine on both debug and release configurations when I start the program from visual studio, but when I navigate into the Debug or Release folders of the project and try to run the .exe, the programs break with an error about abort() being called, or they give me the error "X program has stopped working."
I'm including all of my DLLs in the same folder as the executables are being placed, and the game runs perfectly fine from inside VS, but I just can't seem how to figure out how to compile it as a standalone .exe (or even including a folder full of dlls) without it falling apart.
Can someone give me a pretty precise way to get this working? Any help would be great.
If you have an EXE, then your program is compiling. Most likely in debug mode, the program is running using a specific directory as the current working directory (CWD), but when you run it as standalone, the CWD is different.
The CWD affects both the DLL that can be loaded as well as the search of any file that uses a relative path (that is, not starting with a [back]slash). That is probably your problem: textures, graphics, configuration files, fonts...
My advise is to set the CWD in the debugging runs (there is an option for that) to be exactly the same than that of the EXE, that is the default when you run the EXE. Then you will be able to debug your crash.

Compile for release

I was writing a simple pong application and while its not finished I'd lie to be able to figure out how to compile it for release. I get no errors and i linked against SDL, SDLmain,SDL_image,SDL_ttf but when people on other computers try to run it (both the debug and release) it closes as if it's missing files. I put SDL.dll,SDL_image.dll, SDL-ttf.dll all in there along with the images i use in the program, it works fine on my computer so that says theres a file I'm missing for it...but what would that be?
EDIT:
Finally after 30 minutes i figured it out: when including SDL_image.dll you also have to include SDL_image.dll's dependencies : zlib1.dll,libjjpeg-x.dll,libpng..etc
A good way to solve this sort of problem (if it's DLL related) is to use Dependency Walker. This will show you all the dependencies of an executable, and the dependencies of the dependencies.
If you run it on the target platform, it will highlight DLLs that are required but not available, making it easier to see why your executable won't run.

Import existing C++ project into Xcode IDE

I am trying to open an existing C++ open-source library in Xcode to publish it with my own modification/additions. The library is Tesseract-OCR, which does not include a .xcodeproj file.
Since Xcode can function as an IDE, is it possible to open a bunch of files as a single project in Xcode? Is there an easy way to produce an Xcode project?
There are several ways you could do it, depending on the level of IDE integration you want. There's no direct way of importing a Makefile-based project into Xcode. You can create a project that builds via the Makefile, but you wouldn't get many of the benefits of using an IDE, since the editor features such as word completion rely on Xcode being able to parse the files in the project. You will be able to use the debugger though. To do this, create a new project and add a custom target with a script build phase that just calls down to Makefile.
If however the project you're building compiles very easily, ie without requiring a lot of macros to be set up, include paths, etc, then it may be simple to just create an empty project and merely add all source files to it. I've used this method extensively for building boost libraries. If this is a configure && make type project then you will probably have to run the configure step first, and ensure any top level config.h files are included in the project.
If the project has a complex makefile then it is likely to be an involved task to create a useful Xcode project
I realise you asked explicitly for Xcode, but in case you were actually trying to solve the problem of "I have existing C++ code which builds and runs fine from the command line, and I'd like to code and debug it in an IDE, what should I do?" my firm recommendation would be to avoid Xcode and go for Eclipse.
The reason is that as far as I can tell, Xcode has no way of ingesting the command line build environment and effectively requires you to recreate the make process inside Xcode from scratch. Fine for tiny projects, but anything with more than a few source files and it quickly becomes painful. Whereas in Eclipse everything is built around Makefiles. So in my case I got to the "step through code with working code completion" in Eclipse a lot quicker vs. never in Xcode. This of course could be because I'm an Xcode noob, but my 2c.
To create an Xcode project from an existing cmake project, you can run cmake -G Xcode. It produces some folders and files apart from the project file, so it might be better to create a folder for it first. For example:
mkdir -p build/xcode
cd build/xcode
cmake -G Xcode ../..
Xcode is a useable IDE for library creation.
Of course a good first step is to see if the one source code will build on its own with configure scripts that are included.
If not, it becomes a question of how many libraries you need to link in.
There are resources online (or at least there used to be) for using Xcode (or perhaps it's forerunner Product builder) for porting Unix projects to Mac.
Good tutorial at: http://www.macresearch.org/tutorial-introducing-xcode-30-organizer
Another good reference is Darwin Ports.
As for doing this on your own. You can build c++ based libraries in XCode. People do that every day. You can even use one of the Xcode templates to get you started.
However, library dev requires more experience with Xcode then say a simple Cocoa "Hello World" app.
The remaining questions will be assuring that the source code's dependencies are already built into the Mac's SDK. (Don't hold your breath for linking to MFC)
It's a general question... So it's a general answer.
In Xcode8,there is "Xcode->file->add files to...",then choose your files.If you want to add several files at a time,press "Cmd" when you are choosing.