krux02 / opengl-sandbox

just a macro that generates the fuzz you need to deal with OpenGL
139 stars 8 forks source link

"nimble build" fails on Windows - OpenMesh, AntTweakBar, etc. Errors #4

Closed Aligorith closed 4 years ago

Aligorith commented 4 years ago

I'm trying to get the project building on Windows to play with it (using a freshly downloaded Nim install), but nimble keeps failing on the OpenMesh dependency:

$ nimble build
  Verifying dependencies for fancygl@0.3.2
      Info: Dependency on AntTweakBar@>= 1.0.2 already satisfied
  Verifying dependencies for AntTweakBar@1.0.2
      Info: Dependency on sdl2_nim@>= 2.0.6.1 already satisfied
  Verifying dependencies for sdl2_nim@2.0.10.0
      Info: Dependency on glm@>= 1.1.1 already satisfied
  Verifying dependencies for glm@1.1.1
      Info: Dependency on ast_pattern_matching@>= 1.0.0 already satisfied
  Verifying dependencies for ast_pattern_matching@1.0.0
 Installing OpenMesh@>= 0.1.0
    Prompt: OpenMesh not found in any local packages.json, check internet for updated packages? [y/N]
    Answer: y
Downloading Official package list
    Success Package list downloaded.
       Tip: 15 messages have been suppressed, use --verbose to show them.
     Error: Package not found.

Is there a way to disable this dependency or work around this issue?

Aligorith commented 4 years ago

1) I managed to comment out the OpenMesh dependency in the "requires" list in fancygl.nimble, and got the first few examples building. The "openmesh.nim" example doesn't look like it's one of those that's supposed to get built - is it one of the broken ones that the readme refers to?

2) The following errors occurred with the AntTweakBar Nim library that iqm_mesh_loading.exe requires. I should probably file a bugreport of these issues on that library's issue tracker when I get time later, but I thought I'd include some notes here in case it helps anyone out in future.

2a) Include path problems with AntTweakBar.nim --> getAntTweakBarPath()

        ... Error: execution of an external compiler program 'gcc.exe -c  -w -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN -I/cAntTweakBar/include -O3 -Wall -fPIC -fno-strict-aliasing -D__PLACEMENT_NEW_INLINE  -IC:\Apps\nim\lib -IE:\libs\nim\graphics\opengl-sandbox\examples -o C:\Users\Joshua\nimcache\iqm_mesh_loading_d\TwEventWin.c.o C:\Users\Joshua\.nimble\pkgs\AntTweakBar-1.0.2\cAntTweakBar\src\TwEventWin.c' failed with exit code: 1
        ... C:\Users\Joshua\.nimble\pkgs\AntTweakBar-1.0.2\cAntTweakBar\src\TwEventWin.c:15:10: fatal error: AntTweakBar.h: No such file or directory
        ...  #include <AntTweakBar.h>
        ...           ^~~~~~~~~~~~~~~
        ... compilation terminated.

I managed to patch around that by amending AntTweakBar.nim` (the build-script parts) with the following:

when defined(windows):
  from strutils import strip
  proc getAntTweakBarPath(): string {.compileTime} =
    # On Windows with nim 1.0.2, I'm only getting two lines of output from the "nimble path" command: 1) the path we want, 2) a blank line. 
    result = strip(staticExec("nimble path AntTweakBar"))
else:
  ...  # <-- the existing getAntTweakBarPath() implementation goes here

2b) This however is then followed by errors about #include "release64\TwDirect3D11_LineRectVS.h" not being found in cAntTweakBar\src\TwDirect3D11.cpp.

From the comments in that file, it looks like those header files need to be generated by a pre-compilation step (using the standalone shader compiler - fxc.exe).

I temporarily tried working around this by just commenting out the TWDirect3D<XX>.cpp includes. This gets fixes the immediate compile problem, but ends up breaking later when linking (as lots of event symbol lookups fail. Hopefully I'll manage to get this working, otherwise, I'll just comment out the iqm_mesh_loading example from being built.

2c) The -lGL thing linker flag fails on Linux. AntTweakBar.nim needs to be modified so that Windows will pass -lopengl instead.

krux02 commented 4 years ago

Thank you for testing this project on windows. While I use platform independent libraries only, I do not own any version of windows to test things on. Your feedback is well received.

regarding AntTweakBar, since I am the author of those wrappers as well, thank you for your feedback. I didn't know that AntTweakBar had this complicated build process to work on windows. Maybe you can disable the compilation of TwDirect3D11 for now somehow, since the OpenGL backend will be used here anyway.

You may also disable the AntTweakBar code in iqm_mesh_loading. The UI here really is just sugar, nothing important. I integrated it for the reason to have something with AntTweakBar, not because AntTweakBar does something important here. Maybe I should move give AntTweakBar anther example when it causes trouble.

regarding 2c) yes that should be easy to fix. Sorry for that one.

There is another thing. Yesterday I found out there is a bug in Nim that causes trouble in this project: https://github.com/nim-lang/Nim/issues/12670 This certainly causes problems in some examples where wrong glsl types are generated.

And yes, regarding OpenMesh, that one is mostly a construction site. I did it mostly as a debugging project to develop the OpenMesh library.

krux02 commented 4 years ago

@Aligorith can you try to run the base example for AntTweakBar here: https://github.com/krux02/nimAntTweakBar/blob/master/twsimplesdl.nim ? I would really like nimAntTweakBar to run on Windows as well and your feedback is very welcome.

regarding the issue from nim-lang, I implemented a workaround, that should work now again.

Aligorith commented 4 years ago

@krux02 I've been taking a look at getting that compiling

What I've had to do so far:

I wonder whether it might be easier to wrap this library on Windows by using dynamic calls to a pre-built .dll like the SDL libraries do currently, in order to bypass the whole MSVC-path/environment problems that building the library from source each time would entail. I might give that a try when I get time over the next few days.

krux02 commented 4 years ago

I think it might be best to drop out the DirectX backend for the AntTweakBar wrapper. It is mostly causing trouble and there isn't any DirectX wrapper in sight, so these backends can't be used anyway.

Regarding your error messages. I am not used to Microsoft error messages. I don't know what this prefix __imp_ means. To my knowledge everything that starts with __ is reserved for compiler specific symbols. And then I also can't find anything in the source that starts with __imp_. Without the prefix these symbols should be defined in TwMgr.cpp.

krux02 commented 4 years ago

OK, I disabled AntTweakBar in iqm_mesh_loading by default for now. It should build now. Please test it again. Thanks a lot for tying out this project, and many thanks more for providing feedback.

krux02 commented 4 years ago

By now the project ditched nimble in favor of submoduled and a nim.cfg file. I dislike submodules, but I disleke them less than nimble. The project should be reproducable by now. Tell me if I can close the issue.

krux02 commented 4 years ago

I just assume the issue has been fixed or the interest is just gone by now. Anyway feel free to reopen a new issue, if there are still problems left.