EclipseFG does not search for "user" installed modules - cabal

I've just installed EclipseFP and now I am trying to load a module in GHCi. The problem is that GHCi doesn't load libraries installed by cabal, referenced by my module. After I set -v in GHCi and ran :r, it looks like GHCi is only looking for libraries that are installed globally, not libraries that are installed for the local user:
Could not find module `Text.ParserCombinators.Parsec'
There are files missing in the `parsec-3.1.3' package,
try running 'ghc-pkg check'.
Locations searched:
Text/ParserCombinators/Parsec.hs
Text/ParserCombinators/Parsec.lhs
/Library/Haskell/ghc-7.6.3/lib/parsec-3.1.3/lib/Text/ParserCombinators/Parsec.hi
However, when I'm running GHCi in terminal or via Haskell-Mode in emacs, everything works just fine!
I am wondering if there is something wrong with my configuration in EclipseFP or if I can force GHCi to search for user local modules as well.
By the way, I have already tried -i option to pass the local search path to CHCi
-i~/Library/Haskell/ghc-7.6.3/lib/
but apparently, GHCi is only looking for source files (e.g., Parsec.hs and Parsec.lhs) but not interface files (Parsec.hi) in the specified path.
I would much appreciate it if you can help me experience the joy of Haskell programming in Eclipse!
Thanks!

In Eclipse, a run configuration has been created for your GHCi run on your module. This will give you the exact parameters that are being passed to GHCi. It should reference the user package db and all the packages your module needs (make sure the proper dependencies are in the Cabal file). EclipseFP installs packages in the user db by default, so normally this works fine. You should not need to add specific directories to GHCi in EclipseFP.

Related

C app deployment and managing dependencies in c

I'm new to c development, but I have some experience in other modern languages .so the first thing that I found hard is dependencies and deployment, while we got Gradle, maven, NuGet and pipy and... but in c I find it a bit difficult to manage this process.
for example, I have an app that should use mongo-c-library, log4c,libarchive so basically, in my development environment, I download and unzip all of the tar files of the above libraries and then followed their instruction(usually some make stuff) and installed them in order to include them in code make the code work.
I have studied a bit about CMake but I couldn't get a clear picture of how that could actually solve the problem.
at this moment my best solution is to create an install bash script and zip all dependencies unzipped folder with that install script and then send it to the production server to deploy it.
1.The first question is : is it possible to just copy and past all of .so .h and etc files in /path/of/installed/dependencies/include
and /path/of/installed/dependencies/lib in the destination server libary path.
2.if not what is the faster way?
while I was surfing the CMake source file I found that its developers just use this package source code directly.
cmxxx contains the xxx sources and headers files.
3.how can apt-get and Linux package manager help in the deployment process?
2 first question was more about dependencies. imagine we have a simple c app and we want to install(build and make a useable executable file) quickly. how it can be related to .deb packages.
1.The first question is : is it possible to just copy and past all of .so .h and etc files in /path/of/installed/dependencies/include and /path/of/installed/dependencies/lib in the destination server libary path.
Yes, technically it's possible. That's essentially what package managers do under the hood. However, doing that is a colossal mistake and screams bad practices. If that's what you want then in the very least you should look into package managers to build up your own installer, which handles this sort of stuff already for you.
2.if not what is the faster way?
You're actually asking an entirely different question, which is: how should I distribute my code, and how do I expect users to use/deploy it?
If you want users to access your source code and build it locally, as you've mentioned cmake then you just to set up your project right as cmake already supports that usecase.
If instead you just want to distribute binaries for a platform then you'll need to build and package that code. Again, cmake can also help you on that one, as cmake's cpack supports generating some types of packages like DEB packages used by Debian and Ubuntu, and which are handled by apt.
3.how can apt-get and Linux package manager help in the deployment process?
apt is designed to download and install packages from a repository.
Under the hood, apt uses DEB packages, which can be installed with dpkg.
If you're targeting a system that uses apt/deb, you can build DEB packages whenever you release a version to allow people to install their software.
You can also go a step beyond and release your DEB packages in a Personal Package Archive.
You would typically NOT download and install source packages. Instead you should generally rely on the libraries and development packages of the distribution. When building your own package you would typically just reference the packages or files that your package is dependent on. Then you build your own package and you're done. Upon installation of your package, all dependencies will automatically be resolved in an appropriate order.
What exactly needs to be done is dependent on the package management system, but generally the above statements apply. Be advised, package management apparently is pretty hard, because so many 3rd party developers screw it up.

CMake: how to specify from command line where to look for locally installed libraries

I am building locally a dependencies and installing in a local directory. Now I would like to tell CMake to look into that local directory for include and libraries, in addition to all the standard places.
I tried this:
cmake -D CMAKE_LIBRARY_PATH=`realpath ../target`/lib CMAKE_INCLUDE_PATH=`realpath ../target`/include .
But it did not work. Any idea?
You can use the
find_library()
command to search for libraries.
With
include_directories()
you tell cmake where to look for include files
You can first add the folder to your PC's system environment, e.g. called PersonalLib_DIR that points to the folder. Then you can add it for include and libraries by accessing $ENV{PersonalLib_DIR} via CMake:
For include:
include_directories($ENV{PersonalLib_DIR})
For libraries (assume you want to link the aLib.lib under the folder):
target_link_libraries(youProject $ENV{PersonalLib_DIR}/aLib)

How to manage libstdc++.so.6: wrong ELF class: ELFCLASS64 at computer cluster

