Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Simplest way to distribute on Linux  (Read 3001 times)

0 Members and 1 Guest are viewing this topic.

rogelius

  • Newbie
  • *
  • Posts: 4
    • View Profile
Simplest way to distribute on Linux
« on: February 06, 2012, 07:35:55 pm »
I've been using SFML 1.6 for a university project (Computer Graphics in fact), it uses the basic sfml libraries, C++, linux.

I'm wondering what would be the easier way for the person who would execute my program to do it supposing he doesn't have sfml installed. ¿Is there any way to make an install script, or to set the Makefile to install sfml libraries, or...? :roll:

Thanks in advance!

HKei

  • Newbie
  • *
  • Posts: 23
    • View Profile
Simplest way to distribute on Linux
« Reply #1 on: February 06, 2012, 09:21:15 pm »
Distribute the binaries, if you know what platform exactly you're targeting. Other than that, they probably won't get around installing SFML on their own.

rogelius

  • Newbie
  • *
  • Posts: 4
    • View Profile
Simplest way to distribute on Linux
« Reply #2 on: February 06, 2012, 10:08:51 pm »
The only thing I know is that it will be executed on linux, don't know anything more... I would like to avoid that the person who evaluate my project has to deal with too much commands, compiler errors and so...

Thank you for your response!

rogelius

  • Newbie
  • *
  • Posts: 4
    • View Profile
Simplest way to distribute on Linux
« Reply #3 on: February 07, 2012, 07:28:54 pm »
I'm trying to provide the sfml libraries with the source of the project and use a Makefile in order to build the project linking with these libraries. Here's my Makefile:
Code: [Select]
EJECUTABLE = app
MODULOS = main.o Handbapp.o Camera.o Light.o Scene.o Graphics.o Window.o Model.o Court.o Player.o Primitives.o Path.o
CC = g++
LIBDIR = sfml/lib
LIBS = -lsfml-window -lsfml-system -lGLU
LDFLAGS = -L$(LIBSDIR)
CFLAGS = -Wall

$(EJECUTABLE): clean $(MODULOS)
$(CC) $(CFLAGS) -o $(EJECUTABLE) $(LDFLAGS) $(MODULOS) $(LIBS)

clean:
rm -f *.o
rm -f $(EJECUTABLE)

I have to say that if I don't use the LDFLAGS (commenting -L$(LIBSDIR)), it compiles and everything goes well (I guess in this case it's using the system installes sfml libraries). If use the LDFLAGS in order to the compiler to link with the libraries I provide with the source, I get the following disconcerting error:
Code: [Select]
...
g++ -Wall -o app -L main.o Handbapp.o Camera.o Light.o Scene.o Graphics.o Window.o Model.o Court.o Player.o Primitives.o Path.o -lsfml-window -lsfml-system -lGLU
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned exit state 1
make: *** [app] Error 1

May I provide more info?

rogelius

  • Newbie
  • *
  • Posts: 4
    • View Profile
Simplest way to distribute on Linux
« Reply #4 on: February 08, 2012, 03:03:25 am »
I've got it working now, for anybody who wants to distribute his code with the libraries in linux, here's how I did it.

My file hierarchy is as follows:

    - lib/ >> here goes all the sfml libraries (.so files)
    - Makefile
    - src/
    --- myfiles.h, myfiles.cpp
    --- SFML/ >> here goes all the sfml headers

My very simple Makefile looks like:

Code: [Select]
EJECUTABLE = app

MODULOS = src/module1.o src/module2.o ...

CXX = g++
LIBDIR = ./lib
INCDIR = ./src

LIBS = -lsfml-window -lsfml-system -lother-libraries-here

LDFLAGS = -L$(LIBDIR)
CXXFLAGS = -I$(INCDIR) -Wl,-rpath,$(LIBDIR)

$(EJECUTABLE): $(MODULOS)
$(CXX) $(CXXFLAGS) -o $(EJECUTABLE) $(LDFLAGS) $(MODULOS) $(LIBS)

clean:
rm -f $(MODULOS) $(EJECUTABLE)


The -Wl,-rpath,$(LIBDIR) make the executable use the libraries on your local folder.

 

anything