I want to build static Rust executables with a customized version of musl. As a first step, I'm making myself familiar with Rust's build system.
I took the slightly outdated docker-rust-musl GitHub project and updated URLs that went out-of-date. Everything seems to work well with the build, but when I want to compile with x86_64-unknown-linux-musl the compiler doesn't find the musl std crate:
root#beb234fba4af:/build# cat example.rs
fn main() { println!("hi!"); panic!("failed"); }
root#beb234fba4af:/build# rustc --target=x86_64-unknown-linux-musl example.rs
error[E0463]: can't find crate for `std`
|
= note: the `x86_64-unknown-linux-musl` target may not be installed
error: aborting due to previous error
In fact, /usr/local/lib/rustlib/ only contains the x86_64-unknown-linux-gnu directory, even though output during the build indicates that x86_64-unknown-linux-musl is built:
[...]
Building stage2 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-musl)
[...]
However, when it comes to the installation step x86_64-unknown-linux-gnu is nowhere to be seen:
[...]
Install std stage2 (x86_64-unknown-linux-gnu)
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rust-std-x86_64-unknown-linux-gnu'
std is standing at the ready.
Install rustc stage2 (x86_64-unknown-linux-gnu)
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
Rust is ready to roll.
Build completed in 0:31:07
What do I have to do to install the x86_64-unknown-linux-musl Rust standard library?
Progress:
Digging through the build environment revealed that make all builds the Rust std library with musl but the subsequent make install step does not install it.
We have a temporary fix in the build.sh script of the previously mentioned docker image.
It is unclear whether that is an issue of the build environment or of its usage.
The issue is known to the Rust developers. No eta of the fix, however.
Related
I am trying to compile dlib 19.4 using the vcpkg tool
since I am having trouble compiling CMAKE and working with Boost.Python
to fix compiler issues for dlib.
Though I am having problems even running the basic steps
to get the vcpkg package to work:
(I also downloaded Visual Studio 2017 for this tool)
Looking at executed command (git init), you initialized empty git repository for vcpkg - that is likely wrong. This bootstrap.ps1 script fails internally when trying to fetch existing revisions. vcpkg doesn't want to reside in just any git repository, it wants "its" git repository. vcpkg uses git as a distribution platform and later to perform updates.
So instead, you should clone vcpkg repository to some directory, e.g.:
C:\test>git clone https://github.com/Microsoft/vcpkg.git vcpkg_test
Cloning into 'vcpkg_test'...
...
Checking out files: 100% (876/876), done.
C:\test>cd vcpkg_test
C:\test\vcpkg_test>powershell -exec bypass scripts\bootstrap.ps1
https://github.com/Microsoft/vcpkg/
Additionally I see errors regarding VS2017 C++ support. VS2017 is an IDE with multiple optionally supported languages (i.e. you could have only C# support installed). Please make sure you have "Desktop development with C++" workload installed - as vcpkg is for C++. You can update the installation at any time by running installer again (Modify).
https://learn.microsoft.com/en-us/visualstudio/install/install-visual-studio
The objective is to compile a C++ program with Boost.Python in Eclipse on the OS on Linux Mint 18. In particularly, we want to run the template program:
#include<boost/version.hpp>
#include<boost/python.hpp>
#include<iostream>
using namespace std;
int main() {
cout << "My first boost program with version: " << BOOST_LIB_VERSION << endl;
return 0;
}
This personally took me quite a while to get working, so the tutorial below should serve as a one-stop-shop reference for anyone in a similar situation. Note on software used:
Boost version: 1.62.0
Python version: 2.7.12
OS: Linux Mint 18 Xfce 64-bit
Eclipse version: CDT 9.1.0 for Eclipse Neon.1
Installing Eclipse CDT
Make sure that you have Java installed. For the Java JDK (if you want to also develop Java programs), run:
sudo apt-get install default-jdk
To simply run Java programs (such as Eclipse), you can install the lighter Java JRE:
sudo apt-get install default-jre
Both JDK and JRE will work, but JDK takes up more space.
Go to CDT download webpage and download the Linux 64-bit file eclipse-cpp-neon-1-linux-gtk-x86_64.tar.gz
Assuming you downloaded the file in ~/Downloads/, run the following command to unpack ("install") Eclipse into the /opt/ directory:
sudo tar zxvf ~/Downloads/eclipse-cpp-neon-1-linux-gtk-x86_64.tar.gz -C /opt/
To create a desktop launcher icon, run
sudo gedit ~/.local/share/applications/eclipse.desktop
and in the text editor copy-paste:
[Desktop Entry]
Name=Eclipse
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse
You now have Eclipse installed, but you don't need to run it yet, just keep reading and following the instructions :)
Installing Boost
The instructions are more or less given here, but for the sake of cohesion I write them here.
Download boost_1_62_0.tar.gz
Assuming you downloaded the file into ~/Downloads/, run the following command to unpack Boost into the /usr/include/ directory:
sudo tar zxvf ~/Downloads/boost_1_62_0.tar.gz -C /usr/include/
It's as easy as that - you now have Boost... but that's not all yet. Read on :)
Building Boost.Python and Boost.System
The Boost libraries Boost.Python and Boost.System must be built before they can be used. Here's how you do this:
Go into the Boost directory in your Terminal:
cd /usr/include/boost_1_62_0/
Run the command:
sudo ./bootstrap.sh --prefix=/usr/local
To build Boost.Python and Boost.System into the /usr/local/lib folder, run:
sudo ./b2 install --with-system --with-python
once the command has finished, you will find libboost_system and libboost_python (with various file endings) in /usr/local/lib
That's it for building the necessary Boost libraries. Note that any other Boost library that needs to be built can be done in the same way.
Preparing Python 2.7
Linux Mint 18 comes with Python 2.7 pre-installed. For me, running the command python --version returns the output Python 2.7.12. I'll assume this is the same for you - but probably it doesn't make a difference what the version is. However, to get our objective of the C++ program with Boost.Python to build and run, you have to execute the additional command:
sudo apt-get install python-dev
which places some additional necessary files (particularly pyconfig.h) into /usr/include/python2.7.
Installing Linux GCC
Linux GCC allows you to compile C++ programs. To install everything necessary, simply run:
sudo apt-get install build-essential
Making our program run in Eclipse
Now we've got everything configured to be able to write, build and run our program in Eclipse. So, let's do it!
Run Eclipse, either from the terminal (either by using the desktop icon we've created or by running /opt/eclipse/eclipse in the Terminal).
If it's your first time running Eclipse, you'll be prompted to choose a workspace (basically, a folder where all Eclipse project files will be stored):
Now go to File -> New -> C++ Project and enter the following and click Finish (you can use whatever Location you wish, including the default location (i.e. the one of your workspace)):
Now go to File -> New -> Source File, enter the following and click Finish:
In the main.cpp file that automatically opens in the editor, type in the program that we want to compile (note that I customized my Eclipse layout, so it looks different from the default layout you might have):
Now the secret sauce. Go to Project -> Properties -> C/C++ Build -> Settings where you will see:
Go to GCC C++ Compiler -> Includes and, using the little icon that looks like a folder with a green plus sign, add the following Include paths:
Go to GCC C++ Linker -> Libraries and add the following Libraries and Library search paths:
Press OK to close the Project Properties window.
Back in the main Eclipse window, first click the hammer icon to build the project, then the green play icon to run it (both buttons are highlighted in the below screenshot). In the console view you will first see a successful build, then the Terminal output of our program:
That's it! We've achieved our objective of building and running a C++ program with the Boost.Python library included. That's the end of this tutorial, I hope it helped you :)
I am trying to build from source for RedHawk installation and trying to replace uhd3.5.3 with a higher version of uhd for USRP_UHD module. I saw USRP_UHD source code, but found nowhere for uhd3.5.3 source code. I am guessing it might simply use "yum install ..." to download and install uhd host code and suporting libraries. Does anybody know where this code is located in redhawk_src_2.0 package? Or is there an efficient way in linux to search for this among all the files in redhawk_src_2.0 package?
Thanks in advance!
UHD is the USRP Harware driver softwware from Ettus Research. The UHD is distributed from:
http://files.ettus.com/binaries/uhd_stable/
Version 3.5.3 is here:
http://files.ettus.com/binaries/uhd_stable/uhd_003.005.003-release/
The current release is 3.9.2:
http://files.ettus.com/binaries/uhd_stable/uhd_003.009.002-release/
Hopefully this helps. I wasn't 100% sure what you are asking for.
First, clone the uhd library:
git clone git://github.com/EttusResearch/uhd.git
Then checkout the 3.9.2 tag:
git checkout release_003_009_002
Using the instructions from Ettus (http://files.ettus.com/manual/page_build_guide.html), install the dependencies listed under the Fedora section:
sudo yum -y install boost-devel libusb1-devel python-mako doxygen python-docutils cmake make gcc gcc-c++
Next, generate the Makefiles with CMake:
cd <uhd-repo-path>/host
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/uhd ../
I recommend using an alternate install prefix at first to preserve the 3.5.3 version, just in case, but if you don't want to, just run:
cmake ../
instead of the longer command with the -DCMAKE_INSTALL_PREFIX flag. (Note: I couldn't get cmake to find the installed boost version, so you may have to do some other research on that since it is probably a whole different stackoverflow post in and of itself)
Now build and install the uhd library:
make
make test
sudo make install
Now that the library is installed, you should edit the USRP_UHD/cpp/configure.ac so that the PKG_CONFIG_PATH points to your install prefix (either the one specified in the flag above, or if you did the default, just leave it, as it should already be pointing to /usr/local/lib/pkgconfig). Also in the configure.ac file, make sure to change the uhd version number to 3.9.2.
Now you should be able to rebuild the USRP_UHD Device:
./reconf && ./configure && make install
I don't guarantee that the Device will build against the new version of the uhd library, that will depend on what (if anything) has been deprecated an removed from the library between the supported version and the newest one.
Finally, if you get through all of those steps successfully and if you specified a non-standard install prefix, you will have to add this prefix to either the LD_LIBRARY_PATH or an /etc/ld.so.conf.d/ script in order for the Device to correctly execute.
Clarification - you can follow the Redhawk manual appendix B for building Redhawk from source AFTER installing UHD v3.9.3 from source as per pwolframs instructions. The UHD v3.5.3 is not packaged with the Redhawk source code, only the Redhawk RPM, disregard all those RPMs when building UHD and Redhawk from source.
This is related to this question: Can't install Vision Workbench.
I need to install boost1.42 in order to compile Vision workbench. I have downloaded the 1.42 package http://sourceforge.net/projects/boost/files/boost/1.42.0/ and extracted it. First I run ./bootstrap.sh --prefix=/home/myname/ and then ./bjam install. Everything works fine except for
error: #error "Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS"
So the thread package is not installed correctly and that means I cannot generate a make-file for Vision Workbench.
Does anyone have an idea of how to solve it?
/ Erik
As per the instructions http://www.boost.org/doc/libs/1_42_0/more/getting_started/unix-variants.html
$ cd ~/boost_1_42_0
$ bjam --build-dir=/tmp/build-boost toolset=gcc stage
should build static and shared non-debug multi-threaded variants of the libraries. To build all variants, pass the additional option, “--build-type=complete”.
If this doesn't work for you, then potentially your toolset is not being detected correctly (try specifying it). This is not unlikely since Boost 1.42.0 is really old, and probably could never know about the compiler version you're using.
As an aside, the BOOST_DISABLE_THREADS is known to make no difference for recent boost version.
I have downloaded Vowpal Wabbit ( Version 7.4 ) on to my Mac ( OS X Mavericks ) with the following version of g++ :
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include- dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
I modified the Makefile that comes with the installation so that it will pick up Boost ( Version 1.55 ) headers and libraries from the correct folders on my Mac ( I checked by writing and compiling a simple program and everything works ). However, when I run make it cannot find a header file, for example:
In file included from library_example.cc:2:
./../vowpalwabbit/parser.h:15:10: fatal error: 'boost/program_options.hpp' file
not found
Grateful for any help in tracking down the problem.
vowpal wabbit has a dependency on the C++ library+headers boost/program_options.
This dependency must be installed before vowpal wabbit can be built from source.
Since other people may have a similar issue, I will try to answer the more general question:
How to build vowpal wabbit from scratch/source, on Mac OS-X?
The following set of instructions assumes you have no development environment at all. If you do, you may skip any steps you deem unnecessary.
Important: credit where credit is due. These instructions are almost 100% written by Aaron Shumacher: I sourced them from his page following a web-search, with relatively minor modifications, additions, and clarifications.
Stage 0, basic prerequisites needed for developing on Mac OS-X:
Install the Xcode command line tools. This will give you an Apple’s development environment (compiler, make, etc.).
Install the Homebrew package manager.
Once you have Homebrew installed, everything else that's missing, is easy to install.
Install needed tools to build from source:
brew install libtool
brew install automake
brew install boost
brew install git
Now, you're ready to download the vowpal wabbit source tree (latest):
Download:
git clone https://github.com/JohnLangford/vowpal_wabbit.git
cd vowpal_wabbit
You’re now ready to go through the standard build (aka make) process.
Build:
[Edit: 2014-07-20]: ./autogen.sh may not work well in some environments. I recommend trying to build using a simple make first. The included Makefile is already pretty robust and should work just fine in most environments. The problem with running autogen/automake is that it may overwrite the (pretty good) original Makefile with a bad one.
# ./autogen.sh # commented out, use only if 'make' alone doesn't work
make
make test
Note: it is important to verify (using make test) that your binary works as expected. If you see any failure, please report it on the mailing list, and proceed with the installation only if the failure is immaterial to you (e.g. only some rarely used options/tests you don't care about fail). See the test/RunTests script for full details on the tests.
Install:
make install
At this point, you should have vowpal wabbit at /usr/local/bin/vw