C++ Cross platform libraries

a 夏天 提交于 2019-12-23 19:53:09

问题


I'm not exactly new to C++ but I've never managed to get my head around Libraries.

I would like to split my networking, graphics and input class sets out of my main executable so that I can update them individually rather then sending out a recompiled version of all the code as a single executable.

Is this possible and how do I do this cross platform? (E.g. the process will work on Windows, Linux and Mac)


回答1:


As @Armen said in the simplest of terms, one of the requirements here is a library that works as cross-platform as possible/needed. Qt is the obvious choice for this. There are others like wxWidgets that achieve the same thing and the choice is up to you.

The second thing is that all the "upgradeable" libraries need to conform to binary compatibility (something which Qt pledges to do for every major version, don't know about wxWidgets).

Third and probably the "yeah, duh!" part: you need to build these as shared libraries and link these shared libraries.

These three points should allow you to replace the libraries without rebuilding the executable file itself and keep that as small as possible. The way of upgrading will be different across platforms though (linux: automatic through repositories, Mac and Windows manually or through your own updating software, perhaps macports for Mac?)




回答2:


Yes, use Qt




回答3:


Two libraries that I swear by, that you may want to look at

SDL:
http://www.libsdl.org/
tut:
http://lazyfoo.net/SDL_tutorials/index.php

SFML:
http://www.sfml-dev.org/
tut:
http://www.sfml-dev.org/tutorials/1.6/

Both graphics/networking/audio libraries!




回答4:


Really, this doesn't make sense. You're going to have to recompile the binary when you move it to another platform in any case, because different platforms use different hardware and use different binary formats. There's no reason not to just link in your "platform specific" code into the same binary.

Cross platform at the source level does make sense, however.



来源:https://stackoverflow.com/questions/5234449/c-cross-platform-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!