Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when building an application using Statismo #21

Closed
NahomKidane opened this issue Feb 22, 2024 · 4 comments
Closed

Issue when building an application using Statismo #21

NahomKidane opened this issue Feb 22, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@NahomKidane
Copy link

I used external ITK, VTK & Eigen to build Statismo. Although I faced some problems while using external HDF5, I managed to build and run tests using ITK_HDF5 instead.

However, now I'm encountering an error while making a simple Statismo project using cmake. Could you please suggest a solution to resolve this issue?
LNK2019 error: unresolved external symbol "__declspec(dllimport) public: class H5::H5File & __cdecl H5::H5File.

buildshapemodel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class H5::H5File & __cdecl H5::H5File::operator=(class H5::H5File const &)" (_imp??4H5File@H5@@QEAAAEAV01@AEBV01@@z) referenced in function "public: virtual void __cdecl statismo::DataManagerBase<class itk::Mesh<float,3,class itk::DefaultStaticMeshTraits<float,3,3,float,float,float> >,class statismo::BasicDataManager<class itk::Mesh<float,3,class itk::DefaultStaticMeshTraits<float,3,3,float,float,float> > > >::Save(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)const " (?Save@?$DataManagerBase@V?$Mesh@M$02V?$DefaultStaticMeshTraits@M$02$02MMM@itk@@@itk@@v?$BasicDataManager@V?$Mesh@M$02V?$DefaultStaticMeshTraits@M$02$02MMM@itk@@@itk@@@statismo@@@statismo@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z)
2>C:\Projects\NahomProjects\Repositories\statismo-build-examples\ITK\build\Release\statismo-app.exe : fatal error LNK1120: 1 unresolved externals

@NahomKidane NahomKidane added the bug Something isn't working label Feb 22, 2024
@NahomKidane NahomKidane changed the title Issue when building an Application using Statismo Issue when building an application using Statismo Feb 22, 2024
@kenavolic
Copy link
Collaborator

I see you opened an issue (statismo/statismo#285) on the statismo repo as well thus which version do you use?

We use this fork internally and managed to build it on Ubuntu 20.04/Ubuntu22.04 with external hdf5 version 1.14. I remember the compilation on Windows is a bit less stable and unfortunately not stressed anymore because everybody works on Linux. I don't have the time to test under Windows but will be glad to add the fix to the fork if you manage to solve the issue.

@NahomKidane
Copy link
Author

Hi @kenavolic ,

Thank you for getting back to me.

I am actually using this version. I had issues with external hdf5 1.10.11 and had to use ITK_HDF5 ( ITK 5.3). All the unit tests worked, but I got the above error when trying to include it in a separate project. Maybe I do not include it correctly? Any suggestions?

@kenavolic
Copy link
Collaborator

The project is not maintained anymore because we had no more time to investigate all the build and link issues on many platforms. Moreover, it was too time-consuming to transfer all major algorithm evolutions from Scalismo back to statismo.

Therefore I can only gives you the setup that is working right now in our lab aka:

  • OS: Ubuntu 20.04/22.04 with default g++ installed version
  • ITK 5.3
  • Hdf5 1.14 (external deps)

I unfortunately cannot investigate your issue that can have many causes. You can explore the generated ITK hdf5 dlls for exported symbols or retry an external build of hdf5 with the 1.14 version.

Make sure to install all dependencies properly after build (cmake --install ...) and to use the installed cmake config files in your final app (xxxConfig.cmake)...

Good luck anyway. It reminds me all the trouble I got with HDF inclusion...

@NahomKidane
Copy link
Author

NahomKidane commented Feb 26, 2024

Hi @kenavolic,

I was able to compile and resolve the issue. When linking it to my test code, the HDF5 required a STATIC preprocessor definition. The compiler defined it as dynamic instead of static (H5_BUILT_AS_STATIC_LIB).

All tests pass, and I am currently using it as a library. However, I am getting this error when building the CLI examples. I am still trying to figure out how to fix it.
For example:

Compiling statismo-fit-surface, I get the error below, which points to statismoFittingUtils.h. It might be a namespace-related issue, but I can't figure out how to fix it. Any suggestions?

image

Thank you once again for your support. I truly appreciate any assistance you can offer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants