awsteiner / o2scl

Object-oriented Scientific Computing Library
https://awsteiner.org/code/o2scl
GNU General Public License v3.0
35 stars 14 forks source link

error in compiling o2scl program files #13

Closed ishfaq333 closed 4 years ago

ishfaq333 commented 4 years ago

I installed the o2scl-0.923 version. the installation was fine. but when i started compiling the program files, it shows errors. for example, i wanted to compile hdf_nucmass_io.cpp file:

g++ -Wall -c "hdf_nucmass_io.cpp" (in directory: /home/ishfaq/o2scl-0.924/src/nuclei) In file included from hdf_nucmass_io.cpp:24:0: /usr/local/include/o2scl/hdf_nucmass_io.h:35:10: fatal error: hdf5.h: No such file or directory

include

      ^~~~~~~~

compilation terminated. Compilation failed.

ishfaq333 commented 4 years ago

By compliling in terminal, i was able to locate the hdf5.h file:

ishfaq@ishfaq:~/o2scl-0.924$ locate hdf5.h /snap/o2scl/3038/usr/include/hdf5/serial/hdf5.h /usr/include/hdf5/serial/hdf5.h /usr/local/serial/hdf5.h ishfaq@ishfaq:~/o2scl-0.924/examples$ export CPATH="/usr/local/serial/"

now, I am getting all this:

ishfaq@ishfaq:~/o2scl-0.924/src/nuclei$ g++ hdf_nucmass_io.cpp /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function _start': (.text+0x20): undefined reference tomain' /tmp/ccSWbIR0.o: In function o2scl_hdf::ame_load_ext(o2scl::nucmass_ame&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)': hdf_nucmass_io.cpp:(.text+0x216): undefined reference too2scl_hdf::hdf_file::hdf_file()' hdf_nucmass_io.cpp:(.text+0x24f): undefined reference to o2scl_hdf::hdf_file::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool)' hdf_nucmass_io.cpp:(.text+0x26d): undefined reference too2scl_hdf::hdf_file::get_current_id()' hdf_nucmass_io.cpp:(.text+0x2cf): undefined reference to o2scl_hdf::hdf_file::geti(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int&)' hdf_nucmass_io.cpp:(.text+0x360): undefined reference too2scl_hdf::hdf_file::gets_fixed(std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >&)' hdf_nucmass_io.cpp:(.text+0x407): undefined reference to H5TBread_table' hdf_nucmass_io.cpp:(.text+0x71e): undefined reference too2scl_hdf::hdf_file::close()' hdf_nucmass_io.cpp:(.text+0x73d): undefined reference to o2scl_hdf::hdf_file::~hdf_file()' hdf_nucmass_io.cpp:(.text+0x7e0): undefined reference too2scl_hdf::hdf_file::~hdf_file()'

awsteiner commented 4 years ago

Let me know what OS and compiler you are using and what configure script you are using to install, along with the relevant environment variables.

Using 'snap' might be a good solution for you as well, as that installation is a bit easier.

ishfaq333 commented 4 years ago

Thankyou for your reply. I am using Ubuntu 18. I simply downloaded the o2scl file from the source and then used the. /configure, make, make check and make install commands.

On Wed, 29 Jan 2020, 7:54 pm Andrew W. Steiner, notifications@github.com wrote:

Let me know what OS and compiler you are using and what configure script you are using to install, along with the relevant environment variables.

Using 'snap' might be a good solution for you as well, as that installation is a bit easier.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awsteiner/o2scl/issues/13?email_source=notifications&email_token=AOM7YEDKSAKZIDHL67MWM53RAGGSZA5CNFSM4KNALWC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKHLOFY#issuecomment-579778327, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOM7YEEC6BXVOPPTHXI66Z3RAGGSZANCNFSM4KNALWCQ .

ishfaq333 commented 4 years ago

Using Geany software to run the programs, it showed the error: hdf5.h not found.

While running in terminal, this error repeated and I omitted it by : ishfaq@ishfaq:/o2scl-0.924/examples$ export CPATH="/usr/local/serial/"

But after this, it showed the error shown in my 2nd comment.

awsteiner commented 4 years ago

Each machine is configured differently, and with the different Ubuntu/HDF5 versions it is hard to provide an answer that will work for them all. The basic problem is that you need to tell the configure script where to find the header files (using CXXFLAGS) and the library files (using LDFLAGS).

Try

CXXFLAGS="/usr/include/hdf5/serial/" LDFLAGS="/location/to/libhdf5" ./configure

and then doing make and make install. I don't think the CPATH variable is relevant here.

It appears from your comments above like you might have a snap and a traditional installation on the same machine, and I don't know how well these will work together. It also appears you have hdf5 headers in /usr/include/hdf5/serial/, which is a bit surprising to me, as I think it is typically in /usr/lib/x86_64-linux-gnu/hdf5/serial/include .

awsteiner commented 4 years ago

Oh! It turns out /usr/lib/x86_64-linux-gnu/hdf5/serial/include is just a symbolic link to /usr/include/hdf5/serial . In that case you might try (all one line)

CXXFLAGS="/usr/include/hdf5/serial/" LDFLAGS="/usr/lib/x86_64-linux-gnu/hdf5/serial" ./configure

ishfaq333 commented 4 years ago

The. /configure, make commands work just fine. "Make" Commands a lot of time. When all this is complete and i go to src folder and open up any program in Geany/Terminal, it shows errors I mentioned earlier.

On Wed, 29 Jan 2020, 8:54 pm Andrew W. Steiner, notifications@github.com wrote:

Oh! It turns out /usr/lib/x86_64-linux-gnu/hdf5/serial/include is just a symbolic link to /usr/include/hdf5/serial . In that case you might try (all one line)

CXXFLAGS="/usr/include/hdf5/serial/" LDFLAGS="/usr/lib/x86_64-linux-gnu/hdf5/serial" ./configure

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awsteiner/o2scl/issues/13?email_source=notifications&email_token=AOM7YEHMVF6G44UXC64VJU3RAGNSZA5CNFSM4KNALWC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKHSI7Q#issuecomment-579806334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOM7YECNNDUI4UGW6HFZFW3RAGNSZANCNFSM4KNALWCQ .

awsteiner commented 4 years ago

Yes, but the point is that even if the ./configure command appears to succeed, if not properly done then make (and/or make install) may fail. Can post the output of the ./configure command?

ishfaq333 commented 4 years ago

Screenshot from 2020-01-29 21-05-58 I ran the commands you mentioned above and then ./configure. see the picture about the output.

Now If I run "make" command, it prints a lot of confusing results and keeps running for a long time.

ishfaq333 commented 4 years ago

Screenshot from 2020-01-29 21-42-00 This is the output after command "make check" It took a lot of time, but all the tests are passed. make install is also complete.

what should i do next?

awsteiner commented 4 years ago

Ah great. I'm glad it worked!

From here, you can do anything you like. You may want to begin by compiling the examples and adapting them to your use.

ishfaq333 commented 4 years ago

Screenshot from 2020-01-29 22-15-22

When I am trying to compile any program in Geany, here is the output:

awsteiner commented 4 years ago

Ah I understand. Geany is a program that I don't have and I am not familiar with, so I cannot help you with using o2scl in that environment.

ishfaq333 commented 4 years ago

any programs that you suggest, that o2scl can work with. or what commands need to be used to run these programs in the terminal

ishfaq333 commented 4 years ago

whatever software/Terminal I use to run o2scl files, it always shows the same error: hdf5.h no such file or directory

ishfaq333 commented 4 years ago

Screenshot from 2020-01-30 11-12-22