I'm running a ./configure script and make to build a library. However, only .a libraries are generated. Is there an option to generate shared libs?
It's going to depend on the project you're trying to build. Run
./configure --help
to get a list of all options you can pass to ./configure, there may be a --shared option or something similar.
Related
I am trying to build an iOS app that is exposed to a fairly extensive Rust project, but I am having issues with one of the dependencies in the project. The Rust project has a ZMQ dependency, and while I am able to build the project on my Mac, when I try to incorporate the Rust project I get the following error:
error: failed to run custom build command for `zmq-sys v0.8.3`
Caused by:
process didn't exit successfully: `/Users/lisa/company/project/project_detail/target/debug/build/zmq-sys-16dfc88dff84d855/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBZMQ_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'Unable to locate libzmq:
pkg-config has not been configured to support cross-compilation.
Install a sysroot for the target platform and configure it via
PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
cross-compiling wrapper for pkg-config and set it via
PKG_CONFIG environment variable.', /Users/lisa/.cargo/registry/src/github.com-1ecc6299db9ec823/zmq-sys-0.8.3/build.rs:31:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
I am trying to build the appropriate library for the iOS and iOS simulator architectures without relying on pkg-config, but if someone can provide useful instructions for configuring pkg-config for cross-compilation, I am not opposed to it, I just don't know how and can't find any up to date resources.
I have cloned the libzmq project from this github: https://github.com/zeromq/libzmq.git, then navigate into libzmq.
Inside libzmq, I run ./autogen.sh followed by ./configure --prefix [directory location] --target "aarch64-apple-ios", then make and make install.
The above procedure without the --target flag is how I got the project to compile on my Mac in the first place, and with the target flag in place make and make install both complete successfully, but when I try to build the project using PROJECT_DIR="${PWD}/ProjectName" ./ProjectName/build-rust.sh,
I get the previously posted error.
I am following the Swift-Bridge Book (https://chinedufn.github.io/swift-bridge/building/xcode-and-cargo/index.html) to try to load the Rust libraries into Xcode.
One thing to note: In the libzmq git hub, there is a folder called builds/ios/ and inside this folder is what looks to be a build file for all of the iOS archs, but I haven't been able to get the repo to build with that file. I think figuring out how to use the build_ios.sh build file as opposed to the standard build.sh provided might be the answer, but I've tried dropping build_ios.sh where build.sh is, and ./autogen.sh doesn't work, because it complains that it can't find configure.ac, even though this file does exist.
I'm trying to use libffi in one of my projects, but I can't seem to compile for iOS (or macOS, for that matter). Here is one of the various errors I've encountered while building for the iOS Simulator:
bash: src/arm/gentramp.sh: No such file or directory
Update 1: Since the question remains unanswered, I've decided to open an issue at the official repository as well.
Update 2: Question has been answered and the issue has been closed!
If you check the repository you will see that the file you require was deleted in this commit. You can find the last version of this file here.
generate-darwin-source-and-headers.py and the libffi.xcodeproj need to be updated to include all currently relevant source files.
The gentramp.sh script is not needed anymore and the current upstream xcodeproj is not up to date either with compilation settings and to be included source files for 64-bit on iOS. A patched fork can be found at https://github.com/ksjogo/libffi
sh autogen.sh
python generate-darwin-source-and-headers.py --only-ios
open libffi.xcodeproj
select scheme libffi-iOS and device Generic iOS Device
click "Product - Build"
If success, you would see a "Product/libffi.a" in the side bar, you can right click it to get the lib in the finder.
Please make sure you are following the installing libffi instructions released on the TBD or git project: https://github.com/libffi/libffi
Here some of the main Highlights:
First you must configure the distribution for your particular
system. Go to the directory you wish to build libffi in and run the
"configure" program found in the root directory of the libffi source
distribution.
If you're building libffi directly from version control, configure won't
exist yet; run ./autogen.sh first.
You may want to tell configure where to install the libffi library and
header files. To do that, use the --prefix configure switch. Libffi
will install under /usr/local by default.
If you want to enable extra run-time debugging checks use the the
--enable-debug configure switch. This is useful when your program dies
mysteriously while using libffi.
Another useful configure switch is --enable-purify-safety. Using this
will add some extra code which will suppress certain warnings when you
are using Purify with libffi. Only use this switch when using
Purify, as it will slow down the library.
For iOS builds, the 'libffi.xcodeproj' Xcode project is available.
Configure has many other options. Use "configure --help" to see them all.
Once configure has finished, type "make". Note that you must be using
GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
To ensure that libffi is working as advertised, type "make check".
This will require that you have DejaGNU installed.
To install the library and header files, type "make install".
Alternatively, try merging one of the following git projects to your project in order to include the missing files. Please make sure the files are not outdated before merging.
1 https://github.com/pandamonia/libffi-iOS
2 https://github.com/influitive/libffi-iOS
3 https://github.com/landonf/libffi-ios
I want to build a program (YCM for VIM) which needs compiled Clang binaries to be linked with. For a reason, I can't use precompiled version which llvm itself offers for download (I've tested it, it doesn't work), so I want to build Clang and then build YCM, both with gcc.
For YCM to be built, I need compiled Clang files in the same way that they are in the precompiled package that llvm offers, that is there should be these folders:
bin docs include lib share
with corresponding files in them.
Now, I can build llvm and Clang with these commands:
mkdir llvm && cd llvm
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ..
cd ..
mkdir llvm-build && cd llvm-build
../llvm/configure --prefix=/usr/clang_3_4 --enable-optimized --enable-targets=host --disable-compiler-version-checks
make -j 8
after these, I get these folders in my llvm-build folder:
bindings config.log docs include LLVMBuild.cmake Makefile Makefile.config projects test unittests
cmake config.status examples lib llvm.spec Makefile.common Makefile.llvmbuild Release+Asserts tools utils
How can I create the files in the aforementioned way?
I think you should then run sudo make install.
You can also set the configure prefix to a local dir (e.g. somewhere in $HOME) if you don't want it to get copied into the system dirs and needing root access.
I have a few libraries that I build in succession. Some depend on others. For example:
libfoo.so depends on libbar.so
And, I don't want to have to deploy these things system-wide on the build machine. In my cmake file I have something like the following:
find_library(FOO_LIB foo /usr/lib64 /usr/lib /usr/local/lib)
On the build machine I normally give it a CMAKE_INSTALL_PREFIX flag at compile-time. Is there a way to do something like this:
find_library(FOO_LIB foo ${CMAKE_INSTALL_PREFIX}/lib /usr/lib64 /usr/lib /usr/local/lib)
if the flag is provided, but use the first version if it isn't provided?
please forgive my noobish-ness with respect to cmake
[clarification] Each library is built by a separate CMakeLists.txt file.
If you have one cmake-project which include other cmake-projects (with your libraries and applications), you can use target names to link libraries: target_link_libraries(app foo bar)
If you build your libraries cmake project separately - it's not good way, I think, but you still have two options:
deploy your libraries before build app;
put already built libraries to third_party catalog and find it them (e.g. writing specific FindXXXX.cmake file which try to locate your libraries in third_party catalog first).
Trying to build a completely self-contained OTP that can be moved around independently of libs installed on a system.
Build OpenSSL 1.0.0d from source as follows:
./config --prefix=<open-ssl-dir>
make
make install
Then OTP R14B03:
./configure --prefix=<erlang-dir> --with-ssl=<open-ssl-dir> --without-termcap
Make of Erlang then fails as follows:
relocation R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a shared object; recompile with -fPIC
We're talking Ubuntu 10.04. Any help greatly appreciated - thanks!
The "can not be used when making a shared object; recompile with -fPIC" would mean SSL is not build with the Position Independent Code flag. This is needed for building it as a Dynamic Shared Object (DSO). This is probably needed by Erlang build process. Example build:
$ tar zxvf openssl-0.x.tar.gz
$ cd openssl-x
$ sh config shared -fPIC
$ make
$ sudo make install
For ppc64le:
./configure --prefix=/home/huaxin/huaxin/toolsInstalled/ --build=ppc64le CFLAGS="-D_GNU_SOURCE -DOPENSSL_NO_EC=1"
I suggest that you build on a VM where you have sudo permissions. Then build libraries like OpenSSL using --prefix=/usr so that make install puts them in the usual system library.
Then build your tool, in this case Erlang, using -rpath. Then use ldd to find all library dependencies for Erlang and any ports (C extensions) and copy those into Erlangs lib directory. Check all binaries and libraries with readelf -d to make sure that RPATH is set to $ORIGIN or $ORIGIN/../lib as needed. Use patchelf to fix these things if the linking process is not quite right (or you copied in secondary dependencies of system libraries).
Then use patchelf to set the interpreter for your binaries (not libraries) to point to ld-linux.so.2 in Erlang's lib directory. And then run a test suite using
strace -e open erl ... to make sure that your build is not opening anything in /lib or /usr/lib.
At this point tar it up and it will run on any Linux.
See this question Compiling Python 2.6.6 and need for external packages wxPython, setuptools, etc... in Ubuntu for far more detail on how I built Python in this fashion.