jeudi 7 septembre 2017

C++ Nana in Ubuntu Eclipse - undefined reference to X

I'm having trouble compiling Nana in C++ for Ubuntu using Eclipse.

I've followed these installing steps:

http://ift.tt/1KUZJY0

  1. I've created a static linkage library in Eclipse [OK compiled and I have my libNanaStaticLibrary.a library file]
  2. I've create a C++ project
  3. Added the include paths from nana
  4. Added the library create on point 1 to the paths
  5. Also added the library X11, pthread to the project libraries
  6. I'm also compiling this in C++11 (added to misc: -std=c++11)

So far so good....

When I try to compile my project, I get the errors:

07:24:16 **** Incremental Build of configuration Debug for project Sandbox ****
make all 
Building file: ../Sandbox.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include -I/usr/include/freetype2 -I"/home/john/john/workspace/projs/common/nana/include" -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"Sandbox.d" -MT"Sandbox.d" -o "Sandbox.o" "../Sandbox.cpp"
Finished building: ../Sandbox.cpp

Building target: Sandbox
Invoking: GCC C++ Linker
g++ -o "Sandbox"  ./Sandbox.o   -lX11 -lpthread -lNanaStaticLibrary -L/usr/lib -L/usr/lib/X11 -L/usr/include/X11 -L/usr/lib/x86_64-linux-gnu/X11 -L/usr/lib/x86_64-linux-gnu -L"/home/john/john/workspace/projs/common/nana/lib"
/home/john/john/workspace/projs/common/nana/lib/libNanaStaticLibrary.a(bedrock_posix.o): In function 'nana::detail::bedrock::set_cursor(nana::detail::basic_window*, nana::cursor, nana::detail::bedrock::thread_context*)':
bedrock_posix.cpp: (.text+0xcfb): undefined reference to 'XUndefineCursor'
bedrock_posix.cpp: (.text+0xd77): undefined reference to 'XCreateFontCursor'
bedrock_posix.cpp: (.text+0xdd4): undefined reference to 'XFreeCursor'

... and a bunch more errors like this. All starting with X.

What am I missing here?

My code is, as simple as this (retrieved from here http://ift.tt/2eK9AVv )

#include <nana/gui.hpp>
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/widgets/button.hpp>
#include <thread>

int main()
{
    using namespace nana;

    //Define a form.
    form fm;

    //Define a label and display a text.
    label lab{fm, "Hello, <bold blue size=16>Nana C++ Library</>"};
    lab.format(true);

    //Define a button and answer the click event.
    button btn{fm, "Quit"};
    btn.events().click([&fm]{
        fm.close();
    });

    //Layout management
    fm.div("vert <><<><weight=80% text><>><><weight=24<><button><>><>");
    fm["text"]<<lab;
    fm["button"] << btn;
    fm.collocate();

    //Show the form
    fm.show();

    //Start to event loop process, it blocks until the form is closed.
    exec();
}

Here are my includes:

includes

And the libraries:

libraries

Thank you.

Aucun commentaire:

Enregistrer un commentaire