janmayer / hdtv

Nuclear Spectrum Analysis Tool
GNU General Public License v2.0
17 stars 9 forks source link

Having issue with hdtv installing. cern root installed from source code #37

Open zak-dyer opened 2 weeks ago

zak-dyer commented 2 weeks ago

Hi there,

So I installed and created root from the source code and it opens and runs. import root also works on python. used the pip install hdtv command and when I try to run hdtv I get this:

ak@Zaks-MacBook-Pro ~ % hdtv -- The CXX compiler identification is AppleClang 16.0.0.16000026 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Vdt: /Users/zak/root/root-6.32.06/buildroot/include (found version "0.4") -- ROOT Version 6.32.06 found in /Users/zak/root/root-6.32.06/buildroot/bin/root -- Configuring done (1.2s) -- Generating done (0.0s) -- Build files have been written to: /private/var/folders/1l/yzz3jd2yvgp2q0hl_wxyg80000gn/T/tmp0q82si24 [ 25%] Generating G__calibration.cxx, libcalibration_rdict.pcm, libcalibration.rootmap [ 75%] Building CXX object CMakeFiles/calibration.dir/Gcalibration.cxx.o [ 75%] Building CXX object CMakeFiles/calibration.dir/Calibration.cc.o [100%] Linking CXX shared library libcalibration.dylib [100%] Built target calibration [100%] Built target calibration Install the project... -- Install configuration: "Release" -- Installing: /Users/zak/.cache/hdtv/51119088-63206-24.10/lib/libcalibration.dylib -- Installing: /Users/zak/.cache/hdtv/51119088-63206-24.10/lib/libcalibration.rootmap -- Installing: /Users/zak/.cache/hdtv/51119088-63206-24.10/lib/libcalibration_rdict.pcm Error in : /Users/zak/.cache/hdtv/51119088-63206-24.10/lib/libcalibration.so does not exist in /Users/zak/.cache/hdtv/51119088-63206-24.10/lib:/Users/zak/root/root-6.32.06/buildroot/lib:/Users/zak/root/root-6.32.06/buildroot/lib::.:/Users/zak/root/root-6.32.06/buildroot/lib:/usr/local/lib:/usr/X11R6/lib:/usr/lib:/lib:/lib/x86_64-linux-gnu:/usr/local/lib64:/usr/lib64:/lib64::/Users/zak/root/root-6.32.06

Entirely lost as to how to fix this. Any help would be greatly appreciated.

janmayer commented 2 weeks ago

Hi!

I don't have a Mac so I can't test that, but I have these notes from Liam Gaffney from a few years ago:

* By default, dynamic libraries built on macOS have the .dylib extension, not .so:

    I fix this just by changing "lib%s.so" to "lib%s.dylib" in hdtv/rootext/__init__.py but there is probably a better way to do this to include both possibilities.

