Library not found when building distribution config in xcode 4 - xcode

I have a minor problem. Whenever I try to build my project using the distribution configuration it complains that one of my libraries is missing
ld: library not found for -lTouchCustoms
This only appears in distribution mode. The only difference between the release and distribution build is in the code signing section. Because of this I had to use the release build (with distribution profile code signing) to publish my app because that builds correctly, and was acceppted. If I delete and recreate the distribution config, duplicating the release config, I get the same error. How do I solve this? Thanks.

The problem is that the static library doesn't have the "distribution" build configuration. It will default to building the Release configuration instead. When the linker is trying to bring everything together, it is unfortunately looking in the "distribution-iphoneos" folder for the library while the library is actually in the "Release-iphoneos" library.
I'm trying to find a general solution for this issue in this question. For you and others it should suffice to simply add the same configuration to all static libraries you're linking against as well.

Related

Should Project References be avoided between C++ projects?

Our large C++ solution has a lot of project references between different projects and it seems to cause problems, most commonly it will try to link the wrong version of the dependency e.g. You'll build Project in release and get an error about missing library dependency_d.lib. Especially if you are using multiple build configurations.
Are project references considered bad practice working in C++ and developers should stick with the old way (#include directories and libraries listed in project settings)? Or does this simply suggest they've been set up wrong in our solution?
In our team we use #include despite of using vcpkg for the most libraries.
But you can set up different dependencies for each build configuration (Debug, Release etc.): just select desired Configuration at the top if the Project properties window. Your dependency _d .lib seems to be a Debug library.
I think there are some problems in your config. Also I haven't heard anything about project references are bad practice.

Adding a google test framework to existing Xcode project

I use this instruction and CMake tool. When I built XCode project created by CMake I had 2 .dylib files. When I add this tow libs and gtest_main.cc and gtest_all.cc in my existing project, compiler don't see #include "gtest/gtest.h" header.
How do I need to add google test to existing XCode project?
So, I just set the build parameters of my project's test target, as in the examples for gtest, and it works.
Sorry for the stupid question

MSVC C2859 when using a different build configuration of another project as a library

I have a fairly large multi-project C++ solution in Visual Studio 2015. Some of the projects compile to static libraries which are used by other projects, and most of them use precompiled headers to speed up compilation. Each project also has multiple build configurations: debug, release, and several testing configurations which always build an executable to run the tests (even if the normal configurations build a static library).
When building debug and release configurations, or when doing a full rebuild, everything works well, but when doing an incremental build of a test configuration for a project that uses another project's static library, I get C2859 errors which cause the build to fail.
For example, let's say I have a project peach which builds a static library, and a project cobbler that relies on peach. The precompiled header for cobbler references only system and external libraries (no headers from inside the solution). cobbler's test configuration references peach.lib. peach.lib is created by peach's release configuration, so I have a solution configuration called cobbler-test which specifies that:
peach uses its release project configuration
cobbler uses its test project configuration.
Building cobbler-test from scratch (or rebuilding it, clean & build, etc) works fine. But if I then modify a source file called crust.cpp in cobbler and try to build, I get this error:
c:\...\cobbler\src\crust.cpp(1): error C2859: C:\...\out\cobbler-test.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.
Again, this only happens when referencing a static library from the same solution that was built with a project configuration name different from the current one. With both projects using release or debug, incremental builds work fine.
Having to do a full rebuild every time defeats the purpose of using precompiled headers in the first place. Is there any way to get incremental testing configurations to work without having to resort to creating extra project configurations for every combination of projects?
My current solution to this problem is not to use testing configurations, and to create separate projects for testing projects that generate static libraries. This allows all dependent projects to use the same project configuration and allows the precompiled headers to work their magic without blowing up when doing incremental builds.
While this works fairly well for the static libraries, since they can easily be imported with #pragma comment(lib, ...), it's a bit more problematic for projects that build standalone executables. Thankfully, in my case most of those projects don't have a lot of stuff that needs testing.

Target dependencies vs. Link binary with libraries

I don't understand the difference between these Xcode features.
I'm building and app - but the functionality of the app is being abstracted into libraries (so they can be distributed separately as an "SDK").
So I have a workspace of library projects and the app project. I can add library projects to the app project by doing "link binary with libraries". This gives me a list of .a library projects in the current workspace which I can link to.
I can also add frameworks here.
In the "target dependencies" bit all I can add is other targets in the current project.
What I really want to do is both - I want my app project to build all the other library projects when I build it. I also want to make it verbose what libraries the app (and other libraries) depend on.
So can somebody please explain the difference, and whether what I am doing is the right way to go about it?
Many thanks!
It says here...
Drag your framework product (located in the Products folder) to the existing Link Binary With Libraries build phase of your application
target. This causes the application to link against your framework.
And...
In the General tab of the inspector window, add your framework as a dependency for the application. Adding this dependency causes Xcode to
build the framework target before building the application target.
The build dependency you establish in the application target causes
the framework to be built before the application. This is important
because it guarantees that a built version of your framework will be
available to link against and to embed in the application. Because of
this dependency, you can set the active target of your Xcode project
to your application and leave it there.
So it seems that you're supposed to use both. Seems redundant though, because if you're linking to a framework then its a dependency. I suppose you might want to only link to a library and not build it first. Although Xcode seems to build linked libraries even without them being added to the dependency section. Perhaps that's a result of the "Find Implicit Dependencies" option in a scheme's build settings.
I do something similar and was explicitly setting the 'header search path' and 'library search path' in the final executable target. However this all depended on where the objects were being generated. Initially I had set this to be within the source tree (actually a sibling directory called build), however after changing the location of the Xcode DerivedData directory and telling it to build into that directory, the projects no longer built.
The final solution was simply to remove the explicit setting of the 'header/library search path' and set the target dependencies correctly. This resulted in the project building for debugging and archiving without issue.

XCODE 4.3.1 and libcrypto.a and libsqlcipher.a, building debug and release

Have added the Xcode Projects for openssl.xcodeproj and sqlcipher.xcodeproj in a current project and if I build for RELEASE, everything is ok. If I build for DEBUG, the linked does not seem to be able to resolve / find the libsqlcipher.a file. I have taken the two project out of the main project and built by hand in RELEASE / DEBUG and generated the lib files, but if I set the main project to DEBUG, it still will not resolve even though the lib files are added to the link list.
Why would the linker have problems resolving the entry points when the main project is set to DEBUG?
Had to fool with the two projets to make sure that armv6 AND armv7 were present along with valid architectures and the correct base sdk.

Resources