Bienvenue, Invité. Merci de vous connecter ou de vous inscrire.
Avez-vous perdu votre e-mail d'activation ?

Auteur Sujet: Compiler une librairie.  (Lu 16550 fois)

0 Membres et 1 Invité sur ce sujet

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Compiler une librairie.
« le: Novembre 25, 2013, 12:35:03 pm »
Salut, j'ai créer un projet sous code::block pour compiler une librairie statique et j'ai un fichier libSFGL.a
Je voudrais savoir comment tu as compiler SFML toi, avec code::blocks ou en mode console ?
Car je vois que toi tu as plusieurs fichier .a (un pour chaque module en fait), bref, je voudrais un peu savoir comment tu as fait.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : Compiler une librairie.
« Réponse #1 le: Novembre 25, 2013, 01:51:04 pm »
Citer
Je voudrais savoir comment tu as compiler SFML toi, avec code::blocks ou en mode console ?
Je ne sais pas si tu as remarqué, mais je compile SFML avec tout un tas de compilateurs et d'OS ;)
Pour ça, comme tu peux le voir dans les sources, j'utilise CMake.

Citer
Car je vois que toi tu as plusieurs fichier .a (un pour chaque module en fait), bref, je voudrais un peu savoir comment tu as fait.
J'ai plusieurs projets, tout simplement.

A part ça je ne suis pas trop fan du fait que tu aies choisi un nom aussi lié à SFML pour ta propre bibliothèque :-\
« Modifié: Novembre 25, 2013, 01:55:14 pm par Laurent »
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #2 le: Novembre 25, 2013, 05:15:39 pm »
Ok merci je pense que je vais simplement utiliser CMake plutôt. ^^

Pour le nom, ça, je n'ai rien trouvé d'autre pour l'instant donc je l'ai appelé simple and fast game library. (sfgl en abrégé)

Je changerai surement le nom après quand j'aurai trouvé mieux.

Mais ce nom illustre bien le but de cette librairie c'est à dire de créer des jeux avec seulement quelques lignes de codes :

En effet : le framework utilise son propre format de fichier pour charger une map en 2D avec SFML et la sauvegarder.
La map peut contenir n'importe quel type d'entité et le framework se charge lui même de sauvegarder la map, de la lire et de récupérer toutes les entités qui se trouve dans la vue pour pouvoir les afficher dans la renderwindow.
De plus j'ai même rajouté des entités pré-faîtes (tiles (le sol et les modèles qui ont en plus une ombre et des segments pour les intersctions avec la lumière et qui servent aussi à déterminer si un modèle est devant ou bien derrière un autre modèle pour l'ordre d'affichage des modèles), animations, monstres, personnages, ombres, lumières, etc...) avec une classe qui gère automatiquement les intersections entre la lumières et les entités, ainsi que entre les entités et la grille, mais si on ne veut pas utiliser les entités du framework on peut très bien faire ses propres entités. (Mais il faudra bien évidement recoder la classe qui sauvegarde et lis la map)
Bref ce que je veux faire c'est une librairie qui utilise SFML mais avec un niveau plus au dessus de SFML.
Car avec SFML il faut coder soi même les classes de sauvegarde de la map, les lumières, les ombres, les intersections entités et lumières, la grille pour tout stocker et récupérer ce qui est dans la vue de manière rapide, le resource holder, les collisions entité/grille (je ne fais pas de système de pixel-perfect), le pathfinding, le moteur de particule, etc...

