I'm trying to move my app to 64 bit arm processors (and 64 bit simulator), and for that I need to recompile the ICU library (49).
After three days I reached the point where the library compiles fine, and the script I'm using puts together various architectures into one (snippet):
# ...
#x86_64
DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
SDKROOT=$DEVROOT/SDKs/iPhoneSimulator7.0.sdk
SYSROOT=$SDKROOT
export CFLAGS="-I$SDKROOT/usr/include/ -I./include/ $ICU_FLAGS -arch x86_64 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=7.0 -O3 -DU_HAVE_GCC_ATOMICS=0"
export CXXFLAGS="$CFLAGS"
export CC="$TOOLCHAINSROOT/usr/bin/clang"
export CXX="$TOOLCHAINSROOT/usr/bin/clang++"
export LDFLAGS="-L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip -miphoneos-version-min=7.0"
mkdir -p $BUILDDIR/iosbuild/x86_64
cd $BUILDDIR/iosbuild/x86_64
gnumake clean
sh $ICU_PATH/source/configure --host=arm-apple-darwin --enable-static --disable-shared -with-cross-build=$BUILDDIR/hostbuild --prefix=$BUILDDIR/iosbuild/x86_64 --with-data-packaging=library
gnumake
gnumake clean install
# ...
#x86_64
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicudata
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicudata
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicudata.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicui18n
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicui18n
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicui18n.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicuio
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicuio
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicuio.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicule
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicule
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicule.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libiculx
cd ${BUILDDIR}/iosbuild/x86_64/lib/libiculx
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libiculx.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicutest
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicutest
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicutest.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicutu
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicutu
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicutu.a"
mkdir -p ${BUILDDIR}/iosbuild/x86_64/lib/libicuuc
cd ${BUILDDIR}/iosbuild/x86_64/lib/libicuuc
ar -x "${BUILDDIR}/iosbuild/x86_64/lib/libicuuc.a"
ar -qc ${BUILDDIR}/iosbuild/x86_64/lib/libcombinedicu.a ${BUILDDIR}/iosbuild/x86_64/lib/libicudata/*.o ${BUILDDIR}/iosbuild/x86_64/lib/libicudata/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicuuc/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicui18n/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicuio/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicule/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libiculx/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicutest/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicutu/*.ao ${BUILDDIR}/iosbuild/x86_64/lib/libicuuc/*.ao
# ...
#put them together
lipo -create -arch x86_64 "${BUILDDIR}/iosbuild/x86_64/lib/libcombinedicu.a"
-arch i386 "${BUILDDIR}/iosbuild/i386/lib/libcombinedicu.a"
"${BUILDDIR}/iosbuild/arm64/lib/libcombinedicu.a"
"${BUILDDIR}/iosbuild/armv7s/lib/libcombinedicu.a"
-arch armv7 "${BUILDDIR}/iosbuild/armv7/lib/libcombinedicu.a"
-o "$FRAMEWORK_DIR/Versions/Current/$FRAMEWORK_NAME"
The problem is, when I'm compiling the app from XCode (for the 64 bit simulator), I get the following errors regarding the built ICU framework:
ld: warning: directory not found for option '-F"/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxPro/../BIMxEngine/extern/icu"'
duplicate symbol _OSAtomicIncrement32 in:
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(unistr.ao)
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(mutex.ao)
duplicate symbol _OSAtomicIncrement32Barrier in:
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(unistr.ao)
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(mutex.ao)
duplicate symbol _OSAtomicDecrement32 in:
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(unistr.ao)
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(mutex.ao)
duplicate symbol _OSAtomicDecrement32Barrier in:
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(unistr.ao)
/Users/gliptak/ac/m-220/Sources/VBExplorer/BIMxEngine/extern/icu/ICU.framework/ICU(mutex.ao)
...
ld: 64 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
As far as I can tell the mentioned functions are declared in system headers, and are not inline, so how can this error exist?
Do you have any ideas what I might do wrong?
UPDATE: indeed, those functions are static inline, so they cause the problem. So the question is now how do I avoid duplication?
UPDATE: tried the -std=gnu89 flag for the C compiler, no effect...
Found a solution here (confirmed working building on/for Mavericks). Could also be resolved using SVN trunk of icu4c, since that uses C++11 barriers instead.
Related
Does anyone have any experience getting LibCurl working on iPhone OS? Any Tutorials or sample code available for getting understand all thing related to cURL for iOS Development.
You can find a sample application and static libaries at:
http://seiryu.home.comcast.net/~seiryu/libcurl-ios.html
i wasn't able to build a working xcode project to compile my own framework, so i wrote a bash script
CurlVersion="7.29.0"
export IPHONEOS_DEPLOYMENT_TARGET="4.3"
otherBuildFlags="--with-darwinssl"
rm -rf results
rm -rf Products/libcurl.framework/Versions/$CurlVersion
mkdir -p results/iOS
mkdir -p results/Sim
make clean
export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2"
export CFLAGS="-arch armv7 -arch armv7s -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
export LDFLAGS="-arch armv7 -arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk"
./configure --disable-shared --enable-static --disable-dependency-tracking --host="armv7-apple-darwin" --host="armv7s-apple-darwin" $otherBuildFlags
make -j `sysctl -n hw.logicalcpu_max`
cp lib/.libs/* results/iOS/
make clean
export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2"
export CFLAGS="-arch i386 -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk"
export CPPFLAGS="-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IPHONEOS_DEPLOYMENT_TARGET%%.*}0000"
export LDFLAGS="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk"
./configure --disable-shared --enable-static --host="i386-apple-darwin" $otherBuildFlags
make -j `sysctl -n hw.logicalcpu_max`
cp lib/.libs/* results/Sim/
lipo -create results/iOS/libcurl.a results/Sim/libcurl.a -output results/libcurl.a
mkdir -p Products/libcurl.framework/Versions/$CurlVersion/Headers
mkdir -p Products/libcurl.framework/Versions/$CurlVersion/Resources
cp include/curl/*.h Products/libcurl.framework/Versions/$CurlVersion/Headers/
cp results/libcurl.a Products/libcurl.framework/Versions/$CurlVersion/
cd Products/libcurl.framework/Versions/
ln -fs $CurlVersion Current
cd ..
ln -fs Versions/Current/libcurl.a libcurl
ln -fs Versions/Current/Headers .
ln -fs Versions/Current/Resources .
I have been receiving this error for a long time and I don't know what to do.
In order to keep the question short, I have written the error into a .rtf file and put it into CloudApp. Here's the link: http://cl.ly/0T3n1Q123u352T372t0m
I think it has something to do with "CLAPIDeserializer.m".
I will appreciate any help. Thank you.
ERROR:
CompileC
/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Objects-normal/armv7/CLAPIDeserializer.o
"Cloud/API Parsing/CLAPIDeserializer.m" normal armv7 objective-c
com.apple.compilers.llvm.clang.1_0.compiler
cd "/Users/juniorpond/Documents/Dropbox/Triple J Studios/Applications/Applications/CloudSend/Test/Test"
setenv LANG en_US.US-ASCII
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-x objective-c -arch armv7 -fmessage-length=0 -std=gnu99 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
-Wprotocol -Wdeprecated-declarations -g -Wno-conversion -Wno-sign-conversion -mthumb "-DIBOutlet=attribute((iboutlet))" "-DIBOutletCollection(ClassName)=attribute((iboutletcollection(ClassName)))"
"-DIBAction=void)attribute((ibaction)" -miphoneos-version-min=5.1
-iquote /Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Test-generated-files.hmap
-I/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Test-own-target-headers.hmap
-I/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Test-all-target-headers.hmap
-iquote /Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Test-project-headers.hmap
-I/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Products/Debug-iphoneos/include
-I/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/DerivedSources/armv7
-I/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/DerivedSources
-F/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Products/Debug-iphoneos
-include /Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/PrecompiledHeaders/Test-Prefix-clsydhfesjzmtrbgszvgmeofhzfq/Test-Prefix.pch
-MMD -MT dependencies -MF /Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Objects-normal/armv7/CLAPIDeserializer.d
--serialize-diagnostics /Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Objects-normal/armv7/CLAPIDeserializer.dia
-c "/Users/juniorpond/Documents/Dropbox/Triple J Studios/Applications/Applications/CloudSend/Test/Test/Cloud/API
Parsing/CLAPIDeserializer.m" -o
/Users/juniorpond/Library/Developer/Xcode/DerivedData/Test-fqacaiejputxwicubwhguzleizde/Build/Intermediates/Test.build/Debug-iphoneos/Test.build/Objects-normal/armv7/CLAPIDeserializer.o
clang: error: unable to execute command: posix_spawn failed: Resource
temporarily unavailable clang: error: clang frontend command failed
due to signal 1 (use -v to see invocation) clang: note: diagnostic
msg: Please submit a bug report to
http://developer.apple.com/bugreporter/ and include command line
arguments and all diagnostic information. clang: error: unable to
execute command: posix_spawn failed: Resource temporarily unavailable
clang: note: diagnostic msg: Error generating preprocessed source(s).
Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
failed with exit code 255
When this happens, close xcode and issue the "purge" command in Terminal then restart xcode. That solved this error for me.
It means your OS X kernel cannot spawn any more processes for your user ID. There is a maximum number of processes per user:
To see your process limitation:
sysctl kern.maxprocperuid
To check how many processes you have running:
ps aux | grep username | wc -l
To see how many zombie process:
ps -v -u username | grep -v grep | awk '{print $2}' | grep Z | wc -l
To see what they are:
for pid in `ps -v -u username | grep -v grep | awk '{print $1, $2}' | grep Z | awk '{print $1}'`
do
ps -o command="" -p $pid >> zombies.txt
done
None of these processes can be killed, and purge won't work on my mac, 10.8.2.
You could temporarily increase the max user processes count:
sudo sysctl -w kern.maxprocperuid=1024
Then in your .bash_profile or .bashrc add:
ulimit -u 1024
And change Finder’s limits:
sudo launchctl limit maxproc 1024
But really, it's time for coffee and give your mac a reboot..
I had this same problem with a project that I have under GIT with some of my team, the problem was that some of my team forgot to commit some new added files.
So, the .xcodeproj project it self was taking into consideration that it has some ViewControllers, but they weren't physically exist.
As soon as I added the missing view controllers, the project got built properly.
Hope this can help your situation.
just do it!!
1.Turn off your mac computer.
2.Turn on mac computer.
3.Run XCode
I had to do a clean to fix this. product>clean from xcode. rebooting & purging didn't help, cleaning fixed it.
The message says
clang frontend command failed due to signal 1 (use -v to see
invocation)
Try adding a "-v" to your "Other C Flags" under Build Settings of your project and see what it spits out...
I am trying to run xcodebuild and I am getting the following error:
2011-12-11 04:42:22.834 xcodebuild[9155:4203] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x objective-c -c /dev/null 2>&1" UserInfo=0x4001a61a0 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x objective-c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2011-12-11 04:42:22.835 xcodebuild[9155:4203] Warning: Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'objective-c'.
Compiler: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2
Reason: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x objective-c -c /dev/null 2>&1
2011-12-11 04:42:22.895 xcodebuild[9155:4203] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x c -c /dev/null 2>&1" UserInfo=0x4013cbb80 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2011-12-11 04:42:22.900 xcodebuild[9155:4203] Warning: Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'c'.
Compiler: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2
Reason: /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2 -v -E -dM -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -x c -c /dev/null 2>&1
Any idea why this is? I am guessing that it is because I don't have gcc-4.2 in the following path:
/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/gcc-4.2
as of right now gcc-4.2 is located at usr/bin. The question is how do I redirect it?
This could be be related to your $CC variable in your shell ( it keeps track of your compiler ) you can find more information from jMoody on github
Essentially you need to remove $CC
How did you select the compiler? Go to the Xcode navigator, click on the upmost item, then in the right window on your project (not the target), then Build Settings. U and in the section Build Options you can select the compiler. Usually you can choose between LLVM gcc-4.x and some Apple LLVM x.
Have you used xcode-select to select the version of Xcode you want to use?
Manpage.
I have a simple perl test script which uses Net::SSH2, and I'm having trouble getting it to work with public key authentication.
Note: After reading a couple of replies, I realise that I should mention that I created the script to help narrow down a problem I was having with another application that uses Net::SSH2. It's therefore not possible for me to switch to an alternative package such as Net::OpenSSH or Net::OpenSSH::Compat::SSH2.
Note Update: As salva pointed out, Net::OpenSSH::Compat::SSH2 can be used without having to patch the original application.
Here's the code:
use strict;
use warnings;
use 5.10.0;
use Net::SSH2;
my $ssh2 = Net::SSH2->new();
my $auth;
if ( $ssh2->connect('hostname') ) {
$auth = $ssh2->auth_publickey(
'username',
'/home/mike/.ssh/id_rsa.pub',
'/home/mike/.ssh/id_rsa',
'password'
);
}
if ($auth && $ssh2->auth_ok) {
say 'Success';
} else {
say join ', ', $ssh2->error;
}
I have been generating key pairs using ssh-keygen on Ubuntu:
ssh-keygen -t rsa
ssh-copy-id user#server
ssh user#server
The above works correctly - I can SSH to the server.
When I run the Perl code, I get the following error when using a password protected key:
-16, LIBSSH2_ERROR_FILE, Unable to initialize private key from file
If I try with a non-password protected key, it works correctly.
I have the following libraries installed:
Net::SSH2 0.35
libssh2-1 1.2.2-1
libssh2-1-dev 1.2.2-1
ssh 1:5.3p1-3ubuntu6
openssh-server 1:5.3p1-3ubuntu6
openssh-client 1:5.3p1-3ubuntu6
openssl 0.9.8k-7ubuntu8.6
libssl-dev 0.9.8k-7ubuntu8.6
The plot thickens
If I remove libssh2-1 and libssh2-1-dev, I get an error, as expected:
Can't load '/usr/local/lib/perl/5.10.1/auto/Net/SSH2/SSH2.so'
If I then build libssh2 from source, I am unable to reinstall Net::SSH2, as it can't find the development headers. However, if I reinstall libssh2-1 and libssh2-1-dev and then build and install libssh2 from source, it works.
Does that mean that the build of libssh2-1-dev on Ubuntu 10.04 is at fault? If so, how do I install libssh2 from source and correctly install Net::SSH2, without requiring libssh2-1-dev. I presume that the build from source is overwriting or overriding the Ubuntu package.
UPDATE
As noted in Daniel Stenberg's reply, the Ubuntu 10.04 package is now a little out of date (version 1.2.2, compared with the latest stable build at 1.2.8). Installing libssh2 from source 'over the top' of the Ubuntu package solves the problem. However, this feels messy to me. How can I remove the Ubuntu package, install libssh2 from source, and still build Net::SSH2 — how do I tell Net::SSH2 where to find the libssh2 development headers?
UPDATE 2
salva came to the rescue again, and showed how the Net::SSH2 installer can be configured with lib and include directories, so that it may be used with the source install of libssh2. Thanks salva! Note that instead of patching Makefile.PL, it's possible to just override the $lib and $inc variables at the top of Makefile.PL. I wasn't aware of this until I looked at salva's patch.
I have been able to successfully log into a server using a pass-phrase protected key with Net::SSH2 from the the Ubuntu 11.04 libnet-ssh2-perl package.
Anyway, consider using Net::OpenSSH or Net::OpenSSH::Compat::SSH2 instead of Net::SSH2.
Update: Net::OpenSSH::Compat::SSH2 tries to be a replacement for Net::SSH2. There is no need to patch the application in order to try it:
perl -MNet::OpenSSH::Compat=Net::SSH2 yor_app.pl
When you install libssh2 from the source package it will by default install itself in /usr/local, while the default package installs in /usr which probably is why it only finds the "stock" installed version.
Unfortunately it seems your Ubuntu has a fairly old libssh2 version as it has been bugfixed a lot since then.
I recommend using the libssh2-devel mailing list for in-depth libssh2 questions. It's a small but friendly community.
I have created a patch for Net::SSH2 Makefile.PL that allows to set the location of libssh2 libs and headers from the command line.
Here is a capture of the full build process for libssh2 + Net::SSH2 using it:
salva#leon:/tmp/salva$ wget http://www.libssh2.org/download/libssh2-1.2.8.tar.gz
--2011-05-27 11:21:10-- http://www.libssh2.org/download/libssh2-1.2.8.tar.gz
Resolving www.libssh2.org... 80.67.6.50
Connecting to www.libssh2.org|80.67.6.50|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 637707 (623K) [application/x-gzip]
Saving to: `libssh2-1.2.8.tar.gz'
100%[================================================================================================================================================================================================>] 637,707 525K/s in 1.2s
2011-05-27 11:21:14 (525 KB/s) - `libssh2-1.2.8.tar.gz' saved [637707/637707]
salva#leon:/tmp/salva$ tar xzf libssh2-1.2.8.tar.gz
salva#leon:/tmp/salva$ cd libssh2-1.2.8
salva#leon:/tmp/salva/libssh2-1.2.8$ ./configure --prefix=/usr/local/libssh2
checking whether to enable maintainer-specific portions of Makefiles... no
checking for sed... /bin/sed
checking for a BSD-compatible install... /usr/bin/install -c
...
salva#leon:/tmp/salva/libssh2-1.2.8$ make
Making all in src
make[1]: Entering directory `/tmp/salva/libssh2-1.2.8/src'
make all-am
make[2]: Entering directory `/tmp/salva/libssh2-1.2.8/src'
if /bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I../include -I../src -g -O2 -MT channel.lo -MD -MP -MF ".deps/channel.Tpo" -c -o channel.lo channel.c; \
then mv -f ".deps/channel.Tpo" ".deps/channel.Plo"; else rm -f ".deps/channel.Tpo"; exit 1; fi
libtool: compile: gcc -DHAVE_CONFIG_H -I../include -I../src -g -O2 -MT channel.lo -MD -MP -MF .deps/channel.Tpo -c channel.c -fPIC -DPIC -o .libs/channel.o
...
salva#leon:/tmp/salva/libssh2-1.2.8$ sudo make install
Making install in src
make[1]: Entering directory `/tmp/salva/libssh2-1.2.8/src'
make[2]: Entering directory `/tmp/salva/libssh2-1.2.8/src'
test -z "/usr/local/libssh2/lib" || mkdir -p -- "/usr/local/libssh2/lib"
/bin/bash ../libtool --mode=install /usr/bin/install -c 'libssh2.la' '/usr/local/libssh2/lib/libssh2.la'
libtool: install: /usr/bin/install -c .libs/libssh2.so.1.0.1 /usr/local/libssh2/lib/libssh2.so.1.0.1
...
salva#leon:/tmp/salva/libssh2-1.2.8$ cd ..
salva#leon:/tmp/salva$ wget http://search.cpan.org/CPAN/authors/id/R/RK/RKITOVER/Net-SSH2-0.35.tar.gz
--2011-05-27 11:22:56-- http://search.cpan.org/CPAN/authors/id/R/RK/RKITOVER/Net-SSH2-0.35.tar.gz
Resolving search.cpan.org... 207.115.101.144
Connecting to search.cpan.org|207.115.101.144|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://osl.ugr.es/CPAN/authors/id/R/RK/RKITOVER/Net-SSH2-0.35.tar.gz [following]
--2011-05-27 11:22:59-- http://osl.ugr.es/CPAN/authors/id/R/RK/RKITOVER/Net-SSH2-0.35.tar.gz
Resolving osl.ugr.es... 150.214.21.7
Connecting to osl.ugr.es|150.214.21.7|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 92434 (90K) [application/x-gzip]
Saving to: `Net-SSH2-0.35.tar.gz'
100%[================================================================================================================================================================================================>] 92,434 328K/s in 0.3s
2011-05-27 11:22:59 (328 KB/s) - `Net-SSH2-0.35.tar.gz' saved [92434/92434]
salva#leon:/tmp/salva$ tar xzf Net-SSH2-0.35.tar.gz
salva#leon:/tmp/salva$ cd Net-SSH2-0.35
salva#leon:/tmp/salva/Net-SSH2-0.35$ wget -q --no-check-certificate -O - https://github.com/salva/net-ssh2/commit/3c7261f4584137f4240d204731e20f709f1addb1.patch|patch -p1
patching file Makefile.PL
salva#leon:/tmp/salva/Net-SSH2-0.35$ perl Makefile.PL lib=/usr/local/libssh2/lib/ inc=/usr/local/libssh2/include/
The libssh2 library is required by this module. If you don't have it, you can
download it from http://www.libssh2.org; you may also need OpenSSL, which can be
obtained from http://www.openssl.org.
Debian: sudo aptitude install libssh2-1-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel
Checking if your kit is complete...
Looks good
Writing Makefile for Net::SSH2
salva#leon:/tmp/salva/Net-SSH2-0.35$ make
cp lib/Net/SSH2/File.pm blib/lib/Net/SSH2/File.pm
cp lib/Net/SSH2/PublicKey.pm blib/lib/Net/SSH2/PublicKey.pm
cp lib/Net/SSH2/Dir.pm blib/lib/Net/SSH2/Dir.pm
cp lib/Net/SSH2/SFTP.pm blib/lib/Net/SSH2/SFTP.pm
cp lib/Net/SSH2/Listener.pm blib/lib/Net/SSH2/Listener.pm
cp lib/Net/SSH2/Channel.pm blib/lib/Net/SSH2/Channel.pm
cp lib/Net/SSH2.pm blib/lib/Net/SSH2.pm
AutoSplitting blib/lib/Net/SSH2.pm (blib/lib/auto/Net/SSH2)
/usr/bin/perl "-Iinc" /usr/local/share/perl/5.10.1/ExtUtils/xsubpp -typemap /usr/share/perl/5.10/ExtUtils/typemap -typemap typemap SSH2.xs > SSH2.xsc && mv SSH2.xsc SSH2.c
cc -c /usr/local/libssh2/include/ -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"0.35\" -DXS_VERSION=\"0.35\" -fPIC "-I/usr/lib/perl/5.10/CORE" SSH2.c
In file included from SSH2.xs:11:0:
ppport.h:3042:0: warning: "PERL_UNUSED_DECL" redefined
/usr/lib/perl/5.10/CORE/perl.h:330:0: note: this is the location of the previous definition
cc: /usr/local/libssh2/include/: linker input file unused because linking not done
Running Mkbootstrap for Net::SSH2 ()
chmod 644 SSH2.bs
rm -f blib/arch/auto/Net/SSH2/SSH2.so
LD_RUN_PATH="/usr/local/libssh2/lib:/lib/x86_64-linux-gnu" cc -shared -O2 -g -L/usr/local/lib -fstack-protector SSH2.o -o blib/arch/auto/Net/SSH2/SSH2.so \
-L/usr/local/libssh2/lib/ -lssh2 -lz -lssl -lcrypto \
chmod 755 blib/arch/auto/Net/SSH2/SSH2.so
cp SSH2.bs blib/arch/auto/Net/SSH2/SSH2.bs
chmod 644 blib/arch/auto/Net/SSH2/SSH2.bs
Manifying blib/man3/Net::SSH2::File.3pm
Manifying blib/man3/Net::SSH2::Dir.3pm
Manifying blib/man3/Net::SSH2::PublicKey.3pm
Manifying blib/man3/Net::SSH2::SFTP.3pm
Manifying blib/man3/Net::SSH2::Listener.3pm
Manifying blib/man3/Net::SSH2::Channel.3pm
Manifying blib/man3/Net::SSH2.3pm
salva#leon:/tmp/salva/Net-SSH2-0.35$ ldd ./blib/arch/auto/Net/SSH2/SSH2.so
linux-vdso.so.1 => (0x00007fff20abc000)
libssh2.so.1 => /usr/local/libssh2/lib/libssh2.so.1 (0x00007f464d52f000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f464d317000)
libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007f464d09a000)
libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007f464cd0b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f464c977000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f464c772000)
/lib64/ld-linux-x86-64.so.2 (0x00007f464d97e000)
salva#leon:/tmp/salva/Net-SSH2-0.35$ sudo make install
...
I am trying to build openldap-2.4.23 library for iOS3 and 4 but when I try to run configure I get error :
>./configure --disable-slapd --disable-shared --enable-static --host=arm-apple-darwin
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
Configuring OpenLDAP 2.4.23-Release ...
checking build system type... i686-apple-darwin10.7.0
checking host system type... arm-apple-darwin
checking target system type... arm-apple-darwin
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking configure arguments... configure: WARNING: slapd disabled, ignoring --enable- bdb argument
configure: WARNING: slapd disabled, ignoring --enable-hdb argument
configure: WARNING: slapd disabled, ignoring --enable-monitor argument
configure: WARNING: slapd disabled, ignoring --enable-relay argument
configure: WARNING: slapd disabled, ignoring --enable-syncprov argument
done
checking for style of include used by make... GNU
checking for arm-apple-darwin-gcc... /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
My env settings are like this :
export DEVROOT="/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
export CC="${DEVROOT}/usr/bin/gcc"
export LD="${DEVROOT}/usr/bin/ld"
export AR="${DEVROOT}/usr/bin/ar"
export AS="${DEVROOT}/usr/bin/as"
export NM="${DEVROOT}/usr/bin/nm"
export CPPFLAGS="-I${SDKROOT}/usr/lib/gcc/arm-apple-darwin10/4.2.1/include -I${SDKROOT}/usr/include"
export CPP="${DEVROOT}/usr/bin/cpp ${CPPFLAGS}"
export CFLAGS="${CPPFLAGS} -arch armv6 -pipe -no-cpp-precomp"
export LDFLAGS="-L${SDKROOT}/usr/lib"
By the way, I succeeded to configure after the CFLAGS and LDFALGS are modified as follows :
export CFLAGS="${CPPFLAGS} -pipe -no-cpp-precomp"
export LDFLAGS=""
However, that results of make & make install are not armv architecture :
> lipo -detailed_info libldap.a
input file libldap.a is not a fat file
Non-fat file: libldap.a is architecture: i386
How can I build armv6 architecture openldap library?
Anyone, please help!!
Thanks.
This may be a little late for you, however I ported OpenLDAP to iOS using Xcode. The project can be cloned from github. https://github.com/bindle/iOSPorts
There is some documentation and examples in the project.
I think I'm one step closer to the solution (it configuration is successful).
I've found similar problem here and simply adjusted build script so it would work on openLDAP.
#!/bin/bash
PLATFORMPATH="/Applications/Xcode.app/Contents/Developer/Platforms"
TOOLSPATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
export IPHONEOS_DEPLOYMENT_TARGET="8.0"
pwd=`pwd`
findLatestSDKVersion()
{
sdks=`ls $PLATFORMPATH/$1.platform/Developer/SDKs`
arr=()
for sdk in $sdks
do
arr[${#arr[#]}]=$sdk
done
# Last item will be the current SDK, since it is alpha ordered
count=${#arr[#]}
if [ $count -gt 0 ]; then
sdk=${arr[$count-1]:${#1}}
num=`expr ${#sdk}-4`
SDKVERSION=${sdk:0:$num}
else
SDKVERSION="8.0"
fi
}
buildit()
{
target=$1
hosttarget=$1
platform=$2
echo =============================================================
echo = building for target $target platform $platform ... =
echo =============================================================
if [[ $hosttarget == "x86_64" ]]; then
hostarget="i386"
elif [[ $hosttarget == "arm64" ]]; then
hosttarget="arm"
fi
export CC="$(xcrun -sdk iphoneos -find clang)"
export CPP="$CC -E"
export CFLAGS="-arch ${target} -isysroot $PLATFORMPATH/$platform.platform/Developer/SDKs/$platform$SDKVERSION.sdk -miphoneos-version-min=$SDKVERSION"
export AR=$(xcrun -sdk iphoneos -find ar)
export RANLIB=$(xcrun -sdk iphoneos -find ranlib)
export CPPFLAGS="-arch ${target} -isysroot $PLATFORMPATH/$platform.platform/Developer/SDKs/$platform$SDKVERSION.sdk -miphoneos-version-min=$SDKVERSION"
export LDFLAGS="-arch ${target} -isysroot $PLATFORMPATH/$platform.platform/Developer/SDKs/$platform$SDKVERSION.sdk"
mkdir -p $pwd/output/$target
./configure --disable-shared --host=$hosttarget-apple-darwin --with-tls=openssl --disable-slapd --prefix="$pwd/output-build/common" --exec-prefix="$pwd/output-build/$target"
make depend
# make clean
make
make install
echo =============================================================
echo = Success for target $target platform $platform ... =
echo =============================================================
}
findLatestSDKVersion iPhoneOS
buildit armv7 iPhoneOS
buildit armv7s iPhoneOS
buildit arm64 iPhoneOS
buildit i386 iPhoneSimulator
buildit x86_64 iPhoneSimulator
#LIPO=$(xcrun -sdk iphoneos -find lipo)
#$LIPO -create $pwd/output/armv7/lib/libpresage.a $pwd/output/armv7s/lib/libpresage.a $pwd/output/arm64/lib/libpresage.a $pwd/output/x86_64/lib/libpresage.a $pwd/output/i386/lib/libpresage.a -output libpresage.a
Problem is that build error is reported (when executing make):
Making all in /Users/maru/Documents/openldap-2c705e4/libraries
Entering subdirectory liblutil
cc -g -O2 -I../../include -I../../include -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk -miphoneos-version-min=8.4 -c -o sasl.o sasl.c
sasl.c:26:10: fatal error: 'sasl/sasl.h' file not found
#include <sasl/sasl.h>
^
1 error generated.
make[2]: *** [sasl.o] Error 1
make[1]: *** [all-common] Error 1
make: *** [all-common] Error 1
If I understand documentation o SASL correctly it is not available for iOS. So it looks like I'm one step closer then #alkain, but still didn't find final solution.