Cross-Platform Development - Best Practices?

Discussion in 'C++' started by Andreas Wenzke, Apr 5, 2010.

  1. 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.
     
    Andreas Wenzke, Apr 5, 2010
    #1
    1. Advertising

  2. Leigh Johnston schrieb:
    > 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?
     
    Andreas Wenzke, Apr 6, 2010
    #2
    1. Advertising

  3. Christian Hackl schrieb:
    > 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 wants me to include a Makefile, whilst I want to use Visual
    >> Studio for development.

    >
    > 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.
     
    Andreas Wenzke, Apr 6, 2010
    #3
  4. 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
     
    Andrew Schetinin, Apr 6, 2010
    #4
  5. Andreas Wenzke

    Jorgen Grahn Guest

    On Mon, 2010-04-05, Andreas Wenzke wrote:
    > 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


    Weren't you the guy who wasn't even allowed to use more than a
    crippled subset of C++ because the lecturer wanted to focus on
    algorithm design? What happened?

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Apr 6, 2010
    #5
  6. Andreas Wenzke

    Jorgen Grahn Guest

    On Tue, 2010-04-06, Jorgen Grahn wrote:
    > On Mon, 2010-04-05, Andreas Wenzke wrote:
    >> 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

    >
    > Weren't you the guy who wasn't even allowed to use more than a
    > crippled subset of C++ because the lecturer wanted to focus on
    > algorithm design? What happened?


    Already answered in Message-ID:
    <4bb88894$0$6764$-online.net>

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Apr 10, 2010
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer
    Replies:
    2
    Views:
    453
    John Saunders
    Aug 6, 2003
  2. demibee
    Replies:
    0
    Views:
    369
    demibee
    Dec 26, 2003
  3. Karsten

    Cross platform development

    Karsten, Sep 29, 2004, in forum: C++
    Replies:
    3
    Views:
    311
    Karsten
    Sep 29, 2004
  4. Clark K
    Replies:
    5
    Views:
    545
    msalters
    Mar 18, 2005
  5. Replies:
    4
    Views:
    252
    Malcolm
    Jun 9, 2006
Loading...

Share This Page