InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.37k stars 660 forks source link

Unable to debug hxx files and h files #4684

Closed xem123 closed 1 month ago

xem123 commented 1 month ago

I recompiled ITK and RTK using the following configuration parameters, and I want to use the debug mode to debug the code. Currently, I can normally enter the cxx files related to RTK during debugging(picture2), but I cannot debug the related .h files and .hxx files, and I cannot enter the source code of the .h files and .hxx files(picture1). What is the reason? Is there something wrong with my configuration? Or did I not check a certain option when using cmak for compilation? I am in hurry,thanks! cmake=3.24 visual studio 2022 ITK=5.3.0 moudle_RTK=on Module_RTK_GIT_TAG=3f0aa3145d03b8cbc7c6d44bbfd03728b531909c fftw-3.3.5-dll64 image image

xem123 commented 1 month ago

I encountered these errors when compiling ITK and RTK, but I ignored them and did not solve the issues. Is it related to the error that I cannot access the hxx and h files? Is it necessary to solve it? How can I solve it? image

xem123 commented 1 month ago

I didn't choose debug, I chose release. Is it because I made the wrong choice that caused this? image

dzenanz commented 1 month ago

Release build mode does not have debug information. RelWithDebInfo has some debug symbols, but many things are optimized away. For full debugging access, you need to build in Debug mode, which you seem be to already doing. But you need a successful build, without any errors.

For Visual Studio generator, CMAKE_BUILD_TYPE is unimportant. The list in CMAKE_CONFIGURATION_TYPES is important. And then selecting build mode in Visual Studio.

xem123 commented 1 month ago

Thanks! When I compiled ITK, I checked the FFTW related options as shown in Figure 1, but during the build process, I encountered many errors related to FFTW as shown in Figure 2. What is the reason for this? Do I need to configure the FFTW path separately in the environment variables, or should I configure the FFTW related libraries in the all_build properties? 1716342366740_92F9B542-FD3E-4354-95FC-DBED9C27C26F 1716342352851_D54B1532-7A16-44dd-8E97-386775D44E96

dzenanz commented 1 month ago

FFTW can be compiled by ITK on Linux (and maybe Mac), but not Windows. If you want to use FFTW on Windows, you have to compile it yourself, or get a pre-compiled version.

You seem to be trying to use CUFFT, which is the least tested back-end by far. Therefore finnicky, and possibly now broken. In my experience, MKL works the best on Windows.

xem123 commented 1 month ago

Thank you very mach

dzenanz commented 1 month ago

Close this issue if appropriate.

xem123 commented 1 month ago

Thanks!I followed your advice and compiled the FFTW library separately before compiling it with ITK. Then, the Build and install processes were completed smoothly without any errors. Then, I placed my project code into the ITK solution in order to access the RTK source code during runtime, as shown in Figure 1. However, I encountered a problem. I cannot use breakpoints to access the source code of rtkFFTProjectionsConvolutionImageFilter.hxx. I added cout to this hxx source code and recompiled it. The cout in this hxx can print to the console normally as shown in Figure 2, but I still cannot access the hxx source code as shown in Figure 3 and Figure 4. And I hope to output the image after padding, so I added some code to save the image in the source code as shown in Figure 5. However, after normal operation, the image I specified was not saved. Why is that? The ability to print cout to the console indicates that the function in hxx is running, but why can't the breakpoint be entered? Why doesn't the code to save the image execute? image image image image image

xem123 commented 1 month ago

I'm sorry to have caused you trouble, as this is my first time using cmake to compile the ITK and RTK libraries, so I'm not sure how to handle some of the issues. Sorry

poretga99 commented 1 month ago

This question is not directly related to the functionality or code behavior of this repository. I suggest it should be closed.

As for debugging, @xem123 I'd suggest you check some general tutorials on how to debug in Visual Studio in combination with CMake.