Advertisement

DLLs in linux.

Started by April 05, 2007 09:55 AM
16 comments, last by taby 17 years, 7 months ago
An alternative is to use scons.
Here is an example file (read the tutorial, it's pretty good):
# the game will be divided into tree separate parts:# 1) a game library (independant of any 3rd-party library or OS)# 2) a simplistic game engine (that does all the 3rd-party libraries and OS-dependant code)# 3) one executable to rule them all :D###################################################################### give a name for each binary module:game_library = "fooblocks"game_engine = "fooblocks-engine"executable = "fooblocks"########################################################################################################################################### set the sources:engine_sources = Split("""        init.c        graphics.c        input.c        text.c        time.c""")library_sources = Split("""        draw.c        gamelogic.c        ingameloop.c        player.c""")executable_sources = Split("""        fooblocks.c""")########################################################################################################################################### declare the needed librariescommon_libs = Split("""        SDL        SDL_ttf""")# setting the dependancies:engine_libs                     = common_libslibrary_libs            = common_libs + [game_engine] # TODO: see if common_libs is necessary at allexecutable_libs = common_libs + [game_engine, game_library]########################################################################################################################################### general options#prg_lib_path = Split("/usr/lib /usr/local/lib .")prg_hdr_path = Split(".")prg_lib_path = Split(".");# do not recompile if there is no functional changeTargetSignatures("content")   # default is build########################################################################################################################################### build the binary modules:# the game engine:SharedLibrary(        game_engine,        engine_sources,        LIBS            = engine_libs,        LIBPATH = prg_lib_path,        CPPPATH = prg_hdr_path)# the game library:SharedLibrary(        game_library,        library_sources,        LIBS            = library_libs,        LIBPATH = prg_lib_path,        CPPPATH = prg_hdr_path)# the executable:Program(executable,        executable_sources,        LIBS            = executable_libs,        LIBPATH = prg_lib_path,        CPPPATH = prg_hdr_path)#####################################################################

As you can see, it's much easier to both read and maintain. As far as I am concerned, I'll never use autotoos/make in my projects. There are some reasons for this:
1) there is a single configuration file, which is way easier to read and maitain
2) the end user needs to have only one program installed, save for the buildchain
3) I don't need to know all compiler flags
4) I don't need MinGW or Cygwin in Windows to compile my projects (=> greatly simplifies porting)
5) I would choose Python over any shell-like language (brrr, C or ASM :P)
Quote: Original post by dilyan_rusev
Here is an example file...:

And here's the same example using autoconf/automake/libtool:
lib_LTLIBRARIES = fooblocks-engine.la fooblocks.labin_PROGRAMS    = fooblocksfooblocks_engine_la_SOURCES = init.c graphics.c input.c text.c time.cfooblocks_la_SOURCES = draw.c gamelogic.c ingameloop.c player.cfooblock_SOURCES   = fooblocks.cfooblocks_CXXFLAGS = $(SDL_CXXFLAGS)fooblocks_LDFLAGS  = $(SDL_LDFLAGS)fooblocks_LIBS     = fooblocks.la fooblocks-engine.la $(SDL_LIBS)

Quote: As you can see, it's much easier to both read and maintain.

Really?

--smw

Stephen M. Webb
Professional Free Software Developer

Advertisement
Well, there are a few things to mentions.
1) I don't want a flame war started
2) I'm still learning scons, so I don't use all the automisation, as you do with autotools
3) Whatever you keep saying, porting is easier with scons
4) As I said in my first post, scons is an alternative, not the alternative, so I think this little dispute is over. Just let him choose by himselft. What we like is of little or no concern at all. After all, GNU/Linux is the freedom to choose, before anything else.
Well, to complete the set, here's a CMake version :P

FIND_PACKAGE(SDL)INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})ADD_LIBRARY(fooblocks-engine SHARED init.c graphics.c input.c text.c time.c)ADD_LIBRARY(fooblocks-logic SHARED draw.c gamelogic.c ingameloop.c player.c)ADD_EXECUTABLE(fooblocks fooblocks.c)TARGET_LINK_LIBRARIES(fooblocks fooblocks-main fooblocks-logic ${SDL_LIBRARY})


autoconf/automake/libtool has one big advantage over other build systems: There are lots of other programs built on top of it. Turning an autotools application in a .deb package (and probably RMP or KLik as well) is very easy and largely automated (e.g. debuild).

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Quote: Original post by ZQJ
Well, to complete the set, here's a CMake version :P

Sweet. If I didn't already have so much invested in the autotools I might consider learning cmake.
Quote: Original post by Sander
autoconf/automake/libtool has one big advantage over other build systems: There are lots of other programs built on top of it. Turning an autotools application in a .deb package (and probably RMP or KLik as well) is very easy and largely automated (e.g. debuild).

It's not so much of an advantage: both dpkg and rpmbuild are flexible enough that all you need do is write the appropriate rules file (for dpkg) or spec file (for rpmbuild) and you can use scons, cmake, ant, jam, or DCL batch files. The handy default for each of the major Linux packaging tools is the autotools, but it's not a requirement.

I would just recommend using a more sophisticated tool than yer basic makefile of you're buidling shared libraries, just like I would suggest using a high-level language for game writing. You would be mad to do otherwise.

--smw

Stephen M. Webb
Professional Free Software Developer

Advertisement
Well, here is my example :
SharedLibrary('example_lib.c')

No additional libraries to link against, only a single source file.

Seriously, why don't we? But in another thread? It would be fun :P
Quote: Original post by BBB
Enjoy [smile]

*** Source Snippet Removed ***

*** Source Snippet Removed ***

*** Source Snippet Removed ***

*** Source Snippet Removed ***

To build it type "make" and then "make triangle.so".


Much appreciated! Rate++

This topic is closed to new replies.

Advertisement