Xcode 4 - clang error - iphone

I'm migrating from Xcode 3.5 to Xcode 4 and
while I'm trying to Archiving my app for AdHoc distribution.
I received this error
Precompile MyApp_Prefix.pch
ProcessPCH /Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/Build/PrecompiledHeaders/MyApp_Prefix-crxrbmeralwexyefvuwvzexquuin/MyApp_Prefix.pch.pth MyApp_Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/return/Projects/iphone-MyApp
setenv LANG en_US.US-ASCII
setenv PATH "/Xcode4.2/Platforms/iPhoneOS.platform/Developer/usr/bin:/Xcode4.2/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Xcode4.2/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -x objective-c-header -arch armv7 -fmessage-length=0 -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -DFAVOURITES_ENABLED=0 -isysroot /Xcode4.2/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=3.0 -iquote "/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/IntermediateBuildFilesPath/MyApp.build/Distribution-iphoneos/MyApp.build/MyApp-generated-files.hmap" "-I/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/IntermediateBuildFilesPath/MyApp.build/Distribution-iphoneos/MyApp.build/MyApp-own-target-headers.hmap" "-I/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/IntermediateBuildFilesPath/MyApp.build/Distribution-iphoneos/MyApp.build/MyApp-all-target-headers.hmap" -iquote "/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/IntermediateBuildFilesPath/MyApp.build/Distribution-iphoneos/MyApp.build/MyApp-project-headers.hmap" "-I/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/BuildProductsPath/Distribution-iphoneos/include" "-I”/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp" -I- "-IDistribution/BuildProductsPath/Distribution-iphoneos/../three20″" "-I“/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp" -I- "-IDistribution/BuildProductsPath/Distribution-iphoneos/../../three20″" -Ithree20/Build/Products/three20 -I/Xcode4.2/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/include/libxml2 "-I/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/IntermediateBuildFilesPath/MyApp.build/Distribution-iphoneos/MyApp.build/DerivedSources/armv7" "-I/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/IntermediateBuildFilesPath/MyApp.build/Distribution-iphoneos/MyApp.build/DerivedSources" "-F/Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/ArchiveIntermediates/MyApp - Distribution/BuildProductsPath/Distribution-iphoneos" -c /Users/return/Projects/iphone-MyApp/MyApp_Prefix.pch -o /Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/Build/PrecompiledHeaders/MyApp_Prefix-crxrbmeralwexyefvuwvzexquuin/MyApp_Prefix.pch.pth -MMD -MT dependencies -MF /Users/return/Library/Developer/Xcode/DerivedData/MyApp-cwtxjgdpsvtoyxcfpytllmzaxceb/Build/PrecompiledHeaders/MyApp_Prefix-crxrbmeralwexyefvuwvzexquuin/MyApp_Prefix.pch.d
**clang: error: '-I-' not supported, please use -iquote instead**
**Command /Xcode4.2/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1**
Do you know what I should do to fix this?
UPDATE (report result after followed MacMade's suggestions)
So in the Target Build Settings:
I have nothing in Other C flags.
I have nothing in User Header Search Paths
In Header Search Paths, I have:
”$(BUILT_PRODUCTS_DIR)/../three20″
“$(BUILT_PRODUCTS_DIR)/../../three20″
./three20/Build/Products/three20
/usr/include/libxml2
but I'm not sure what to change here.
In Compiler for C/C++/Objective-C setting,
I switched from Apple LLVM compiler to LLVM GCC and get this message:
cc1obj: note: obsolete option -I- used, please use -iquote instead
cc1obj: error: -I- specified twice
cc1obj: note: obsolete option -I- used, please use -iquote instead
UPDATE (report result after followed MacMade's updated suggestions)
So I move:
”$(BUILT_PRODUCTS_DIR)/../three20″
“$(BUILT_PRODUCTS_DIR)/../../three20″
to User Header Search Paths
and it works!!!
(NOTE: I don't move ./three20/Build/Products/three20 because I see
can't find <Three20/Three20.h>
errors while building the project if I do.)

Apparently, you've set custom compiler flags for the include paths.
Go to your target's build settings and check this option:
Other C flags
If you have something in it, you may replace it by the -iquote version.
Otherwise, still in the build settings, check the value of the following options:
Header Search Paths
User Header Search Paths
Try to manipulate these values, if applicable.
Otherwise, you may also continue to use GCC as a fronted, instead of Clang.
You can do this by setting the Compiler for C/C++/Objective-C build setting to LLVM GCC instead of Apple LLVM compiler.
EDIT
Based on your edit, I can see you are using the Three20 library.
Depending on how you include that stuff, you may want to put these search paths to the User Header Search Paths, instead of Header search paths (if you include them with "" instead of <>).
Try to do this for Three20, but leave libxml here...

I tried these solutions. But i couldn't or not working for me.
I solved this problem with this way:
I deleted MuseumTests in targets
When you clicked your project in general tab on left there is targets

You can solve this problem by selecting General tab of AppNameTests and select your app from the drop down list and enable "Allow testing Host Applications APIs"

I just had this problem with an instagram lib, my mistake was that i was importing the files to a target and compiled the other target. It gave me some headaches.

Hi guys we did something that worked...
We had the same problem and it was quite easy to solve...
First you go to terminal type cd
cd (drag the whole folder where your file is in) and press return
after you are inside the folder you have to write:
pod instal and type return
something like that....
Last login: Wed Aug 21 09:19:29 on console
WozMac1:~ KrisBasque$
WozMac1:~ KrisBasque$
WozMac1:~ KrisBasque$
WozMac1:~ KrisBasque$ cd
WozMac1:~ KrisBasque$ cd /Users/KrisBasque/Documents/QUADDRO/medapp
WozMac1:medapp KrisBasque$ pod install
Analyzing dependencies
CocoaPods 0.23.0 is available.
Downloading dependencies
Using AFNetworking (1.3.1)
Installing FMDB (2.1)
Using MBProgressHUD (0.7)
Using PSStackedView (1.0)
Using Reachability (3.1.1)
Installing SDWebImage (3.3)
Using TapkuLibrary (0.2.4)
Installing libwebp (0.3.0-rc7)
Generating Pods project
Integrating client project
WozMac1:medapp KrisBasque$

The way I solved this was my making sure no other implementation files we're linked to your file. Linking interface files is fine though

This error also caused by wrong header import.
For example your class is "yourclass.h", but in wrong way if you import "yourclass.m" it is cause this error.

Related

How to generate Xcode project using SPM with extra build flags?

I am creating a package that depends on OpenSSL on macOS. To use SPM to build the package, I need to pass it some build/linker flags:
swift build -Xlinker -L/usr/local/opt/openssl/lib -Xcc -I/usr/local/opt/openssl/include
The problem is that when I build my xcode project using SPM, I cannot pass the flags. In theory I would think the following would work,
swift package generate-xcodeproj -Xlinker -L/usr/local/opt/openssl/lib -Xcc -I/usr/local/opt/openssl/include
but it doesn't and once Xcode project is generated, to build in it, I need to go into the Settings and update the appropriate paths.
This is obviously ugly and also it wouldn't work for proper CI workflow, which depend on features that are currently only supported by xcode project and not SPM.
I have already tried passing these values when doing a command line xcodebuild like the following, but that also didn't work.
xcodebuild -project MyProj.xcodeproj -scheme MyProjScheme HEADER_SEARCH_PATHS=/usr/local/opt/openssl/include LIBRARY_SEARCH_PATHS=/usr/local/opt/openssl/lib build
Any suggestions?
To create an Xcode project with additional flags, we need to do the following 3 steps:
Step 1 - Obtain the proper mapping between compiler/linker flags and the equivalent xcode settings. In this case,
-Xlinker -L/usr/local/opt/openssl/lib -Xcc -I/usr/local/opt/openssl/include
is equivalent to
HEADER_SEARCH_PATHS=/usr/local/opt/openssl/include
LIBRARY_SEARCH_PATHS=/usr/local/opt/openssl/lib
Step 2 - Create an .xcconfig file. For example,
$ less openssl.xcconfig
HEADER_SEARCH_PATHS = /usr/local/opt/openssl/include
LIBRARY_SEARCH_PATHS = /usr/local/opt/openssl/lib
Step 3 - Use the --xcconfig-overrides flag with generate-xcodeproj to make the project use the config file.
swift package generate-xcodeproj --xcconfig-overrides openssl.xcconfig
Now the Xcode project builds out of the box and xcodebuild can be used without any extra flags.

gcc linker can't find library (openNI)

Can anybody give me some hints for solving this?
I'm trying to compile "Kinect Matlab" (on Mac OS 10.7), in the compile script is the following line:
mex('-v','-L/usr/lib/','-lOpenNI',[...],Filename);
This is the full command run by mex: (1)
gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011a.app/extern/lib/maci64/mexFunction.map -o "mxNiChangeDepthViewPoint.mexmaci64" mxNiChangeDepthViewPoint.o -L/usr/lib/ -lOpenNI -L/Applications/MATLAB_R2011a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
Then I'm getting the following error:
ld: library not found for -lOpenNI
collect2: ld returned 1 exit status
mex: link of ' "mxNiChangeDepthViewPoint.mexmaci64"' failed.
There is most definitely a file at /usr/lib/libOpenNI.dylib.
What kinds of things cause ld to throw this error?
What I tried:
I have tried creating a symlink called libOpenNI.so, like jmlopez suggested, no effect.
Could it be that libOpenNI is a 32bit library, and ld is not seeing it for that reason? Or would the error then be different?
Regarding the point above, it says that the build is "universal x86/x64"
Env vars:
I've tried to add the library to the environment variables using the following command, from the matlab terminal. No effect.
setenv('DYLD_LIBRARY_PATH', [getenv('DYLD_LIBRARY_PATH') ':/usr/lib/']);
In bash:
Just calling gcc as suggested here https://serverfault.com/questions/54736/how-to-check-if-a-library-is-installed gives no problems.
$ gcc -lOpenNi
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
However, if I run g++ first, then gcc as in (1), same error as before. (library not found). How come gcc can find the library, but when matlab adds the stuff in (1) it messes things up?
So, related to what is said above, I started removing all arguments from (1) until I got a different error. I removed the -Wl,-syslibroot, meaning that -syslibroot would no longer be passed to ld, this seems to have fixed it. So -syslibroot is messing up the library search directory! Now to find a way to remove this argument from the mex() call.
Did you trying adding OpenNi to your LIBRARY_PATH ?
export LIBRARY_PATH=$LIBRARY_PATH:/YOUR-PATH/OpenNi
First option: if libOpenNi isn't of the same architecture as the binary you're compiling, the whole compiler suite will likely ignore it. If you did manage to get it to link anyway, it would probably crash. Find a native 64 bit library and link against that.
Second option: I'm not 100% sure on this, but whenever I've tried doing linking on some esoteric linux projects, I start with a .a object archive in the path specified by -L. If it links, then I'll add -fPIC -shared on x86_64 to get it to compile against the shared library. I'm not sure if this will work on OSX: I've never done development on that platform yet.
BOOM! IT WORKS!
Okay, here it is:
The -Wl,-syslibroot option in the gcc call (1) is sending a -syslibroot option to the linker, and somehow that gets prepended to the library search path (even though it shouldn't according to cannot specify root sdk directory with syslibroot when linking)
So, removing this -syslibroot can solve our problem, this can be done in mexopts.sh. Copying matlab's version from the default location:
cp /Applications/MATLAB_R2011a.app/bin/mexopts.sh ~/.matlab/R2011a/
And then changing this line (201):
LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch $ARCHS -Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
Removing the -Wl,-syslibroot,$SDKROOT argument.
Additionally, I could remove the -L/usr/lib argument from the call to mex, making it simply:
mex('-v','-lOpenNI',['-I' OpenNiPathInclude],Filename);

Cross-compile libgcrypt for the iPhone? Linker error... can't seem to find "fwrite" and "strerror"?

I have successfully cross-compiled the Apache Portable Runtime (APR) for the iPhone, using a set of configure scripts that invoke the GNU Autotools "./configure" with the necessary cross-compilation options.
I am now attempting to cross-compile GNUTLS which depends on libtasn1 and on libgcrypt, which in turn, depends on libgpg-error. This is where I am running into trouble and could use your help...
I am currently trying to cross-compile libgpg-error. The configure scripts that I used before are working beautifully; the "./configure" process completes cleanly. The problems occur when I run "make". When I run make, everything seems to compile, but then I get the following nasty linker error at the end:
/bin/sh ../libtool --tag=CC --mode=link /Users/michaelsafyan/Downloads/libgpg-error-1.7/compile /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk' -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include -isystem /Developer/Platforms/iPhoneOS.platform/Developer/usr/include -isystem /opt/iphone-3.0/include -isystem /usr/local/iphone-3.0/include -arch armv6 --sysroot='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk' -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -L/opt/iphone-3.0/lib -L/usr/local/iphone-3.0/lib -o gpg-error gpg_error-strsource-sym.o gpg_error-strerror-sym.o gpg_error-gpg-error.o ./libgpg-error.la
/Users/michaelsafyan/Downloads/libgpg-error-1.7/compile /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include -isystem /Developer/Platforms/iPhoneOS.platform/Developer/usr/include -isystem /opt/iphone-3.0/include -isystem /usr/local/iphone-3.0/include -arch armv6 --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -o gpg-error gpg_error-strsource-sym.o gpg_error-strerror-sym.o gpg_error-gpg-error.o -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -L/opt/iphone-3.0/lib -L/usr/local/iphone-3.0/lib ./.libs/libgpg-error.a
Undefined symbols:
"_fwrite$UNIX2003", referenced from:
_main in gpg_error-gpg-error.o
"_strerror$UNIX2003", referenced from:
_gpg_strerror in libgpg-error.a(libgpg_error_la-strerror.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [gpg-error] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Any ideas on how to get this to work? The versions of the software that I am compiling are:
libgpg-error: 1.7
libgcrypt: 1.4.4
libtasn1: 2.2
gnutls: 2.8.4
Please help. Thank you.
Update
As per initial feedback, each SDK has a copy of "libSystem.dylib" in "$SDKROOT/usr/lib". There is no copy of libSystem in "$DEVROOT/usr/lib", where:
$DEVROOT = "/Developer/Platforms/iPhoneOS.platform/Developer"
$SDKROOT = "$DEVROOT/SDKs/iPhoneOS$VER.sdk"
The "libSystem" libraries contain the ordinary, undecorated versions, of each symbol, but do not contain the "$UNIX2003" variants of the symbols. I suspect that GPG-ERROR is defining "_POSIX_C_SOURCE", "_UNIX", or another UNIX feature test macro, and that a rogue header that is appending "$UNIX2003" to the functions when these feature test macros are present is being included. Removing "$DEVROOT/usr/include" from the list of include directories has no effect with regard to removing this error message.
As a last resort, I see that "ld" accepts an "-alias_list" option that allows one to specify a file with entries like "_fwrite _fwrite$UNIX2003" to forcibly resolve these undefined symbols to their undecorated variants. If possible, I would like to avoid this option, since it seems hackish and potentially dangerous.
Usually an unresolved symbol$UNIX2003 means that you're linking against an older SDK than the one the existing object files were built against.
One strange looking include path to me, and please note that I'm only vaguely familiar with Mac developement and not at all with iPhone developement, is the path
/Developer/Platforms/iPhoneOS.platform/Developer/usr/include
which is not actually in the SDK folder. Is it possible that you've picked up the rogue symbols, if they are that, from there? Seems unlikely since it occurs later in the command line than the SDK include paths.
Perhaps instead the symbols are the expected versions of _fwrite and _strerror and so gpg_error-gpg-error.o and libgpg-error.a are okay and it's really a linking issue although again unlikely as you have
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib
as a -L option. I'm assuming there's a libSystem dylib in there somewhere?
I guess the first thing to do is ascertain whether the UNIX2003 version of the symbol is what you expect or not. My guess is it is, but as I say I could be completely wrong. :)
Secondly you could try getting verbose output from ld to see where it is finding symbols. I'm sure there is an environment variable you can set to make this happen but I can't see any listed in the on-line man page for ld. (Update: The two env variables are LD_TRACE_ARCHIVES and LD_TRACE_DYLIBS but perhaps they give the same as -t?).
Edit:
OK, so I was completely wrong about the UNIX2003 symbols being the ones that were required. lol.
When you built libgpg-error I think it will have created a file
src/.deps/gpg_error-gpg-error.Po
which contains header dependencies (at least it did on my Linux system). This might give a clue as to where it picked up the wrong header when building gpg_error-gpg-error.o.
BTW, it looks as if the libgpg-error configure script accepts both an -isysroot and -archoptions. Can you not use those instead of your own version of the configure script?
Edit2:
Okay, let's have another go :) Here are some things to try, starting from a clean source folder:
use -isysroot instead of --sysroot
use -isysroot as well as --sysroot
temporarily make your normal system headers unavailable by, for example, renaming the folder. Hopefully the build will fall over failing to find a header and it'll tell you exactly where.
Try to preprocess gpg_error-gpg-error.c with -E then search the missing symbols. You should find from where there are inclued (something like asm ("_" "nice" "#UNIX2003").
Then, modify this header (unistd.h for example to add a #warning "HERE").
Now, recompile, and you should find the include stack.
The $2003 suffix is generated by the compiler under some circumstances which you can find fully documented in the manual entry for compat
man compat
I wrestled with this for some time before finally fixing it by setting
-mmacosx-version-min=10.3
Any version prior to 10.4 will do the job. I suspect that given Troubadour's answer I may be better off searching for erroneously linked libraries using the -t option of ld
Hope this helps.

iPhone SDK 3 EXC_BAD_ACCESS with openldap library

Hope someone can help me,
I am trying to build openldap for an app on my iPhoneOS3 but when I try to use something from the library I get this error :
Program received signal: “EXC_
BAD_ACCESS”.
I followed this website to compile openldap with iphone gcc.
So I built openldap with this :
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.0.sdk
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/
-I$SDKROOT/usr/include/ -I/usr/local/BerkeleyDB.4.7/include/"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="/usr/bin/cpp $CPPFLAGS"
export LDFLAGS="-L$SDKROOT/usr/lib/ -L/usr/local/BerkeleyDB.4.7/lib/"
./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.2.1 \
LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin --with-yielding_select=yes
make depend
make
I copied libldap.a, liblber.a to my project and all headers as ldap.h ....
In project settings I have :
Header Search Path : /path/to/openldap/headers
Library Search Path : filled with path from libldap.a and liblber.a
Other Linker Flags : -lldap -llber -ObjC
Everything is fine when it builds but I get the error above with the following code :
LDAP **ld;
ldap_initialize(ld, "ldap://myldap.exemple.com");
Does someone have any idea what I can do ?
Thank you
I think I made a mistake in my post, you should try to change
this line :
export LDFLAGS="-L$SDKROOT/usr/lib/ -L/usr/local/BerkeleyDB.4.7/include/"
by this one :
export LDFLAGS="-L$SDKROOT/usr/lib/ -L/usr/local/BerkeleyDB.4.7/lib/"
Sorry for my Mistake
Léon
Yes, I made it work so I will try to help you.
Here the commands line that I used to set all flasgs.
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS2.2.sdk
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$SDKROOT/usr/include/ -I/usr/local/BerkeleyDB.4.7/include/"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="/usr/bin/cpp $CPPFLAGS"
export LDFLAGS="-L$SDKROOT/usr/lib/ -L/usr/local/BerkeleyDB.4.7/lib/"
So I needed to build BerkeleyDB, my version is 4.7.25.
./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin
make
make install
And finally I built openldap like this :
./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin --with-yielding_select=yes --enable-dynamic=yes --enable-modules=no --enable-static=yes --disable-shared --enable-ldap=yes && make depend && make
May be you did the same, if not try those commands. I know I used gcc 4.0.1 instead of 4.2.1 the one of iPhone OS 3 but I was wedged cause when I was trying to build only a static library it wasn't working properly when I was building my project. (a lot of errors)
After I built openldap, I made a new project
add in Header Search Path with the openldap include in Project Settings.
I copied both library into the ressource folder of my project : libldap.a and liblber.a
I filled Other Linker Flags with "-ObjC -lldap -llber"
Hope that can help you.

iPhone static library distribution and release build errors (but not for debug)

Update
Daniel was close, it just wasn't the search path. The Prefix Header under GCC 4.2 was set to:
$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h
I missed that when I was combing through the first 2 times.
I removed it and now all is well.
Original Question
I have been using/building products with a static libraries for about a week now with no issues.
For the first time, I tried to make a distribution build (for ad hoc testing) and I am getting errors all over the place.
The errors, strangely say that it can't find Appkit headers. Which is odd because it is an iPhone app and shouldn't be linking to Appkit headers
Additionally, the library name, "libFJSCodeDebug.a" turns red while when I switch from debug to distribution/release. I figure this must be a big clue.
To test, I duplicated the debug configuration and renamed it release. This built fine. So it seems the problem is somewhere in the configuration. Below is a snippet of what I get in Xcode when I build. (Note: I named my target FJSCodeDebug even though it will be used for both debug and release builds)
Building target “FJSCodeDebug” of project “FJSCode” with configuration “Release” — (169 errors)
Checking Dependencies
cd /[redacted]/FJSCode
setenv PATH "/DeveloperBeta/Platforms/iPhoneOS.platform/Developer/usr/bin:/DeveloperBeta/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/DeveloperBeta/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -x objective-c-header -arch armv6 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -Wreturn-type -Wunused-variable -isysroot /DeveloperBeta/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -gdwarf-2 -mthumb -miphoneos-version-min=3.0 -iquote /[redacted]/build/FJSCode.build/Release-iphoneos/FJSCodeDebug.build/FJSCodeDebug-generated-files.hmap -I/[redacted]/build/FJSCode.build/Release-iphoneos/FJSCodeDebug.build/FJSCodeDebug-own-target-headers.hmap -I/[redacted]/build/FJSCode.build/Release-iphoneos/FJSCodeDebug.build/FJSCodeDebug-all-target-headers.hmap -iquote /U[redacted]/build/FJSCode.build/Release-iphoneos/FJSCodeDebug.build/FJSCodeDebug-project-headers.hmap -F/[redacted]/build/Release-iphoneos -I/[redacted]/build/Release-iphoneos/include -I/Users/coreyfloyd/Xcode/ProductionProjects/build/FJSCode.build/Release-iphoneos/FJSCodeDebug.build/DerivedSources/armv6 -I/[redacted]/build/FJSCode.build/Release-iphoneos/FJSCodeDebug.build/DerivedSources -c /System/Library/Frameworks/AppKit.framework/Headers/AppKit.h -o /var/folders/R+/R+ofDLtuH1GOYQ1ZQ2C5mk+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/AppKit-gihvhjsfuggoevbehiszhgrzcska/AppKit.h.gch
/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:11:33: error: AppKit/AppKitDefines.h: No such file or directory
/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:12:32: error: AppKit/AppKitErrors.h: No such file or directory
/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:13:37: error: AppKit/NSGraphicsContext.h: No such file or directory
/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:14:35: error: AppKit/NSAccessibility.h: No such file or directory
/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:15:32: error: AppKit/NSActionCell.h: No such file or directory
...... (continues for everything in AppKit)......
Build failed (169 errors)
I'm looking for 1 of 2 solutions:
Obviously, fix the release build to not get these errors
OR
Tweak the debug configuration to have all the important settings that a release configuration requires.
Any ideas??
This
-c /System/Library/Frameworks/AppKit.framework/Headers/AppKit.h
leads me to believe your build target is trying to compile AppKit.h for some reason (while I don't think it should be doing that at all), and/or it's looking for it in the wrong place (i.e. in the root /System instead of in the SDK /Developer/Platforms/...).
You should double check your build settings library/frameworks search paths, and that AppKit.h isn't in the compile phase.
Does your project include Mac OS products? Are you sure you haven't accidently included a Mac library/framework in your frameworks group?
In SDK2.2.1, I don't know why, but the thing that always gets me is when "Active SDK" and "Active Executable" become out of sync (in the build configuration dropdown). This leads to weird linker errors where the iPhone tries to dynamically link against its libraries. This setting seems to occasionally go out of sync whenever I switch from debug/release or device/simulator.
Perhaps its a similar case, its hard to tell without seeing the actual project settings.