rust diesel linking with `cc` failed - rust

Ok, so kind of getting nowhere here. Before I posted a problem with my Mac M1 having linker issues with Rust Diesel and got nothing. So I spun up an Ec2 instance and tried to run this crate here and got the following:
error: linking with `cc` failed: exit status: 1
...
= note: /usr/bin/ld: cannot find -lpq
I've installed the following:
sudo yum update -y
sudo yum install git -y
sudo yum groupinstall "Development Tools" -y
sudo yum install cmake -y
sudo yum install postgresql-libs -y
Seriously, how are people managing to get this crate running?

From the Diesel Getting Started guide:
If you run into an error like:
note: ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This means you are missing the client library needed for a database backend – mysqlclient in this case. You can resolve this issue by either installing the library (using the usual way to do this depending on your operating system) or by excluding the undesired default library with the --no-default-features flag.
By default diesel depends on the following client libraries:
libpq for the PostgreSQL backend
libmysqlclient for the Mysql backend
libsqlite3 for the SQlite backend
If you are not sure on how to install those dependencies please consult the documentation of the corresponding dependency or your distribution package manager.
For example, if you only have PostgreSQL installed, you can use this to install diesel_cli with only PostgreSQL:
cargo install diesel_cli --no-default-features --features postgres
The error "cannot find -lpq" is your linker telling you that it cannot find the PostgreSQL client library.

I'm on Fedora 36. The problem seemed to be that there were 2 versions of Postgres in my PC, and diesel couldn't figure out which library to use. So here's what solved it:
sudo dnf remove postgresql10-libs
sudo dnf install postgresql14-libs
sudo dnf install postgresql14-devel
Edit: this worked for a bit, but then broke again. I fixed it with:
sudo dnf remove postgresql14-devel
sudo dnf install libpq-devel.x86_64

The issue was caused by a missing library.
For Linux
sudo apt install libpq-dev
cargo install diesel_cli --no-default-features --features postgres
For Windows,
Check the version of rust you have installed
rustup --version
then copy the libq.lib from
C:\Program Files\PostgreSQL\14\lib
to
C:\Users\"Your User"\.rustup\toolchains\"Your version of Rust-Nightly or Stable"\lib\rustlib\x86_64-pc-windows-msvc\lib
Worked for me !!

Related

Installing Boost in Linux

I recently set up an AWS EC2 Linux instance, and I'm trying to install boost using the following code:
wget -c
http://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2
tar jxf boost_1_66_0.tar.bz2
cd boost_1_66_0
sudo ./bootstrap.sh --prefix=/usr/local/
./b2
sudo ./b2 install
When I run this, I get the following:
error: toolset gcc initialization:
error: no command provided, default command 'g++' not found
error: initialized from project-config.jam:12
Also, when I tried installing g++, which I thought I had already done by issuing this:
sudo yum install gcc-c++
The result:
Package gcc-c++-4.8.5-1.22.amzn1.noarch already installed and latest version
Nothing to do
On AWS Linux the way to go is described here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/compile-software.html
Or execute command:
sudo yum groupinstall "Development Tools"
This should help.
It seems like you are missing other build tools required for compiling. Installing following should fix your problem,
sudo yum install -y gcc libxml2-devel gcc-c++ make
You can uninstall the tools afterwards.

"configure: error: libnl and libnl-genl are required but were not found"