* By default, ROOT is not built with X11 support on macOS:

    I change all instances of #include "TGX11.h" to  #include "TVirtualX.h", which maintains support for X11 in any case (ROOT recommended method).
    - hdtv/rootext/display/View.hh
    - hdtv/rootext/display/[Painter.cc](http://painter.cc/)
    - hdtv/rootext/display/[XMarker.cc](http://xmarker.cc/)

* Locations for libraries etc installed with MacPorts is missing from CMakeLists:

    I added /opt/local/include and /opt/local/lib to the target_include_directories and target_link_directories, respectively.
    - hdtv/rootext/calibration/CMakeLists.txt
    - hdtv/rootext/display/CMakeLists.txt

* Calibration symbols missing when linking libdisplay.so/dylib:

    The library for calibration is not included when linking libdisplay.so for some reason. Full error shown below. You can see that it installs the calibration library in some .cache directory in my home folder, but then that is not found by cmake during the next build. Adding ${CMAKE_CURRENT_BINARY_DIR}/lib to the target_link_directories doesn't work, because that gives the path to where the libdisplay.so/dylib will be installed, which is different to libcalibration.so/dylib directory.

    I tried to include ${CMAKE_INSTALL_PREFIX}/lib instead, and this time I get no complaint about the library not existing, but the symbols are still missing. Therefore, I had to add calibration to the list of target_link_libraries, and then it works!

Not all of these points might be applicable anymore.

Please report back if you get things working or have a different problem - maybe we can develop a permanent fix for that.

zak-dyer commented 2 weeks ago

hi janmayer,

so i]I managed to fix all the error barring: zak@Zaks-MacBook-Pro ~ % hdtv -- The CXX compiler identification is AppleClang 16.0.0.16000026 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found X11: /opt/homebrew/include -- Looking for XOpenDisplay in /opt/homebrew/lib/libX11.dylib;/opt/homebrew/lib/libXext.dylib -- Looking for XOpenDisplay in /opt/homebrew/lib/libX11.dylib;/opt/homebrew/lib/libXext.dylib - found -- Looking for gethostbyname -- Looking for gethostbyname - found -- Looking for connect -- Looking for connect - found -- Looking for remove -- Looking for remove - found -- Looking for shmat -- Looking for shmat - found -- Looking for IceConnectionNumber in ICE -- Looking for IceConnectionNumber in ICE - found -- Found Vdt: /Users/zak/root/root-6.32.06-install/include (found version "0.4") -- ROOT Version 6.32.06 found in /Users/zak/root/root-6.32.06-install/bin/root -- Configuring done (2.1s) -- Generating done (0.0s) -- Build files have been written to: /private/var/folders/1l/yzz3jd2yvgp2q0hl_wxyg80000gn/T/tmpemsci29u [ 5%] Generating G__display.cxx, libdisplay_rdict.pcm, libdisplay.rootmap [ 11%] Building CXX object CMakeFiles/display.dir/DisplayCut.cc.o [ 16%] Building CXX object CMakeFiles/display.dir/DisplaySpec.cc.o [ 22%] Building CXX object CMakeFiles/display.dir/DisplayFunc.cc.o [ 27%] Building CXX object CMakeFiles/display.dir/DisplayBlock.cc.o [ 33%] Building CXX object CMakeFiles/display.dir/DisplayStack.cc.o [ 38%] Building CXX object CMakeFiles/display.dir/View1D.cc.o [ 50%] Building CXX object CMakeFiles/display.dir/DisplayObj.cc.o [ 55%] Building CXX object CMakeFiles/display.dir/Viewer.cc.o [ 55%] Building CXX object CMakeFiles/display.dir/Marker.cc.o [ 66%] Building CXX object CMakeFiles/display.dir/View2D.cc.o [ 66%] Building CXX object CMakeFiles/display.dir/MTViewer.cc.o [ 77%] Building CXX object CMakeFiles/display.dir/View.cc.o [ 77%] Building CXX object CMakeFiles/display.dir/Painter.cc.o [ 88%] Building CXX object CMakeFiles/display.dir/XMarker.cc.o [ 88%] Building CXX object CMakeFiles/display.dir/YMarker.cc.o [ 94%] Building CXX object CMakeFiles/display.dir/Gdisplay.cxx.o [100%] Linking CXX shared library libdisplay.dylib Undefined symbols for architecture arm64: "HDTV::Calibration::Ch2E(double) const", referenced from: HDTV::Display::DisplayBlock::GetMinE() in DisplayBlock.cc.o HDTV::Display::DisplayBlock::GetMinE() in DisplayBlock.cc.o HDTV::Display::DisplayBlock::GetMaxE() in DisplayBlock.cc.o HDTV::Display::DisplayBlock::GetMaxE() in DisplayBlock.cc.o HDTV::Display::DisplayBlock::GetERange() in DisplayBlock.cc.o HDTV::Display::DisplayBlock::GetERange() in DisplayBlock.cc.o HDTV::Display::Painter::DrawXMarker(HDTV::Display::XMarker, int, int) in Painter.cc.o HDTV::Display::Painter::DrawXMarker(HDTV::Display::XMarker, int, int) in Painter.cc.o ... "HDTV::Calibration::E2Ch(double) const", referenced from: HDTV::Display::Painter::DrawFunction(HDTV::Display::DisplayFunc, int, int) in Painter.cc.o HDTV::Display::Painter::DrawFunction(HDTV::Display::DisplayFunc, int, int) in Painter.cc.o HDTV::Display::Painter::GetCountsAtPixel(HDTV::Display::DisplaySpec, int) in Painter.cc.o HDTV::Display::Painter::GetCountsAtPixel(HDTV::Display::DisplaySpec, int) in Painter.cc.o HDTV::Display::Painter::GetCountsAtPixel(HDTV::Display::DisplaySpec, int) in Painter.cc.o HDTV::Display::Painter::GetYAutoZoom(HDTV::Display::DisplaySpec) in Painter.cc.o HDTV::Display::Painter::GetYAutoZoom(HDTV::Display::DisplaySpec*) in Painter.cc.o ... ld: symbol(s) not found for architecture arm64 c++: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [libdisplay.dylib] Error 1 make[1]: [CMakeFiles/display.dir/all] Error 2 make: *** [all] Error 2 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/bin/hdtv", line 8, in sys.exit(run()) ^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/app.py", line 234, in run App() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/app.py", line 125, in init import hdtv.session File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/session.py", line 29, in from hdtv.fit import Fit File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/fit.py", line 30, in from hdtv.marker import MarkerCollection File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/marker.py", line 24, in import hdtv.rootext.display File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/rootext/display.py", line 4, in hdtv.rootext.dlmgr.LoadLibrary("display") File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/rootext/dlmgr.py", line 79, in LoadLibrary fname = BuildLibrary(name, usrdir) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/hdtv/rootext/dlmgr.py", line 117, in BuildLibrary subprocess.check_call(["cmake", "--build", ".", "-j"], cwd=tmpdir) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '--build', '.', '-j']' returned non-zero exit status 2.

using a virtual machine to simulate ubuntu and install everything other there seemed to work though had the same issues apart from the architecture.

janmayer commented 2 weeks ago

Okay, it needs to link the calibration library (from hdtv/rootext/calibration) to the display, but can't. I'm quite rusty with CMake - maybe its enough to add calibration to target_link_libraries in hdtv/rootext/display/CMakeLists.txt .