Avec SFGL, il n'y aura plus besoin de faire tout ça.
Il n'y aura qu'à créer une entité, l'ajouté dans le monde (qui pourra être composée de une grande map ou plusieurs petites map) et la récupérer pour l'afficher.
Il faudra juste coder l'ihm soi même, et bien sûr, les ordres entre le client et le serveur.
Je compte même essayer d'introduire un système d'ia dans le framework, de quête, etc...
Mais ça, la partie gameplay du framework, se sera pour bien plus tard.
« Modifié: Novembre 25, 2013, 05:36:11 pm par Lolilolight »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : Compiler une librairie.
« Réponse #3 le: Novembre 25, 2013, 08:55:08 pm »
Citer
Mais ce nom illustre bien le but de cette librairie c'est à dire de créer des jeux avec seulement quelques lignes de codes
Oui je suis d'accord, mais avec un nom aussi proche on dirait que les deux bibliothèques sortent du même moule, ce qui n'est pas du tout le cas.
Laurent Gomila - SFML developer

G.

  • Hero Member
  • *****
  • Messages: 1592
    • Voir le profil
Re : Compiler une librairie.
« Réponse #4 le: Novembre 25, 2013, 09:22:49 pm »
Pourquoi pas SFML++ puisque ta lib est une amélioration de SFML ? :D

Enfin sans déc, trouve un vrai nom différent avant d'uploader ça sur github etc. Est-ce que tu souhaites entretenir la confusion juste pour attirer des gens ? C'est un peu malhonnête. ;)

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #5 le: Novembre 26, 2013, 10:52:48 am »
Citer
Pourquoi pas SFML++ puisque ta lib est une amélioration de SFML ? :D

Enfin sans déc, trouve un vrai nom différent avant d'uploader ça sur github etc. Est-ce que tu souhaites entretenir la confusion juste pour attirer des gens ? C'est un peu malhonnête. ;)

Ok, en effet, il faut que je trouve un autre nom avant de mettre ça sur github.

Par contre je ne parviens pas à configurer CMake et je trouve ça assez compliqué, il me dit qu'il me faut un fichier CMakeList.txt, donc, j'ai cherché un tutoriel pour savoir comment en faire un, alors, j'ai essayer de créer ce fichier-ci :

cmake_minimum_required(VERSION 2.8)

#Déclaration du projet

project(SFGL)

set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})

#Inclusion de SFML

include_directories(C:/SFML-2.1/include)

link_directories(C:/SFML-2.1/lib)

#Configuration de l'exécutable