I'm trying to configure powertop-2.5 but when I run ./configure I get a "configure: error: libnl and libnl-genl are required but were not found" error
I've run
sudo apt-get install libtool autoconf libnl-dev ncurses-dev pciutils-dev build-essential -y
as was recommended by these guys but I get the same error.
I ran
sudo apt-get install libnl-genl-3-dev
Which replaced the previous libnl file but I still get the config error.
According to this, powertop has (or had) problems with detecting libnl but I can't figure out how to fix it.
I'm currently running Linux username 3.2.0-4-686-pae #1 SMP Debian 3.2.51-1 i686 GNU/Linux
I see you tried libnl-dev, maybe try libnl-3-dev instead:
sudo apt-get install libnl-3-dev libnl-genl-3-dev
Probably the problem is the lack of the pkg-config application in your system (which is used to find the proper dependencies with the configure script). I just have the same problem in a fresh installed Ubuntu 14.04 system, and after installing the pkg-config package the configure script finalized successfully its work. Then I could compile and install the last version (2.6.1) of powertop.
I "solved" my problem by installing powertop-2.0 instead.
The use of pkg-config made the trick. I was able to install Powertop 2.7.

Error installing charlock_holmes : Error installing GITLAB

I am trying to install GITLAB. I get this error executing "sudo gem install charlock_holmes --version '0.6.9'" (section Install Gems)
GEOGIT:/geogit/Administrative_Tools # sudo gem install charlock_holmes --version '0.6.9'
Building native extensions. This could take a while...
ERROR: Error installing charlock_holmes:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9 extconf.rb
checking for main() in -licui18n... no
which: no brew in (/usr/sbin:/bin:/usr/bin:/sbin)
checking for main() in -licui18n... no
***************************************************************************************
*********** icu required (brew install icu4c or apt-get install libicu-dev) ***********
***************************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.9
--with-icu-dir
--without-icu-dir
--with-icu-include
--without-icu-include=${icu-dir}/include
--with-icu-lib
--without-icu-lib=${icu-dir}/
--with-icui18nlib
--without-icui18nlib
--with-icui18nlib
--without-icui18nlib
Gem files will remain installed in /usr/lib64/ruby/gems/1.9.1/gems/charlock_holmes-0.6.9 for inspection.
Results logged to /usr/lib64/ruby/gems/1.9.1/gems/charlock_holmes-0.6.9/ext/charlock_holmes/gem_make.out
Someone, can help me debug those logs and error?
This looks like issue 1952
It was actually weirdness with the way my ubuntu VPS is commissioned. Mine did not come with a C compiler or libdev obviously.
The problem fix I found was to install libdev first, then the GCC
Then apt-get install libicu-dev.
Update 2015: additional comments include:
yum install libicu-devel worked for me
You just need to make sure "patch" is installed (yum install patch) then it should work
For MacOS install the following dependency:
brew install icu4c
According to the documentation (https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md) the package libicu-dev is required
Install it with "apt-get install libicu-dev" and then charlock_holmes could be installed
I used "yum install libicu-devel" and then I could install charlock_holmes
I got the same mistake on a Centos 5.4 server, the yum repository only have the icu version 3.6, so i have to search and install manually the library icu 4.2 which solve the problem. In case someone else need to know how to do it, i recommend to check this link http://source.icu-project.org/repos/icu/icu/tags/release-4-2-1/readme.html#HowToBuildUNIX
I had kind of the same problem: when I was trying to install charlock_holmes gem, I had this error:
charlock_holmes-0.7.3/mkmf.log
have_library: checking for main() in -licui18n... -------------------- no
I fixed it by running the first command of #VonC:
sudo apt-get install libicu-dev
Hope I helped someone!

How to fix Error 2 when trying to make haskell-platform?

I downloaded the Haskell-platform source from here: http://www.haskell.org/platform/linux.html, installed ghc, and did /.configure. However when I do sudo make, I get the following error:
Preprocessing library HUnit-1.2.4.2...
Test/HUnit/Base.hs:1:1:
Could not find module `Prelude'
Perhaps you haven't installed the profiling libraries for package `base'?
Use -v to see a list of the files searched for.
Error:
Building the HUnit-1.2.4.2 package failed
make: *** [build.stamp] Error 2
Does anyone knows how to fix this?
I'm trying to install on Ubuntu 12.04.1 LTS
Instead of trying to install from the sources, simply install the Ubuntu packages, which will be much simpler, with:
$ sudo apt-get install haskell-platform
If you need a local version of the documentation and the profiling libraries, install the additional packages with:
$ sudo apt-get install haskell-platform-doc haskell-platform-prof
Daniel Fisher's comment led me to the solution. You have to install all the profiling libraries for each of the ghc packages you have installed.
Just write
sudo apt-get install ghc*-prof
That's how it worked for me

