febiosoftware / FEBioStudio

https://febio.org/
MIT License
67 stars 24 forks source link

`Could not find GLEW` error when trying to configure on CMake #84

Closed lokitkhemka closed 7 months ago

lokitkhemka commented 8 months ago

When trying to build FEBioStudio on Windows 11 using CMake for Visual Studio 17 2022, I keep getting the error:

CMake Error at D:/FiniteElement/FEBio/deps/glew/build/cmake/glew-config.cmake:16 (include):
  include could not find requested file:

    D:/FiniteElement/FEBio/deps/glew/build/cmake/glew-targets.cmake
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.24/Modules/FindGLEW.cmake:67 (find_package)
  FindDependencies.cmake:625 (find_package)
  CMakeLists.txt:76 (include)

CMake Error at D:/FiniteElement/FEBio/deps/glew/build/cmake/CopyImportedTargetProperties.cmake:64 (get_property):
  get_property could not find TARGET GLEW::glew.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  D:/FiniteElement/FEBio/deps/glew/build/cmake/glew-config.cmake:56 (copy_imported_target_properties)
  C:/Program Files/CMake/share/cmake-3.24/Modules/FindGLEW.cmake:67 (find_package)
  FindDependencies.cmake:625 (find_package)
  CMakeLists.txt:76 (include)

where D:/FiniteElement/FEBio/deps/glew is the root directory of glew source downloaded from github.

I am also getting the error:

CMake Error at CMakeLists.txt:90 (message):
  Could not find febiolib.lib.  Check FEBio_RELEASE_DIR.
Call Stack (most recent call first):
  CMakeLists.txt:277 (findLib)

CMake Error at CMakeLists.txt:90 (message):
  Could not find febiomech.lib.  Check FEBio_RELEASE_DIR.
Call Stack (most recent call first):
  CMakeLists.txt:277 (findLib)

However, I have already built these files, set their path at the variable FEBio_SDK. Still, it seems CMake cannot find these files.

Any help you can provide will be valuable. Thank you.

lokitkhemka commented 8 months ago

Hi,

I was able to figure out the GLEW errors. I had to add paths of the static and shared libraries in the advanced options of CMake. However, I am still unable to figure out the other errors.

Thank you.

michaelrossherron commented 8 months ago

Again, sorry for the delayed response. Ideally, setting the FEBio_SDK CMake variable to the root directory of your FEBio repository should allow the CMake script to automatically find the libraries. However, if that's not working you can fix it manually. Open the CMake GUI and point it to FEBioStudio. Click the Advanced checkbox to see all of the options and then set the FEBio_LIB_DIR CMake variable to the lib directory in your FEBio build directory. (e.g. C:/path/to/FEBio/cmbuild/lib/). You may have Release or Debug directories inside that lib directory, but do not set the variable to point to either of those. Just set it to point to the lib directory.

Let me know if you run into any further issues.

Michael Herron

lokitkhemka commented 8 months ago

Hi, sorry but that didn't resolve the errors. I even tried setting FEBio_LIB_DIR to D:/FiniteElement/FEBio/build/lib. Still I have the same error. I really have no idea why this is happening because ./Release and ./Debug clearly has all the needed .lib files and still CMake is not able to find them.

EDIT: For some reason, CMake was able to find it after some time. So, this particular error is resolved. However, when trying to build the project in Visual Studio, I keep getting the error Invalid or corrupt file for glew32.dll.

My glew related settings for are attached below: cmake-gui_YKScf888sW

I hope this will suffice. Thank you so much for your help so far.

michaelrossherron commented 8 months ago

Hmm. That GLEW error is a bit odd. I think that you actually need to set the GLEW_SHARED_LIBRARY_RELEASE and GLEW_SHARED_LIBRARY_DEBUG CMake variables to point to the glew32.lib files, not the dll files. On Windows, there are two different files that are created when you build a shared library. One is the runtime library (the dll file) and the other is the link library (the lib file). When you're linking at compile time, you actually need to point the linker to the link library (the lib file), not the runtime library. The runtime library (dll) is what's needed by the linker when the program launches. This can be confusing, because lib is also the file extension used for static libraries on Windows. I suspect that you don't actually have static versions of the GLEW libraries, and that those lib files are actually just the link libraries for the dlls that you built.

I don't often work on Windows, and so I'm not 100% sure that this is the issue you're running into, but I'd give it a try and see if it works.

Michael Herron

lokitkhemka commented 8 months ago

Hi, your solution worked, for static library, I was supposed to link with glew32s.lib and for the shared library, I was supposed to point to glew32.lib. It worked out.

However, I am again stuck with an error. MGgKqId3Vw This error is related to OpenCASCADE. Do I have to build OpenCASCADE from source, I just used OpenCASCADE windows installer.

Sorry to keep troubling you, but I am really close to running it.

EDIT: it seems that the entry point is probably within tbb.dll, but why is it looking inside the wrong dll file. I keep getting this warning

'FEBioStudio2.exe' (Win32): Loaded 'D:\OpenCASCADE-7.5.0-vc14-64\opencascade-7.5.0\win64\vc14\bin\TKernel.dll'. Module was built without symbols.

lokitkhemka commented 7 months ago

I managed to run it on Linux, so it is good enough for me.