mikegashler / waffles

A toolkit of machine learning algorithms.
http://gashler.com/mike/waffles/
86 stars 33 forks source link

Using waffle with cygwin g++ in windows OS #29

Open aveshd opened 7 years ago

aveshd commented 7 years ago

Hi,

I am trying to make small test program in cygwin environment. Here is what I did

include

include "GMatrix.h"

using namespace GClasses; int main(int argc, char const *argv[]) { GMatrix M; GCSVParser p; p.parse(M, "data/data.csv"); std::cout << "Finished" << std::endl; return 0;

}

I am trying to follow the help documentation, just to test the plumbing. But when I try to compile using following command

g++ -std=c++11 -g -I /lib/waffles/GClasses -L /lib/waffles/GClasses -lGClasses main.cpp -o main.exe

I get following error, which looks more like linker error. I built the GClasses.lib library in MSVC 2015. But it is not working. I also did the search on the google and found a link but not much.

Please let me know if I am missing something obvious, please note I have little to none experience with MSVC, I mainly work with GCC.

Please pardon my ignorance if I missed something trivial.

Here is the error:

undefined reference to `GClasses::GMatrix::~GMatrix()'

undefined reference to `GClasses::GCSVParser::~GCSVParser()'

Thank you, Regards, Avesh

mikegashler commented 7 years ago

I managed to reproduce this error, but I could not figure out how to fix it. My guess is that the Cygwin version of g++ may not know how to link with libraries built by MSVC. I suppose the solution would be to build it all in Cygwin. I have never tried building in Cygwin before, but the code does build on several other platforms (Linux with g++, Mac with clang, Sparc with g++, Windows with MSVC, and someone said he got it working in mingw), so I suspect it can be made to work in Cygwin too.

aveshd commented 7 years ago

I think problem is much more complicated than I thought: Here is a link where somebody has addressed this problem, but did not find the solution http://stackoverflow.com/questions/24407762/cygwin-gcc-linking-with-visual-studio-library

Here are interesting comments from MinGw page,

http://www.mingw.org/wiki/Interoperability_of_Libraries_Created_by_Different_Compiler_Brands

Thanks,

StephenAshmore commented 7 years ago

I believe the fix for this is to compile the waffles library entirely in Cygwin, and link to that version. I'm not sure they are designed to talk to each other. You should be able to compile waffles using g++ in cygwin, and get it running without the need for the MSVC.

aveshd commented 7 years ago

I tried compiling it with Cygwin but it uses some of the windows specific header file. I started fixing some of the things but soon realized that it is not going to be easy. I will try to give it one more attempt and report back if I can find a break through.

mikegashler commented 7 years ago

When building on Windows, I use the compiler definition "WINDOWS", and the code only includes Windows-specific header files if this is defined. So, if you do not want to include any Windows-specific header files, just make sure that is not defined.