1

Title says most of it.

Background: I develop on Windows. I do not have access to a Visual Studio licence (not allowed to use the community edition), and therefore not to MSVC. I need to compile third-party code (https://github.com/google/googletest/blob/master/googletest/README.md) into a .lib file for use in a special IDE (CVI/Labwindows). I tried using git bash (so MinGW, I suppose) with cmake and gcc/g++ to compile stuff, but because of this my code compiles into .a files instead of .lib. I have not found if there are any appropriate flags that I can set to make it compile into .lib. All searches for "compiling .lib files" end up mentioning Visual Studio.

Thanks for any clarity on the issue.

  • 1
    visual studio is an IDE. To compile code you need a compiler. IDEs typically come including a compiler, but you need no IDE to compile code – 463035818_is_not_an_ai Dec 16 '20 at 09:15
  • Welcome to Stackoverflow! AFAIR, in gcc world a lib simply has the extension `.a`. Try renaming to `.lib` and use it as that. You might have problems with different name mangling or calling conventions when mixing gcc and cl compiled code, though – king_nak Dec 16 '20 at 09:16
  • Visual C and C++ compilers are free to download. – n. m. could be an AI Dec 16 '20 at 09:24
  • This isn't really an issue about .lib files (which is only a file extension after all). It's about doing something which is compatible with the 'special IDE (CVI/Labwindows)' that you are using. So really what you need to do first is find what compiler CVI/Labwindows is using, and then use that, whatever it is. – john Dec 16 '20 at 09:25
  • A quick google tells me that CVI/LabWindows uses clang. So that's the compiler you need to use. Ref https://zone.ni.com/reference/en-XX/help/370051AG-01/cvi/programmerref/labwindowscvicompiler/ – john Dec 16 '20 at 09:28
  • @n.'pronouns'm. They are? That's great news! I will look and see if I can download them and force cmake to use them instead! – guybrush_threepwood Dec 16 '20 at 09:29
  • @guybrush_threepwood The community versions are free for non-commercial use. But I think you are going to be disappointed, I can't see a VS produced library being compatible with clang, but I might be wrong. – john Dec 16 '20 at 09:30
  • @john: this prevents usage for any professional use... – Serge Ballesta Dec 16 '20 at 09:31
  • @john Yes, it's true that CVI uses clang (albeit one that only can compile C89 code...). My fear is that even if I tell cmake to use clang it will still compile into .a files. I will look closer at using clang as well, that would probably be more useful in the long run than visual c/c++. – guybrush_threepwood Dec 16 '20 at 09:36
  • clang on Windows is supposed to be compatible with Visual C/C++ compiler, but anyway I recommend you to find CVI/LabWindows guide for building extensions, and follow it. – n. m. could be an AI Dec 16 '20 at 09:41
  • Unfortunately, it seems that to use the visual c++ build tools you need a visual studio license, as per the top comment in the accepted answer of this: https://stackoverflow.com/a/22290557/14399618. Second source: https://social.msdn.microsoft.com/Forums/en-US/08d62115-0b51-484f-afda-229989be9263/license-for-visual-c-2017-build-tools?forum=visualstudiogeneral So this does not solve the problem for me at least. If I had a visual studio license I would just use visual studio to solve my problem. I suppose clang is the only possible way out at the moment. – guybrush_threepwood Dec 16 '20 at 11:32
  • You could consider using (after asking permission to your manager) [GCC](http://gcc.gnu.org/) as your C++ compiler, with [GNU emacs](https://www.gnu.org/software/emacs/), [GNU make](https://www.gnu.org/software/make/) and [git](https://git-scm.com/). For legal issues, ask your lawyer – Basile Starynkevitch Dec 16 '20 at 11:50
  • @BasileStarynkevitch That's where I started out (as I state in the question). The problem is that gcc compiles the static library into a *.a file, not *.lib, and I don't think they are interchangeable. – guybrush_threepwood Dec 16 '20 at 12:03
  • But why does that matter to you? The user of your library could use GCC also. You just need to document how your library should be used. – Basile Starynkevitch Dec 16 '20 at 12:06
  • @BasileStarynkevitch As I said in the question, I am not building my own library, I want to compile external code pulled from github into a *.lib because the software I use to develop my application requires *.lib. I have already managed to compile the code into *.a files, but it is not what I need. – guybrush_threepwood Dec 16 '20 at 13:17
  • AFAIK, `github` has source code. So pull the source code and compile it. – Basile Starynkevitch Dec 16 '20 at 14:16

0 Answers0