wxWidgets, CMake et CLion
Bonjour,
J'ai un petit soucis avec la librairie wxWidgets sur mon IDE CLion, pour commencer :
- J'utilise la dernière version de CLion avec MinGW dans sa version 64 bits sous Windows 10.
- J'utilise le code source de wxWidget 3.1.0 que je compile avec la commande : make -f makefile.gcc UNICODE=1 MONOLITHIC=0 SHARED=0 USE_ODBC=1 USE_OPENGL=1 BUILD=release
A noter que je peut aussi utiliser mingw-make.exe a la place de make. La compilation de la librairie ce passe sans aucun soucis, je n'ai aucune erreur et dans le dossier <wxhome>/lib, un dossier gcc_lib avec plein de fichier .a est créé.
- Je place le répertoire de wxwidgets dans un dossier libext, a la racine du projet.
- J'ai commencer un projet simple sur CLion (je suis pas pros de l'ide, et encore moins de CMake, que je découvre) avec 3 fichiers: wxHello.cpp, wxHello.h et le fichier CMake, CMakeLists.txt.
Le contenu :
wxHello.h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| #ifndef WXHELLO_WXHELLO_H
#define WXHELLO_WXHELLO_H
#include <wx/wx.h>
class wxHello : public wxApp {
public:
virtual bool OnInit();
};
DECLARE_APP(wxHello);
#endif //WXHELLO_WXHELLO_H |
wxHello.cpp
Code:
1 2 3 4 5 6 7 8
| #include "wxHello.h"
IMPLEMENT_APP(wxHello);
bool wxHello::OnInit() {
wxMessageBox(_T("Bienvenue sur wxWidgets !"));
return false;
} |
Et pour finir le fichier CMake CMakeLists.txt
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| cmake_minimum_required(VERSION 3.6)
project(wxHello)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -static")
include_directories(
includes
libext/wx/include
)
link_directories(
libs
libext/wx/lib/gcc_lib
)
set(
WXHELLO_SOURCES
src/wxHello.cpp
src/wxHello.h
)
add_executable(
wxHello
${WXHELLO_SOURCES}
) |
Le problème est là, CLion reconnait bien les fichiers .h de la librairie wxWidgets, mais a la compilation sa plante. Je pense parce que il utilise pas les fichiers .a nécessaire à la compilation. Le fait que j'ai rajouté le chemin sur link_directories à l'air de pas suffire.
Et la je coince un peu :(
PS: je met l'erreur que CLion/gcc m'affiche si cela peu aider:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| "C:\Program Files (x86)\JetBrains\CLion 2016.2.1\bin\cmake\bin\cmake.exe" --build F:\JetBrains\CLion\system\cmake\generated\wxHello-389b4489\389b4489\Debug --target all -- -j 8
Scanning dependencies of target wxHello
[ 50%] Building CXX object CMakeFiles/wxHello.dir/src/wxHello.cpp.obj
In file included from F:/Dev/Cpp/wxHello/libext/wx/include/wx/defs.h:20:0,
from F:/Dev/Cpp/wxHello/libext/wx/include/wx/wx.h:14,
from F:\Dev\Cpp\wxHello\src\wxHello.h:4,
from F:\Dev\Cpp\wxHello\src\wxHello.cpp:1:
F:/Dev/Cpp/wxHello/libext/wx/include/wx/platform.h:136:22: fatal error: wx/setup.h: No such file or directory
#include "wx/setup.h"
^
compilation terminated.
mingw32-make.exe[2]: *** [CMakeFiles/wxHello.dir/src/wxHello.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/wxHello.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
CMakeFiles\wxHello.dir\build.make:62: recipe for target 'CMakeFiles/wxHello.dir/src/wxHello.cpp.obj' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/wxHello.dir/all' failed
Makefile:82: recipe for target 'all' failed |
Merci d'avance.