how to compile with liblbfgs? - c++

I downloaded liblbfgs from here and compiled the sample code from its document with
g++ sample.cpp -o sample -llbfgs
Then I run
./sample
But it says
./sample: error while loading shared libraries:
liblbfgs-1.10.so: cannot open shared object file: No such file or directory
Are there any extra flags that I have to add? Thanks!!

Solution for similar problem is discussed here. You may have to do ldconfig, as you have recently installed a shared library.

Related

Can't build C++ project with XLNT library

I am trying to build a sample project using the XLNT-Library under Windows 8 using MinGW g++.
The code is the sample code found in the github Documentation:
#include <xlnt/xlnt.hpp>
int main()
{
xlnt::workbook wb;
xlnt::worksheet ws = wb.active_sheet();
ws.cell("A1").value(5);
ws.cell("B2").value("string data");
ws.cell("C3").formula("=RAND()");
ws.merge_cells("C3:C4");
ws.freeze_panes("B2");
wb.save("example.xlsx");
return 0;
}
I downloaded the library as a zip file, extracted it and copied the folder [xlnt-master-root]\include\xlnt into the folder where my main.cpp resides and then tried to compile it with this command:
g++ -std=c++14 -lxlnt -Ixlnt/include .\excelTest.cpp -o excelTest.exe
But this results in the following error:
c:/users/s/documents/myprogramms/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe:
cannot find -lxlnt
I also tried copying the [xlnt-master] folder to the main.cpp location and tried to compile it again with the same result.
I can program in C++ but I have not worked with libraries before.
Can you please give me a hint how to use and compile the project with the library correctly?
FYI: I also tried building the library with with cmake as found here.
Although cmake was a success, make -j8 won't do anything because no Makefile is created in the build directory.
Maybe I went wrong here?
Thanks for your help...
using the lasted visual studio 2017,you can build the xlnt library automatic.
you can download the library below:
https://1drv.ms/f/s!AvyYANq3dYDem1g9MtINWWw7CyTH

Cygwin won't compile any c++ files

When I try to compile my Fibonacci.cpp file I get this from the compiler:
$ g++ Fibonacci.cpp
C:/cygwin/lib/gcc/i686-pc-cygwin/4.9.3/cc1plus.exe: error while loading shared libraries: cygcloog-isl-4.dll: cannot open shared object file: No such file or directory
I've downloaded the gcc-g++: GNU Compiler Collection (C++) library and it's not working. Am I missing another library?
You need to install the libcloog-isl4 package when you run the setup.exe. You are missing that file in your C:/cygwin64/bin directory. I had the same problem and I was also missing cygisl-10.dll and I had to install libisl10 package.
See this cannot compile anything with gcc on cygwin32; missing cygisl-10.dll.
Unfortunately I'm getting a different error now that I solved that, so I'm not guaranteeing a fix.

error while loading shared libraries: libjvm.so:

I am trying to make this JNI example works.
I am able to compile all the files but I can not launch the executable because of this error :
./TEST: error while loading shared libraries: libjvm.so: cannot open shared object file: No such file or directory
I have checked all the paths, the compilation goes without errors...
Now I think that is linked with my operating system (OpenSuse) or my java version :
I am running java 1.7 and the code use the JVM 1.6 (vm_args.version = JNI_VERSION_1_6;).. and JNI_VERSION_1_7 does not seem to exist.
I found a very good example, one of the best on the web I guess, because the author wrote down the paths of each file he uses : Tutorial
I still had a library problem so here is how I managed to get all working :
Create the java and the cc files (cf. link above) in the same repertory.
Edit the following line in main.cc with the path of your Java class :
{ const_cast<char*>("-Djava.class.path=PATH_TO_JAVA_CLASS"), NULL }
Go the repertory and compile the java class :
$ javac Main.java.
Look for the file libjvm.so on your computer. Once you have
found it, edit the lib path as follows :
$ LIBPATH=PATH_TO_LIBJVM.SO
(for me it was in /usr/lib/jvm/java-1.7.0-openjdk-1.7.0/jre/lib/amd64/server
)
Export the lib path
$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBPATH}
Now you just have to compile the main.cc file. I had a problem because jni.h was not found:
a. Find jni.h (for me /usr/lib/jvm/java-1.7.0-openjdk-1.7.0/include/)
b. If you have a problem with jni_md.h, create a symbolic link of jni_md.h in the same folder of jni.h
c. Compile as follows :
$ g++ -Wall main.cc -I/PATH_TO_jni.h -L${LIBPATH} -ljvm
Should be good :)
./a.out
Hello, world!
Hello, Java!

lib-xerces not found

I'm using xerces(http://xerces.apache.org) lib to parse a XML file in C++, so I downloaded the source code, ran a ./configure, make, make install, so when I execute
g++ -o parser parser.cpp
and I execute ./parser, I get:
./parser: error while loading shared libraries: libxerces-c-3.1.so: cannot open shared object file. No such file or directory.
When I search into /usr/lib or /lib I can't find where libxerces-c-3.1.so did go, nor where libxerces-c-3.1.so is. Does someone know how could I solve that problem?
Did you try running ldconfig command?
ldconfig examples
The only thing that I can think of is some issue with symbolic links, if it has crossed linking successfully.
Related question :https://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s

Program can't find libboost_program_options.so.1.47.0 at runtime

Since I don't have root permission to install Boost C++ library, I installed it under my home local. When compiling, I used:
g++ -I/home/name/local/boost_1_47_0 -L/home/name/local/boost_1_47_0/stage/lib foo.cc -o foo -lboost_program_options
but at runtime, it goes:
error while loading shared libraries: libboost_program_options.so.1.47.0: cannot open shared object file: No such file or directory
and ldd gives:
libboost_program_options.so.1.47.0 => not found
I also tried to specify the absolute path of the library, but it doesn't work either:
g++ /home/name/local/boost_1_47_0/stage/lib/libboost_program_options.so.1.47.0 -I/home/name/local/boost_1_47_0 -L/home/name/local/boost_1_47_0/stage/lib foo.cc -o foo
Try using the LD_LIBRARY_PATH environment variable to instruct the run-time linker where to find the library:
export LD_LIBRARY_PATH=/home/name/local/boost_1_47_0/stage/lib
Then rerun your application.
I'm a newbie, so don't take my words too seriously. Furthermore, this question is several months old and I guess solved long ago. Nevertheless, here's what I think.
You specify the library path to the linker, so the program compiles and links fine. However, when you try to execute the binary, it looks for the libs in the environment defined path.
I guess this can be fixed by typing into bash
export PATH=$PATH:path_to_your_library_folder
Best Regards
Miroslav