Compiling on windows machine using g++. I'd really like to use what I think is a great package. Thank you for any help or suggestions you can give me. I ran "make check" and all tests passed, however now I can't compile test1.cpp. I get all kinds of undefined references like:
reRestEv+0x6):test1.cpp: undefined reference to `TCLAP::Arg::_ignoreRest'
collect2: ld returned 1 exit status
Sorry for the slow response.
It sounds to me like when you're trying to compile test1.cpp independently you're not properly linking to the libtclap library. On linux, the command to compile test1.cpp is:
g++ -o test1 test1.cpp -ltclap
This assumes you've installed tclap (make install). If you haven't, then you need to supply a -L argument telling g++ where to look for the library.
Feel free to contact me directly if you have further questions (firstname.lastname@example.org).
I got it to work using the -L argument. I did run "make install" and everything seemed to work, but for some reason just having "-ltclap" in the command doesn't work. The first character a lower case "el", right? Just in case I tried a pipe and a few other things.
What exactly is the -L supposed to point to? I had to move to a different machine from the one I had it working on, and now I can't get it to work at all. Whether I try to use -L, -ltclap, or nothing at all I get the same errors:
massflow.cpp:9:27: tclap/CmdLine.h: No such file or directory
massflow.cpp:13: error: namespace `TCLAP' undeclared
Ok now I took out the -mno-cygwin flag that keeps it from needing the cygwin1.dll. Now I instead of getting the errors I mentioned previously, I'm getting the undefined reference errors, no matter what path I try to put after the -L. If i use -ltclap I get:
$ g++ -Wno-deprecated -o massflow.exe massflow.cpp cycle.cpp datapoint.cpp -ltc
collect2: ld returned 1 exit status
Are you using both -L and -lclap, as this is what you need to do ("-L /path/to/lib -ltclap")?
Fixing the error above is just a matter of getting g++ to look in the right direction.
Also, since you're in Windows, I've been told that tclap works with Visual C++, if thats an option for you (but I have no personal experience with it).
Ok, I'm glad you got it to work.
I suspect that the gnu auto tools don't behave properly on Windows, which would be why g++, by default, can't find the tclap library. I know very little about Windows, so this advice may not be worth much, but perhaps you could explicitly specify the installation path when you configure things: --prefix=/your/path/here ./configure
This is further explained in the INSTALL file.
In any case, I'll add a note in the documentation about this problem.
Basically the -L flag tells the compiler where to look for the libraries specified with the -l flag.
The error you're seeing above is very similar, namely the compiler doesn't know where to look for the tclap header files. To fix this, you use the -I (capital i, not L) flag.
So what the various error messages are telling me is that the "make install" didn't put the headers or library in places where g++ knows to look. This isn't really a big deal, you just need to do so manually:
g++ -o massflow -I /path/to/headers massflow.cpp -L /path/to/library -ltclap
I'll explain each part:
"-o massflow" just names the output executable.
"-I /path/to/headers" tell g++ where to look in addition to its normal places for the header files. If you were to open IE to this path, you should see a directory called tclap. Because you include the headers like: "#include <tclap/CmdLine.h>", g++ knows to look in the tclap subdirectory.
"-L /path/to/library" tells g++ where to look for libraries in addition to its normal places.
"-ltclap" tells g++ to link the tclap library.
If you're wondering where the various paths are, you can just use the directory where you compiled tclap in the first place. So if you built tclap in C:\temp\tclap-0.9.6, then the g++ command would look like:
g++ -o massflow -I C:\temp\tclap-0.9.6\include massflow.cpp -L C:\temp\tclap-0.9.6\src -ltclap
Hope this helps.
Alright I got things figured out well enough to get things compiled like I want, but I'd like to understand this as well as I possibly can.
g++ -Wno-deprecated -o massflow.exe massflow.cpp cycle.cpp datapoint.cpp -L %CYGWIN%\usr\local\lib -ltclap
works just fine, which means for some reason the compiler isn't finding the tclap library. Any ideas why not? It seems to be exactly where it should be.
when I add the -mno-cygwin flag which uses some different libraries, I have to specify the include file as well, which I suppose makes sense, so the command has to look like:
g++ -mno-cygwin -Wno-deprecated -o massflow.exe -I %CYGWIN%\usr\local\include massflow.cpp cycle.cpp datapoint.cpp -L %CYGWIN%\usr\local\lib -ltclap
The strange this is, I'm sure I didn't need the -I before and I know I was using the -mno-cygwin flag.
My only idea on why the compiler might not be finding the library is because the "configure" command needed something special because of the cygwin environment. Unfortunately, I don't know anything about cygwin, so I'm not sure I can help much more. If you do find an answer, let me know and I'll update the documentation.