I have a problem with the libstdc++.so.6 library when I execute a program in MATLAB. The code works fine on my laptop and my desktop, which is why I'm sure the problem is a library or linking compatibility issue:
/home/arturo/Virality/viral_cluster_ml/Viral_features/code/segment_pedro/segment: error while loading shared libraries: libstdc++.so.6: wrong ELF class: ELFCLASS64
I've google some answers on how to fix the library, and some say that I should remove the library to later re-install the correct version:
error while loading shared libraries: libstdc++.so.6: wrong ELF class: ELFCLASS64
The problem is that I can't afford the luxury to delete a library, because I am ssh'ing to a cluster at the lab I'm working in. I really wouldn't want to mess up any programs that are running at the cluster, so isn't there another way of fixing this problem? I'm hoping a solution similar to:
sudo apt-get install libstd++6
that doesn't require me to delete or modify any files, but rather to install them.
Or maybe the error is that I'm not linking the library correctly?
The file does exist, as when I use
locate libstd++.so.6
the computer finds it at these directories:
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
/usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6
/usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6.0.13
/usr/local/MATLAB/R2012b/toolbox/sldv/sldv/polyspace-dvo/lib/x86-linux/libstdc++.so.6
/usr/local/MATLAB/R2012b/toolbox/sldv/sldv/polyspace-dvo/lib/x86-linux/libstdc++.so.6.0.13
/usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6
/usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6.0.13
/usr/local/MATLAB/R2013a_DCS/sys/os/glnxa64/libstdc++.so.6
/usr/local/MATLAB/R2013a_DCS/sys/os/glnxa64/libstdc++.so.6.0.13
/usr/local/Matlab_R2012a/bin/glnxa64/libstdc++.so.6
/usr/local/Matlab_R2012a/bin/glnxa64/libstdc++.so.6.0.13
/usr/local/Matlab_R2012a/sys/os/glnxa64/libstdc++.so.6
/usr/local/Matlab_R2012a/sys/os/glnxa64/libstdc++.so.6.0.13
/usr/local/Matlab_R2012a/toolbox/sldv/sldv/polyspace-dvo/lib/x86-linux/libstdc++.so.6
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyo
I've also tried setting the path to the the file before running MATLAB, without anyluck:
LD_LIBRARY_PATH=/usr/lib64:/home/arturo/Virality/viral_cluster_ml/Viral_features/code/scene_sun ./matlab
Similar link and problem:
http://www.linuxquestions.org/questions/linux-newbie-8/apt-get-messed-up-812346/
Problem was solved by recompiling a subfolder of the code on the cluster.

What is the right way to install header files from some package?

I want to build some package from source (e2fsprogs to be more concrete) and install its header files to my system. After that I will delete the build tree so it will not be accessible anymore. What is the right way to do this?
When I want to install program, I make simply:
$ ./configure
$ make
# make install
What are the equivalent actions when I want to install headers?
For e2fsprogs, quoting verbatim from the INSTALL file shipped with the sources:
7) Install the include files and libraries
You can run `make install-libs' to install the include files and
libraries. Please note that this installation is not needed for the
programs to work. It is only needed if you expect to develop other
programs using the libraries or if you want to compile other program
using these libraries (like the 4.4BSD dump and restore port).
More generally though, when I want to find out what is the 'proper' way to install something that has worked for others, I look at:
What the package looks like, in my favourite distro
How the package is built for my favourite distro

Any possible way to use Tokyo Cabinet in Eclipse?

Just spend 3 straight hours trying to solve the java.lang.UnsatisfiedLinkError: no jtokyocabinet in java.library.path problem in Eclipse in Linux.
Downloaded TC and TC-Java sources,
Built them both using ./config --prefix=/usr (so everything "JNI" related should be in /usr/lib)
Set the LD_LIBRARY_PATH=/usr/lib and CLASSPATH="$CLASSPATH:/usr/local/lib/tokyocabinet.jar" and exported both in .profile
Imported tokyocabinet.jar into the project.
Am I missing a setting other than the proper -Djava.library.path=. settings? I can't even find anything on the net about jtokyocabinet on the web or in the documentation. What's the secret sauce to getting this thing to work?
try to make a link to libjtokyocabinet.so...0 in your JAVA_HOME/jre/lib/i386.
it is because your code can not find tokyocabinet's *.so and *.a files, usually they are in /usr/local/lib, run the following command:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
and then try your code again.
Have the same problem, in my case, using OpenSUSE 12.3 64 bits and Eclipse.
First, the kyotocabinet-java package can be downloaded from this repository:
http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_12.3/
This package provide /usr/lib64/libjkyotocabinet.so.1.1.0 that is the library used by the kyotocabinet jar you can get from maven or the official site.
Looking for this lib I found that there is created a slink:
xxxx#xxxx:/usr/lib64> ls -al /usr/lib64/libjkyoto*
/usr/lib64/libjkyotocabinet.so.1 -> libjkyotocabinet.so.1.1.0
/usr/lib64/libjkyotocabinet.so.1.1.0
I just created a new slink without the ".1" at the end...
sudo ln -s libjkyotocabinet.so.1.1.0 libjkyotocabinet.so
/usr/lib64/libjkyotocabinet.so -> /usr/lib64/libjkyotocabinet.so.1.1.0
And all worked alright, seems that
System.loadLibrary("jkyotocabinet");
don't work if the library name is ended with something different to ".so"
Yes, you're missing something. Eclipse controls its own classpath, so whatever you set up in the environment outside Eclipse is likely not to have any effect.
You need to go into the properties for your project, find the "Build Path" settings and add the path to your tc.jar (or jars) to your build path there.
It may be easier to set up a /lib directory within your eclipse project, copy your tokyo jar there and add that to your build path. That way, it becomes part of your project (and can move from Eclipse installation to Eclipse installation) rather than being an external system dependency.

Resources