Can't build gem -- native extension build fails -- can you see why?

I can't figure out what is going wrong here -- any ideas??
I'm running on a Ubuntu 8.04 LTS, and have installed libxml2 and libxslt from these instructions:
http://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php
http://www.techsww.com/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.php
However, I installed the latest versions:
libxslt-1.1.24
libxml2-2.7.3
The install was uneventful
-------------------- I set LD_LIBRARY_PATH ----------------------------------
echo $LD_LIBRARY_PATH
/usr/local/libxslt/lib:
------------- seems like the function is present -- at least based on the output of strings ------------
/usr/local/libxslt/lib$ strings * | grep ParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
----------------------- But the compile still fails ----------------------------------------
sudo gem install webrat
Building native extensions. This could take a while...
ERROR: Error installing webrat:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb install webrat
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxml/parser.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libexslt/exslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... no
libxslt is missing. try 'port install libxslt' or 'yum install libxslt-devel'
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-xml2lib
--without-xml2lib
--with-xsltlib
--without-xsltlib
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3/ext/nokogiri/gem_make.out
In Ubuntu you need to follow these steps:
sudo apt-get install libxml2-dev
sudo apt-get install libxslt-dev
Jared Evans in this post on his blog, described a solution that worked for me on Ubuntu 8.04 LTS. His trick is to NOT use apt-get to install rubygems, but rather to build it from source. This worked great for me. His post is directed at installing rails, so I used these (modified slightly) steps from it to just install nokogiri:
FIRST INSTALL RUBY WITH APT-GET:
sudo apt-get update
sudo apt-get install ruby irb ri rdoc ruby1.8-dev libzlib-ruby
libyaml-ruby libreadline-ruby libncurses-ruby libcurses-ruby libruby
libruby-extras libfcgi-ruby1.8 build-essential libopenssl-ruby
libdbm-ruby libdbi-ruby libdbd-sqlite3-ruby sqlite3 libsqlite3-dev
libsqlite3-ruby libxml-ruby libxml2-dev
IN ADDITION TO JARED'S INSTRUCTIONS I ALSO INSTALLED (I'm not certain that libxslt1.1 is necessary):
sudo apt-get install libxslt1.1
sudo apt-get install libxslt1-dev
DOWNLOAD RUBYGEMS SOURCE:
Download the latest RubyGems (currently 1.3.6) from rubyforge (I used the zip package).
BUILD RUBYGEMS:
cd /TO/DIRECTORY/WHERE/YOU/UNZIPPED/rubygems-1.3.6/
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
INSTALL NOKOGIRI:
sudo gem update –system
sudo gem install nokogiri
The response will be:
1 gem installed
Installing ri documentation for nokogiri-1.4.1...
No definition for parse_memory
No definition for parse_file
No definition for parse_with
No definition for get_options
No definition for set_options
Installing RDoc documentation for nokogiri-1.4.1...
No definition for parse_memory
No definition for parse_file
No definition for parse_with
No definition for get_options
No definition for set_options
I haven't yet noticed any problems caused by the 'No definition' messages...
Try removing the libxslt* and install them again. That fixed the issue for me.
You have to install the development kits of these libraries.
I get the same error when trying to install to a non-standard location (as I don't have access to directories outside my home directory). It seems as if this answer simply installed to the default location in /usr for success. Or did I misunderstand?
More context about what I'm trying to do at http://groups.google.com/group/nokogiri-talk/browse_thread/thread/c1e909be09e90f5a, if that's helpful.
Here's what worked for me on Ubuntu 11.04 (natty):
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri

Resources