-
Notifications
You must be signed in to change notification settings - Fork 113
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
Compiling in Visual Studio? #261
Comments
Only LLVM/Clang and GCC compilers are supported. I would recommend trying to use clang-cl, see https://clang.llvm.org/docs/MSVCCompatibility.html |
Thanks for your answer. I tried opening the folder in Visual Studio (2019 btw) as a CMake project, set the config to clang and I got this error: Do I need to take a more manual approach, so to speak? I also got some error about a config.json not being able to be opened initially. Then later I tried it again by just creating a static library project and adding the files. That made the C++14 error go away, but instead I got an error about that processor cores function in some CMakeLists.txt. Can you tell me how and where I must implement this? Is this some kind of "Cmake function" or whatever? Sorry if that sounds dumb. Or do I just create a normal C++ function like that? |
Honestly, i have no idea. I have never used Visual Studio, and i have never used clang-cl. rawspeed/cmake/compiler-flags.cmake Line 12 in 62f6073
/std:14 , when the compiler is clang-cl.
|
Going back to the original idea of compiling with VS normally (since clang doesn't seem all that well implemented in VS, not giving meaningful errors for example), would you consider doing a change or accepting a pull request to the code where the GCC specific stuff is turned into a macro that is defined conditionally based on the compiler? So for example, in the code itself, #define ATTRIBUTE_CONST __attribute__((const)) and then I could just do my own define in Visual studio that goes: #define ATTRIBUTE_CONST which would in effect just turn it into empty space. Because the problem I have is that the ones with double brackets like Of course I could just do my own fork and leave it like that there, but then I that would create long-term problems with maintaining the change etc., whereas implementing this directly into the main codebase would provide a tiny step towards being more generally compatible without sacrificing the original functionality this stuff was meant to provide. At least that's the way I see it from my limited experience. Let me know what you think. |
I would be open/sympathetic to supporting clang-cl. |
Well, it wouldn't necessarily mean you have to support it explicitly, it would just get rid of some major hurdles that make it impossible. But alright, I'll respect your decision. I'll try and look into the clang thing if I find the time and motivation. Thanks. |
So when I try to properly use the CMAKE gui and I specify the platform toolset as "ClangCL", I get a bit further than usual, but I end up with the same problem with the compiler flag test.
This error doesn't stop the build, it's just marked in red, so I thought I'd mention it. Here's the fatal one:
I tried to comment out this line:
and it got a bit further but ended up failing at:
I strongly suspect I shouldn't be editing that line out, but at least it helped me find another error. |
Not sure if it helps in any way but here's the -help output of the clang-cl.exe:
|
I know nothing about Microsoft C++ or clang, and only a very little about cmake, but I think cmake is trying to test if the compiler you've told it to use supports the C++14 standard. Presumably Darktable has code that uses C++14 features and has told cmake that C++14 is required. For an example, see How can I add a minimum compiler version requisite?. These two pages might be helpful: Microsoft C++ language conformance table and this Enabling C++14 in clang in Visual Studio. If I understand the latter correctly and if I assume that it is accurate, the compiler should enable the latest support it provides. But, it might be worth getting the output of It could also be that clang-cl.exe does not report version information in a way that this cmake file understands. |
You'll just need to add fallbacks to all such places in cmake to also try
Not to me. Someone who cares about that platform and has direct access to that compiler should be doing such porting.
|
So, I've created my own fork and resorted, at least temporarily, to commenting out the part that sets the flag parameter. The reason is this:
The issue referenced when leaving out the CMAKE_CXX_FLAGS appears to be resolved on the CMake tracker so perhaps this is no longer necessary. But if there's evidence to the contrary, I'll be happy to give it another try. In any case, what currently stops me from progressing is the googletest issue.
The error thrown by cmake is: I tried looking into the folder in the binary output folder src/external/googletest but found no source code or anything, just some Cmake stuff. There's also a log file and some other stuff in there but nothing that provides any clue to what went wrong. Any ideas? Specifically, there is a CMakeOutput.log in the CMakeFiles subdirectory of that folder that just says:
|
One thing I think might be the issue is commands like this:
Obviously on Windows there can't be a /usr/src/... My spontaneous solution to this would be to create a subfolder "ext" under "src" and add git submodules with the required libraries. Thoughts? |
... which was part of cmake-3.8, while rawspeed requires 3.10.
Works just fine in windows-based CI. |
Ah, interesting. Okay so my change would then basically be to remove this part:
And replace the message about needing both with a short note that that is no longer necessary. Does that make sense? I'm still very much beginning to understand how cmake works so wanna make sure I'm not breaking anything. So far I only commented that part out. About googletest, thanks, I learned a new thing. Realized there's a checkbox I can set in the CMAKE GUI to activate the downloading and that worked. Curiously, it worked only for googletest and not for the other stuff like zlib, openmp, etc. When I put those checkboxes there, they just get ignored and after the next round of "config", they are deselected again. I also get a bunch of messages from googletest about how some kind of deprecation. Might need to update to a newer googletest version or something? But doesn't seem like a serious error so I'll let that one go. In other news, deactivating the additional libraries at least made the config succeed and I was able to build the projects. Further, I was able to compile the rawspeed subproject but I had to manually remove the "-g0" and "-O3" flags from the compiler settings. Doing that for the single subproject is okay but for the full build of hundreds of projects that might be very obnoxious to do manually. I presume those are gcc-only flags? Clang CL said that -g0 is an unknown argument and that -O3 is an "unused argument", whatever that means. In any case, I was able to compile a .lib and successfully load it into the linker in my other project. Well, not sure if successfully, but at least the compilation finished, which I'm gonna call a success. |
As per, https://gitlab.kitware.com/cmake/cmake/-/commit/f72ba42b7c643b1b217d1b8f6684cec3289e7201#9735efb2f01e32e5293f52150b5e52561787a4ce,
See above, i have already answered that exact question before. |
Alright, I'll prepare a PR if/when I find the time. Haven't done one for a while. Re. the flags, are you referring to your comment about windows-style flags? Bc all the other flags in the VS project are listed with "-" as well and seem to cause no issues, it's only those two he doesn't seem to know what to do with. |
Any news on VS cmake? Or perhaps I can manually add the files to a new project? |
There are no news because no one has volunteered to do the porting. |
99,9% of Visual Studio Windows developers use msvc. The only feasible solution for them therefore would be to build some DLL with rawspeed and even so, this could cause major incompatibilies when two different compilers are used in the same project. Apart from that, this seems a great library and it's a pity I can't use it as of now, but will perhaps try to work on it later. |
Good for them. |
I'm trying to use this in a project I have in Visual Studio, but as a C++ beginner I'm at the end of my wits for now.
The header files I managed to make work by doing this in a newly created rawspeedconfig.h, based on some info from various places:
I also copied a bunch of the code from config.h.in to my rawspeedconfig.h. After that the only remaining issue after compiling was unresolved symbols (all the actual function bodies etc).
But when I include all the other sources, it will just spit out a billion syntax errors and die. Most if it seems to be due to some gcc related stuff. I wanted to use this code as a submodule in git so I don't want to just go rogue and replace all the GCC stuff (and I'm not sure if I should either, since I would likely end up breaking something).
Is there any way at all to compile this code without gcc?
I was thinking of compiling with gcc and using the static library inside Visual Studio but I then read that this is impossible, so I'm back to zero.
The text was updated successfully, but these errors were encountered: