How does dmd determine it's library path at compile time?
I have two versions of dmd installed, dmd 2.074 and dmd 2.080.
The dmd 2.080 was picking up the 2.074 files, which (not surprisingly) weren't compiling.
For example, dmd 2.074 has functional.d at:
/Library/D/dmd/src/phobos/std/functional.d
While dmd 2.080 installed by brew has functional.d at:
/usr/local/Cellar/dmd/2.080.0/include/dlang/dmd/std/functional.d
I renamed /Library/D/... (which has 2.074) to /Library/D2_074/....
Now dmd 2.080 (located in /usr/local/bin/dmd) is finding Phobos okay. Huzzah!
Maybe it is a bad thing to have multiple versions of dmd installed.
I'm trying to understand how the dmd compiler/linker determines the location of its compile, link, and (possibly) runtime support files. So when I install the next drop of dmd I won't make the same mistake again.
dmd will look for dmd.conf in the following sequence of directories:
current working directory
directory specified by the HOME environment variable
directory dmd resides in
/etc directory
It seems a dmd.conf is placed in /etc/dmd.conf by default in an install, but as seen above you can have separate configs for separate installs.
Related
I would like to run on Colab a C++ library which requires a version of libstdc++.so which is newer than the one provided by the default g++ 7.x installed on Colab. Such requirement is due to C++17 features not supported by g++ 7.x.
In order to do so, I install a recent g++ compiler (and corresponding libstdc++.so) from a PPA. However, when I try to import libraries compiled with the updated g++ compiler it seems that the python runtime is not aware of the update to libstdc++.so, unless one restarts the runtime via "Runtime -> Restart runtime".
Since restarting the runtime is an ugly workaround, and might be disruptive for my end users, is there a better way to make the current runtime aware that libstdc++.so has changed?
I have prepared a standalone notebook which shows my problem on a simple case (using pybind11).
Thanks
To install and use recent libstdc++ do:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt install libstdc++-9-dev.
Installed include files are inside /usr/include/c++/9/ and /usr/include/x86_64-linux-gnu/c++/9/.
Installed binary library files (.a/.so) are in /usr/lib/gcc/x86_64-linux-gnu/9/.
You can list installed files of package through dpkg -L libstdc++-9-dev.
Now you can run your program like:
LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/ your_program_name
So that it gets correct path and correct .so file.
Issue with your Notebook was solved for me by adding to setup.py following options, after that your Notebook doesn't print any error:
extra_compile_args=["-std=c++11", '-static', '-static-libgcc', '-static-libstdc++'],
extra_link_args=['-static-libgcc', '-static-libstdc++'],
Also you can collect all necessary .so files into folder of your Python's module and package all into wheel .whl file. There is no need to APT-install all .so dependencies on every machine. I think for Python is more clean solution to ship all necessary .so files inside .whl.
There is a specific program i need to run using c++11 libraries offered by gcc-4.8 and higher. The remote HPC on which i am trying to run the program has gcc-4.6.1. I was able to install the gcc-4.8.2 version on the HPC in a user specified directory, say
/share/user/gccInstall
(gccInstall has the /bin and /lib (etc) folders you get after installation)
I need to switch to this version for compiling my program. I tried using update-alternatives --config gcc, but it does not return anything.
Can anyone help me solve this!
EDIT:
Was able to change the gcc version using the following commands:
setenv PATH /share/user/gccInstall/bin
setenv LD_LIBRARY_PATH /share/user/gccInstall/lib
Now gcc --version returns 4.8.2.
But encountered another error while compiling:
g++: error trying to exec 'as': execvp: No such file or directory
what am i missing?
Many Thanks.
If you have a different version of g++ that you want to use then make sure you're getting the right one according to your $PATH or else specify the full path to the g++ you want. The other thing to be aware of is that you will probably need to update the $LD_LIBRARY_PATH environment variable to get the necessary libraries from your new gcc installation.
What exactly is the problem you're having? Can you compile but not run? Does compilation fail? Do you have any error messages you can share?
Assuming as you say that your new GCC installation is
under /share/user/gccInstall then if you add the option
-B/share/user/gccInstall
to each invocation of g++ or gcc then it will have this
effect:
-Bprefix
This option specifies where to find the executables, libraries, include files, and data files of the compiler itself.
(from Options for Directory Search)
This should help, and will perhaps be enough.
I am trying to build libtorrent (http://www.libtorrent.org/) using the provided jamfile. If I try to build it in its vanilla state everything goes well. I am then building using this command:
bjam msvc-12.0 boost=source
However I want to build it with OpenSSL which there seem to be support for. This is where I run into problems. Most likely because it is the first time I use Bjam (actually anything else than make files). I now try to run the following command:
bjam msvc-12.0 boost=source encryption=openssl
Now the compiler starts to complain about not finding the OpenSSL include files.
So I guess I have to include this path in the JAM file. But I have no idea where.
I also tried to add the path into the INCLUDE environment varaible in windows but that doesn't seem to be picked up by BJAM or msvc. Any suggestions?
My understanding of how this is normally done on windows is by installing libraries and headers into visual studio's include and lib folders.
(That's how I install openssl on windows at least).
The jamfile is also supposed to pick up CXXFLAGS and LDFLAGS environment variables, which you could use to introduce the library- and include paths. However, it only does this when boost=system is specified, i.e. you're building against "system" boost libraries instead of from source.
I'm trying to install cross-compiler using that tutorial .
I got stuck cross-compiling GCC version 4.9.1 using my native linux-GCC compiler. I occured an error during the installation and the solution is to build it in non-source directory. However, I have no idea how can I do it. I've read the documentation. However, it hasn't helped me.
I just want to install C++ and C version.
I haven't done this for ages but I think it means create a new empty directory and run configure from there, i.e. rather than
cd /usr/src/crosscompiler
./configure ...
do
mkdir /usr/src/crosscompiler-build
cd /usr/src/crosscompiler-build
/usr/src/crosscompiler/configure ...
which will then set up the build environment and make files in that new directory to use the source tree from the old directory. (If that doesn't work, you could try putting the empty directory inside the source tree, e.g. /usr/src/crosscompiler/build)
That all said, I thought a separate build directory has been the only way to build GCC for 10+ years, so I'm surprised the tutorial says anything different. You can build binutils into a separate path too, and there are ways of combining the GCC and binutils sources so that they can be built in one go too.
i just installed gcc 4.9 using the link here and it is a very good link. But I have only one problem which i dont want to try not to mess up --> linking the libraries and path variables.
we have a cluster in our college and i installed this in my home directory (without root). Now my home/ directory contains this folder where all the gcc folders are :
bin
include
lib
lib64
libexec
share
What all do i have to do to point to the g++/gcc binary in bin folder with additional linking ? For example, set ld_library_path, set binary paths (export PATH = /home/asdf/gcc4.9/bin:$PATH) . etc..
Can anyone provide details on what all needs to be done to use gcc/g++ 4.9 (installed by me) by bypassing the older version of gcc installed by root.
Do i have to add lib and lib64 to the ld_library_paths as well ? Will i have to use " " instead of < > to include files (e.g. # inlcude "set" or #include and it includes from gcc4.9 and not the old one ) Or explicitly provide the include path using -I
Any suggestions/discussions/comments are welcome. I am aware this may marked as duplicate, but it will really be useful to all the people out there who want to try the new gcc-4.9 with c++11 without messing up the environment variables.
PS: I am not asking how to export or set an environment variable. I am asking what all environment variables are required to use my non-root version of gcc and not the root's older version and not mess up the ld paths and so paths during runtime.
thanks !!
If you build your compiler with --prefix=/home/myname/gcc4.9 (adjust to match your system, obviously), then the compiler should "know" that the include paths etc.
All you need beyond that is to make sure your path has /home/myname/gcc4.9/bin before /usr/bin or wherever your other gcc is installed, and everything should work just like normal. On my machine, I have gcc 4.8.2 installed from my own build and gcc 4.6.3 from the linux installer for gcc (because it's a fairly old distro). And as long as I have the paths set in the right order, it works "automagically".
You will need to set LD_LIBRARY_PATH, but include-paths and static libraries should be handled by gcc itself.