file(

        GLOB_RECURSE

        source_files

        src/*

include/*

)

add_executable(

        SFGL_build

        ${source_files}

)

Malheureusement ça ne parse pas.

CMake Error: Error in cmake code at
D:/Projets/Projets-c++/SFGL/CMakeLists.txt:1:
Parse error.  Expected a command name, got unquoted argument with text "".
Configuring incomplete, errors occurred!

Voilà ce que cmake me dit quand je clique sur configure.

J'essaye de faire un fichier tout simple plutôt que celui de SFML qui utilise pleins d'options que je ne comprend s pas pour compiler aussi sur macosx, linux, etc...
Et de toute façon ceux de SFML ne convienne pas pour ma bibliothèque. :/
Comment tu as fait toi pour  générer tout tes fichier de configurations pour cmake, tu les as fait à a main ou bien tu as utilisé un outil ?

PS : C'est pas une confusion de nom qui va faire de ma librairie un succès lol, il suffit de voir ce qu'est devenu le projet sf3d.
« Modifié: Novembre 26, 2013, 11:18:38 am par Lolilolight »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : Compiler une librairie.
« Réponse #6 le: Novembre 26, 2013, 11:37:33 am »
Il n'y a pas d'outil pour créer les scripts CMake, c'est un langage avec ses propres instructions, il faut l'apprendre. C'est un peu rude au début mais on finit par s'y faire ;)

Aucune idée par rapport à ton erreur. Vu l'erreur et le fait qu'elle survient ligne 1, on dirait que ton fichier contient de la choucroute garnie.
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #7 le: Novembre 26, 2013, 12:10:27 pm »
Ouais mon fichier est bizarre on dirait, il me faudrait un éditeur de texte autre que le bloc note qui me rajoute je ne sais pas quoi...

Au pire je compiler ma librairie avec codeblocks et je copie/colle les fichiers libSFGL.a et les fichier du dossier include de ma librairie dans le dossier d'installation de ma librairie et ça marche aussi.

Par contre je ne suis pas sûr que ça fonctionne aussi sur macosx et linux en faisant comme ça...

Le seul truc qui m'ennuie c'est que je suis quand même obligé de linker SFML à mon projet qui utilise SFGL, même si SFGL utilise SFML, je crois qu'il faudrait que je fasse un en tête spécial un peu comme tu as fait pour opengl.


Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #8 le: Novembre 26, 2013, 08:11:59 pm »
Mais je ne comprends pas très bien votre réaction, ce n'est pas comme si je copiais SFML et que je la revendais donc je ne vois pas en quoi ce serait malhonnête de l'appeler SFGL, de plus, ce n'est pas parce que les noms se ressemble que 2 choses sont identiques.

Le projet SFML est sous license GNU si je ne me trompes donc c'est juste un projets dans le but d'aider tout comme le projets SFGL, et pas dans le but d'avoir du succès et de faire du commerce.

Bref j'ai déjà vu des documentaires sur l'apparition de la micro-informatique, je peux vous dire que il y a des sociétés qui ont fait des choses bien plus malhonnête que ça. (L'une qui demandait à une société de lui fournir un OS en imposant des conditions de tel sorte que la société n'aie aucun droit sur cet OS, l'autre qui à acheté les droits sur un OS et qui a plagié sur une autre société pour les interfaces graphiques de son OS, et l'autre qui a tenté un procès à sa rivale, et enfin la dernière qui exprime sa haine en disant que les OS vont disparaître, sans parler des nombreux clônes qu'il y a eu avec la rétro-ingénieurerie.)
Quand je pense que ce sont des gens qui ont des milliards de sous maintenant..., ce qui me dégoutte encore plus, hors que nous ont fait juste ça comme passion ou pour aider les gens mais qu'on pleure toujours pour trouver un emploi pour avoir sa propre maison, ce sont des choses qui me dégoutte donc voilà il y a des choses plus aberrantes que ça dans l'informatique donc en tant que administrateur de ce projet, je ne comprend pas trop tes réactions parfois sur le forum.
Je voulais juste te dire ça.
« Modifié: Novembre 26, 2013, 08:15:05 pm par Lolilolight »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Messages: 32504
    • Voir le profil
    • SFML's website
    • E-mail
Re : Compiler une librairie.
« Réponse #9 le: Novembre 26, 2013, 08:49:52 pm »
Evidemment que tu as le droit d'utiliser ce nom. Et je sais très bien que tu n'as pas d'intention "malhonnête".

Tout ce que je dis, c'est que c'est tellement proche que les gens vont penser que c'est un nouveau projet de l'équipe de SFML. Ou bien un projet officiellement reconnu comme étant le penchant 3D de SFML. C'est tout. Il y aura un lien, c'est inévitable. Après à toi de voir si tu veux que ton projet soit accolé à SFML (et est "digne" de l'être), ou si tu ne préfèrerais pas qu'il parte avec un "casier vierge" ;)
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #10 le: Novembre 26, 2013, 09:28:38 pm »
Citer
Après à toi de voir si tu veux que ton projet soit accolé à SFML (et est "digne" de l'être)

Bah j'aimerais bien, maintenant dans le projet il faut savoir qu'il n'y aura pas que de la 3D, mais aussi de la 2D. (Gestion de collision en 2D et en 3D, stockage des entités dans une map en 2D et plus tard en 3D, éclairage et ombrage en 2D et plus tard en 3D, génération de terrain et chargement de modèles et animations en 2D et en 3D, resources holder, graphes de scenes et multipass-rendering, etc...)
C'est juste une librairie que je suis entrain de créer pour m'aider plus tard à créer des jeux.
Et j'ai jugé cela bien de pouvoir la mettre en ligne mais c'est plus pour avoir de l'aide mais dans le but d'aider aussi, je ne sais pas du tout si SFGL deviendra un jour une vrai librairie digne de l'être comme SFML mais je l'espère en tout cas.
« Modifié: Novembre 26, 2013, 09:31:28 pm par Lolilolight »

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #11 le: Novembre 27, 2013, 02:32:06 pm »
Re, comme certains le save déjà, j'essaye de compiler une librairie utilisant SFML avec CMake.
J'ai donc suivis ce tutoriel que j'ai trouvé :

http://fr.sfml-dev.org/forums/index.php?action=post;topic=13683.0;last_msg=95882

J'ai juste du rajouté le path du dossier ou se trouve SFML sur mon PC:
# This script locates the SFML library
# ------------------------------------
#
# Usage
# -----
#
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
# example:
#   find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
#
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
# If nothing is specified, the version won't be checked (ie. any version will be accepted).
# example:
#   find_package(SFML COMPONENTS ...)     // no specific version required
#   find_package(SFML 2 COMPONENTS ...)   // any 2.x version
#   find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
# description below).
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
# example:
#   set(SFML_STATIC_LIBRARIES TRUE)
#   find_package(SFML 2 COMPONENTS network system)
#
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
# to tell CMake where SFML is.
#
# Output
# ------
#
# This script defines the following variables:
# - For each specified module XXX (system, window, graphics, network, audio, main):
#   - SFML_XXX_LIBRARY_DEBUG:   the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
#   - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
#   - SFML_XXX_LIBRARY:         the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
#   - SFML_XXX_FOUND:           true if either the debug or release library of the xxx module is found
#   - SFML_XXX_DEPENDENCIES:    the list of libraries the module depends on, in case of static linking
# - SFML_LIBRARIES:    the list of all libraries corresponding to the required modules
# - SFML_FOUND:        true if all the required modules are found
# - SFML_INCLUDE_DIR:  the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
#
# example:
#   find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
#   include_directories(${SFML_INCLUDE_DIR})
#   add_executable(myapp ...)
#   target_link_libraries(myapp ${SFML_LIBRARIES})

# define the SFML_STATIC macro if static build was chosen
if(SFML_STATIC_LIBRARIES)
    add_definitions(-DSFML_STATIC)
endif()

# deduce the libraries suffix from the options
set(FIND_SFML_LIB_SUFFIX "")
if(SFML_STATIC_LIBRARIES)
    set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-s")
endif()

# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
    ${SFML_ROOT}
    $ENV{SFML_ROOT}
    ~/Library/Frameworks
    /Library/Frameworks
    /usr/local
    /usr
    /sw
    /opt/local
    /opt/csw
    /opt
/SFML-2.1)

# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
          PATH_SUFFIXES include
          PATHS ${FIND_SFML_PATHS})


# check the version number
set(SFML_VERSION_OK TRUE)
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
    # extract the major and minor version numbers from SFML/Config.hpp
    # we have to handle framework a little bit differently :
    if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
        set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
    else()
        set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
    endif()
    FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
    STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}")
    STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
    STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
    math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10 + ${SFML_FIND_VERSION_MINOR}")

    # if we could extract them, compare with the requested version number
    if (SFML_VERSION_MAJOR)
        # transform version numbers to an integer
        math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10 + ${SFML_VERSION_MINOR}")

        # compare them
        if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
            set(SFML_VERSION_OK FALSE)
        endif()
    else()
        # SFML version is < 2.0
        if (SFML_REQUESTED_VERSION GREATER 19)
            set(SFML_VERSION_OK FALSE)
            set(SFML_VERSION_MAJOR 1)
            set(SFML_VERSION_MINOR x)
        endif()
    endif()
endif()

# find the requested modules
set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
    string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
    string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
    set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER}${FIND_SFML_LIB_SUFFIX})

    # no suffix for sfml-main, it is always a static library
    if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
        set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
    endif()

    # debug library
    find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
                 NAMES ${FIND_SFML_COMPONENT_NAME}-d
                 PATH_SUFFIXES lib64 lib
                 PATHS ${FIND_SFML_PATHS})

    # release library
    find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
                 NAMES ${FIND_SFML_COMPONENT_NAME}
                 PATH_SUFFIXES lib64 lib
                 PATHS ${FIND_SFML_PATHS})

    if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
        # library found
        set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
       
        # if both are found, set SFML_XXX_LIBRARY to contain both
        if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug     ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
                                                          optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
        endif()

        # if only one debug/release variant is found, set the other to be equal to the found one
        if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
            # debug and not release
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY         ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
        endif()
        if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
            # release and not debug
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY       ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
        endif()
    else()
        # library not found
        set(SFML_FOUND FALSE)
        set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
        set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
        set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
    endif()

    # mark as advanced
    MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
                     SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
                     SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)

    # add to the global list of libraries
    set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
endforeach()

# in case of static linking, we must also define the list of all the dependencies of SFML libraries
if(SFML_STATIC_LIBRARIES)

    # detect the OS
    if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
        set(FIND_SFML_OS_WINDOWS 1)
    elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
        set(FIND_SFML_OS_LINUX 1)
    elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
        set(FIND_SFML_OS_FREEBSD 1)
    elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        set(FIND_SFML_OS_MACOSX 1)
    endif()

    # start with an empty list
    set(SFML_DEPENDENCIES)
    set(FIND_SFML_DEPENDENCIES_NOTFOUND)

    # macro that searches for a 3rd-party library
    macro(find_sfml_dependency output friendlyname)
        find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib)
        if(${${output}} STREQUAL "${output}-NOTFOUND")
            unset(output)
            set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
        endif()
    endmacro()

    # sfml-system
    list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
    if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)

        # update the list -- these are only system libraries, no need to find them
        if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
            set(SFML_SYSTEM_DEPENDENCIES "pthread")
        endif()
        if(FIND_SFML_OS_LINUX)
            set(SFML_SYSTEM_DEPENDENCIES "rt")
        endif()
        if(FIND_SFML_OS_WINDOWS)
            set(SFML_SYSTEM_DEPENDENCIES "winmm")
        endif()
        set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES})
    endif()

    # sfml-network
    list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
    if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)

        # update the list -- these are only system libraries, no need to find them
        if(FIND_SFML_OS_WINDOWS)
            set(SFML_NETWORK_DEPENDENCIES "ws2_32")
        endif()
        set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_NETWORK_DEPENDENCIES})
    endif()

    # sfml-window
    list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
    if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)

        # find libraries
        if(FIND_SFML_OS_LINUX)
            find_sfml_dependency(X11_LIBRARY "X11" X11)
            find_sfml_dependency(XRANDR_LIBRARY "Xrandr" Xrandr)
        endif()

        # update the list
        if(FIND_SFML_OS_WINDOWS)
            set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
        elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
            set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY})
            if(FIND_SFML_OS_FREEBSD)
                set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "usbhid")
            endif()
        elseif(FIND_SFML_OS_MACOSX)
            set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" "-framework Foundation -framework AppKit -framework IOKit -framework Carbon")
        endif()
        set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_WINDOW_DEPENDENCIES})
    endif()

    # sfml-graphics
    list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
    if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
   
        # find libraries
        find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
        find_sfml_dependency(GLEW_LIBRARY "GLEW" glew GLEW glew32 glew32s glew64 glew64s)
        find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)

        # update the list
        set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
        set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_GRAPHICS_DEPENDENCIES})
    endif()

    # sfml-audio
    list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
    if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)

        # find libraries
        find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
        find_sfml_dependency(SNDFILE_LIBRARY "libsndfile" sndfile)

        # update the list
        set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})
        set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_AUDIO_DEPENDENCIES})
    endif()

endif()

# handle errors
if(NOT SFML_VERSION_OK)
    # SFML version not ok
    set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR})")
    set(SFML_FOUND FALSE)
elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
    set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
    set(SFML_FOUND FALSE)
elseif(NOT SFML_FOUND)
    # include directory or library not found
    set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
endif()
if (NOT SFML_FOUND)
    if(SFML_FIND_REQUIRED)
        # fatal error
        message(FATAL_ERROR ${FIND_SFML_ERROR})
    elseif(NOT SFML_FIND_QUIETLY)
        # error but continue
        message("${FIND_SFML_ERROR}")
    endif()
endif()

# handle success
if(SFML_FOUND)
    message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
endif()

Et puis j'ai fais un fichier CMakeLists, j'ai juste rajouté quelques ligne pour spécifier ou se trouve les .h et les .a de ma librairie :

cmake_minimum_required(VERSION 2.8)


#Déclaration du projet

project(SFGL)

# Enable debug symbols by default
if(CMAKE_BUILD_TYPE STREQUAL "")
  set(CMAKE_BUILD_TYPE Debug)
endif()
# (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)

# Set version information in a config.h file
configure_file(
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
  )
include_directories("${PROJECT_BINARY_DIR}")


# Define sources and executable
set(EXECUTABLE_NAME "SFGL")
add_executable(${EXECUTABLE_NAME} main.cpp)


# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR}) 
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()


# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)


# CPack packaging
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "${SFGL_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${SFGL_VERSION_MINOR}")
include(CPack)

set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})

#Génération de la liste des fichiers sources

file(

        GLOB_RECURSE

        source_files

        src/*
include/*

)



#Déclaration de l'exécutable

add_executable(

        sfgl_exe

        ${source_files}

)

Quand je run configure et generate ça marche mais la commande mingw32-make me sors une erreur :
No rules to make target '/SFML-2.1/lib/libsfml-system-d.a', needed by 'bin/Debug/SFGL.exe'. Stop

Alors voilà je sais pas trop ce que je dois faire là. :/

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #12 le: Novembre 27, 2013, 03:07:56 pm »
Bon finallement j'ai changé un peu le fichier :
cmake_minimum_required(VERSION 2.8)


#Déclaration du projet

project(SFGL)

# Enable debug symbols by default
if(CMAKE_BUILD_TYPE STREQUAL "")
  set(CMAKE_BUILD_TYPE Debug)
endif()
# (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)

# Set version information in a config.h file
configure_file(
  "${PROJECT_SOURCE_DIR}/config.h.in"
  "${PROJECT_BINARY_DIR}/config.h"
  )
include_directories("${PROJECT_BINARY_DIR}")


#Déclaration de l'exécutable

set(EXECUTABLE_NAME "SFGL")
add_executable(${EXECUTABLE_NAME} main.cpp)


# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
#Find any version 2.X of SFML
#See the FindSFML.cmake file for additional details and instructions
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR}) 
  target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif()
#Génération de la liste des fichiers sources

file(

        GLOB_RECURSE

        source_files

        src/*
include/*

)
add_library(

        sfgl       

        ${source_files}

)

# Install target
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)


# CPack packaging
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "${SFGL_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${SFGL_VERSION_MINOR}")
include(CPack)

set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})

Mais ici j'ai une autre erreur, il me dit qu'il ne trouve pas le fichier SFML/System.hpp





Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #13 le: Novembre 27, 2013, 03:27:29 pm »
Bon finalement j'ai trouvé, en fait, le fichier cmake pour trouver SFML que j'utilisais n'était pas le bon. (Fallait que j'utilise celui dans mon dossier cmake de SFML version 2.1 et pas celui que j'ai trouvé sur ce lien.

Lolilolight

  • Hero Member
  • *****
  • Messages: 1232
    • Voir le profil
Re : Compiler une librairie.
« Réponse #14 le: Novembre 27, 2013, 07:28:26 pm »
Sinon j'ai une question, comment faire pour lier un .lib dans un .lib ?

J'ai toujours besoin de lier libsfml-system.a à mon projet ainsi que tout les librairies qu'utilise SFML hors que SFGL utilise déjà toutes ces librairies donc je suis embêté avec des undefined references de partout. :/