2

I recently completed a C project that uses GTK and OpenSSL. I have native binaries in linux and they run just great. However my new goal is to make as close to native as I can with a build for windows.

I've tried MinGW and it produces as a exe, however it crashes very easily, and gdb performs poorly when attempting to debug windows builds. It's almost pointless to try to make sense of the binary mess.

So I'm in search of any alternative solutions or perhaps an improved version of this one. How do I build a Linux C project on windows?

  • 1
    How did you debug under Linux? MinGW's GDB should provide you the very same possibilities. Any chance you forgot the debugging information (-g)? Also have you tried using Visual Studio instead? – Mario Dec 18 '16 at 7:47
  • @Mario I did not miss the build information for it's compiling with -O0 -g3. And does visual studio only do C++? Or is that the best way? – Sanchke Dellowar Dec 18 '16 at 7:50
  • Visual Studio supports both C and C++ out of the box and is (IMO) the best way to debug programs you can compile due to all the visual helps, e.g. bring and to pin variable value displays/watch list entries right in your code. – Mario Dec 18 '16 at 7:56
  • @Mario Does visual studio support make files though? What is the windows equivalent? – Sanchke Dellowar Dec 19 '16 at 20:33
  • Multiple ways, I'm posting this as an answer, since it's essentially a solution to your problem. – Mario Dec 20 '16 at 13:55
1

It depends heavily on your approach.

My preferred way is to use CMake to create project files or makefiles based on the current platform. For example, under Linux this would create classic makefiles, while under Windows it would create a VS project. You still only have to maintain the CMake source file(s).

In your case I'd have a look at the Linux Tools for VS extension, considering you can't really debug the GPIO pins on your Windows machine. Further details are in the linked blog post, since this is a bit lengthy to explain and setup. The usage is rather trivial though.

This essentially prepares Visual Studio to only act as a remote IDE. When issuing a build command or starting a debug run, it will upload modified files through SSH, issue the build commands and then connect to the GDB server to perform debugging, everything with the known tools and features from Visual Studio (e.g. visual debugging, watch list, etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.