Cross-Platform Development - Best Practices?

A

Andreas Wenzke

So I've ditched the idea of implementing my own XML parser in the end.
Now I'm going to use TinyXML instead (unless you have a better suggestion):
http://www.grinninglizard.com/tinyxml/index.html

Now what would be the best way to integrate that into my project?
I could of course include the header and link against the library, but
how would I make sure my project would compile both under Linux and Windows?
The lecturer wants me to include a Makefile, whilst I want to use Visual
Studio for development.

I don't want to learn Autoconf for this - should I just include to
different Makefiles with a variable "TINYXML_LIB" pointing to different
library files (.lib and .a or whatever is the Linux file extension)?
Or should I somehow include the source in my project?
After all, a TinyXML comes with its own Makefile - but then again, how
would I include that in Visual Studio?

And what about the filesystem structure - I currently have something
like this:

My project
|
+---src
|
+---include
|
+---doc
|
+---data
|
+---bin

Should I add a new directory "lib"?
And if so, what would I put there, only the library or the header file
as well?

Thanks.
 
A

Andreas Wenzke

Leigh said:
If you want to keep things simple you could use a header file only XML
library (no need to worry about makefiles and linking with libs then).

Any suggestion?
 
A

Andreas Wenzke

Christian said:
For your own code, the answer is: by testing your program with both
compilers and by making sure that you disable all compiler extensions.
For example, by invoking VC with /Za.

Other than that, it depends on the libraries you use.

Assuming that linking against the library is enough:
Would you provide two Makefiles (one for CL and one for G++), or would
you use a different approach?
The lecturer must tell you what you have to hand in when using a 3rd
party library.

If I was a lecturer, I would require students to hand in a copy of the
library and to document exactly how to install and use it on the target
platform.

Install? I don't want to install anything.
Also, I'm only talking about static linking.
I would explicitly forbid integrating the library into the
application project itself.
Ok.

Your lecturer may handle things differently. Of course, this means an
awful lot of trouble for the lecturer, which is why I'd except 3rd party
libraries to be forbidden altogether in a beginner's course...

Third-party libraries are generally forbidden, but when he handed out
the assignment I asked whether integrating an XML parser was ok, he said
yes, adding that the integration effort would probably equal what would
have to be done if one wrote the parser by oneself.
Questions about conversion of Visual Studio project files into Makefiles
are off-topic here and should instead be posted to
microsoft.public.vc.language.

I actually think automatic conversion would be overkill as I only have a
couple of files anyway.
Before asking, however, you should be aware of the fact that Makefiles
are not restricted to Linux and/or GCC. One can happily use Makefiles
with VC on Windows.

I know, Microsoft even include their own make implementation, NMAKE.
 
A

Andrew Schetinin

Hi,

CMake is certainly a good choice for a cross-platform C/C++ project -
it saves a lot of unnecessary manual work.

A good cross-platform C++ library with abstractions for threads/file
system/IO is usually also very useful.

But for the learning purposes it would be useful to learn how to write
make files manually :)

Regards,

Andrew Schetinin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top