Reputation: 23
I am new to wxWidgets
My platform is fedora 16,gcc 4.6.2 editor is vim
I download the wxwidget.gz.tar file on sourceforge, and tried to compile.
I typed ./configure --with-gtk --enable-unicode --disable-shared
in bash, and make install and the wxwidget install is finished.
I tried to comile a file: test.cpp Here are the contents of the file:
#include <wx/wx.h>
int main()
{
return 0;
}//i have copied the head file folder to /usr/include/wx
use gcc -o
gcc shows the wx/platform.h:wx/setup.h
, no such file
How do I solve this?
Upvotes: 0
Views: 1470
Reputation: 1530
I STRONGLY encourage you to use CMake for managing you wxWidgets application build process.
You can find LiMuBei's example app bundled with CMake configuration file here.
Just clone the project and follow the instructions int the "README" file.
git clone https://bitbucket.org/vizz/wxstartapp.git
The basic idea is to describe your project sources, dependencies and to use CMake to handle all the "gathering process" ( so that you don't have to worry about "wx-config" and its options ) through appropriate built-in macros/functions.
For example, to configure you wxWidgets project you would write:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(wxstartapp)
FIND_PACKAGE(wxWidgets REQUIRED core base)
IF(wxWidgets_FOUND)
INCLUDE(${wxWidgets_USE_FILE})
...some CMake stuff here...
INCLUDE_DIRECTORIES(
... some additional CMake stuff here...
${wxWidgets_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(wxstartapp ${wxWidgets_LIBRARIES})
ENDIF(wxWidgets_FOUND)
See the "CMakeLists.txt" file for yourself.
Upvotes: 2
Reputation: 3078
You should use wx-config --cxxflags and wx-config --libs to get the include paths, flags and libraries you need in order to compile.
To elaborate more: you need to tell the compiler where to find the include files and what libraries need to be linked. wx-config is a convenience program that will give you that information. On my system the output from wx-config looks like this:
-I/usr/local/lib/wx/include/gtk2-unicode-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -L/usr/local/lib -pthread -lwx_gtk2u_xrc-2.9 -lwx_gtk2u_html-2.9 -lwx_gtk2u_qa-2.9 -lwx_gtk2u_adv-2.9 -lwx_gtk2u_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9
Let's take this minimalistic wxWidgets application:
#include <wx/app.h>
#include <wx/frame.h>
/** Main application class.
* This class is derived from the main wxWidgets application class.
*/
class MyApp : public wxApp
{
public:
/// Initialization function. Called at startup.
virtual bool OnInit();
virtual ~MyApp();
};
DECLARE_APP(MyApp);
IMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
if ( !wxApp::OnInit() )
return false;
wxFrame* MainFrame = new wxFrame(NULL, wxID_ANY, wxT("MyApp"));
MainFrame->Show();
return true;
}
MyApp::~MyApp() {}
You can compile this using the following call:
gcc OUTPUT_OF_WX-CONFIG test.cpp -o test
where OUTPUT_OF_WX-CONFIG is the flags and library directories like above and test.cpp contains the above source code. If you wxWidgets installation is setup properly this should compile and run fine (will show an empty window).
Upvotes: 2