Форум русскоязычного сообщества Ubuntu


Считаете, что Ubuntu недостаточно дружелюбна к новичкам?
Помогите создать новое Руководство для новичков!

Автор Тема: fltk  (Прочитано 1785 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн andeykapas

  • Автор темы
  • Новичок
  • *
  • Сообщений: 24
    • Просмотр профиля
fltk
« : 10 Апреля 2015, 15:45:43 »
код:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main(int argc, char **argv) {
  Fl_Window *window = new Fl_Window(340,180);
  Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
  box->box(FL_UP_BOX);
  box->labelfont(FL_BOLD+FL_ITALIC);
  box->labelsize(36);
  box->labeltype(FL_SHADOW_LABEL);
  window->end();
  window->show(argc, argv);
  return Fl::run();
}

консоль:
andreykapas@Andrew-pc:~$ g++ ./fl_test/hello.cpp
/tmp/cc1JL9DA.o: In function `main':
hello.cpp:(.text+0x32): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
hello.cpp:(.text+0x66): undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'
hello.cpp:(.text+0xa2): undefined reference to `fl_define_FL_SHADOW_LABEL()'
hello.cpp:(.text+0xbe): undefined reference to `Fl_Group::end()'
hello.cpp:(.text+0xd3): undefined reference to `Fl_Window::show(int, char**)'
hello.cpp:(.text+0xd8): undefined reference to `Fl::run()'
collect2: error: ld returned 1 exit status
andreykapas@Andrew-pc:~$

помогите)

Оффлайн aSmile

  • Активист
  • *
  • Сообщений: 755
    • Просмотр профиля
Re: fltk
« Ответ #1 : 10 Апреля 2015, 15:57:58 »
Так что ж ты этот fltk не слинковал-то?

Оффлайн andeykapas

  • Автор темы
  • Новичок
  • *
  • Сообщений: 24
    • Просмотр профиля
Re: fltk
« Ответ #2 : 10 Апреля 2015, 15:59:39 »
очень может быть)
а как слинковать?

Пользователь решил продолжить мысль [time]10 Апрель 2015, 17:53:51[/time]:
вот!)
andreykapas@Andrew-pc:~$ g++ /home/andreykapas/fl_test/hello.cpp -L/usr/local/lib -lfltk -lXext -lX11 -lm

и всё заработало!)

Пользователь решил продолжить мысль [time]10 Апрель 2015, 18:25:44[/time]:
спасибо за помощь!
Но fltk я установил, Чтобы Страуструпа "Принципы и практику..." пробовать, так вот:
создал папку: /home/andreykapas/Strsustr/str12_3
в неё положил файлы из сорса книги: Graph.h, Simple_Window.h и т.д. ...
код:
//
// This is example code from Chapter 12.3 "A first example" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//

#include "Simple_window.h"    // get access to our window library
#include "Graph.h"            // get access to our graphics library facilities

//------------------------------------------------------------------------------

int main()
{
    using namespace Graph_lib;   // our graphics facilities are in Graph_lib

    Point tl(100,100);           // to become top left  corner of window

    Simple_window win(tl,600,400,"Canvas");    // make a simple window

    Polygon poly;                // make a shape (a polygon)

    poly.add(Point(300,200));    // add a point
    poly.add(Point(350,100));    // add another point
    poly.add(Point(400,200));    // add a third point

    poly.set_color(Color::red);  // adjust properties of poly

    win.attach (poly);           // connect poly to the window

    win.wait_for_button();       // give control to the display engine
}

//------------------------------------------------------------------------------
И вот:

andreykapas@Andrew-pc:~$ g++ ./Strsustr/str12_3/chapter.12.3.cpp -L/usr/local/lib -lfltk -lXtext -lX11 -lm -o ./Strsustr/str12_3/first
In file included from /usr/include/c++/4.8/ext/hash_map:60:0,
                 from ./Strsustr/str12_3/std_lib_facilities.h:34,
                 from ./Strsustr/str12_3/Window.h:12,
                 from ./Strsustr/str12_3/GUI.h:10,
                 from ./Strsustr/str12_3/Simple_window.h:10,
                 from ./Strsustr/str12_3/chapter.12.3.cpp:7:
/usr/include/c++/4.8/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
 #warning \
  ^
In file included from ./Strsustr/str12_3/chapter.12.3.cpp:7:0:
./Strsustr/str12_3/Simple_window.h:17:24: error: reference to ‘Window’ is ambiguous
 struct Simple_window : Window {
                        ^
In file included from /usr/include/FL/Xutf8.h:24:0,
                 from /usr/include/FL/fl_utf8.h:64,
                 from /usr/include/FL/Fl.H:30,
                 from ./Strsustr/str12_3/Window.h:10,
                 from ./Strsustr/str12_3/GUI.h:10,
                 from ./Strsustr/str12_3/Simple_window.h:10,
                 from ./Strsustr/str12_3/chapter.12.3.cpp:7:
/usr/include/X11/X.h:96:13: note: candidates are: typedef XID Window
 typedef XID Window;
             ^
In file included from ./Strsustr/str12_3/GUI.h:10:0,
                 from ./Strsustr/str12_3/Simple_window.h:10,
                 from ./Strsustr/str12_3/chapter.12.3.cpp:7:
./Strsustr/str12_3/Window.h:22:11: note:                 class Graph_lib::Window
     class Window : public Fl_Window {
           ^
./Strsustr/str12_3/chapter.12.3.cpp: In function ‘int main()’:
./Strsustr/str12_3/chapter.12.3.cpp:28:9: error: ‘struct Simple_window’ has no member named ‘attach’
     win.attach (poly);           // connect poly to the window

как быть?
« Последнее редактирование: 11 Апреля 2015, 11:56:34 от andeykapas »

Оффлайн Olej

  • Забанен
  • Активист
  • *
  • Сообщений: 884
    • Просмотр профиля
Re: fltk
« Ответ #3 : 11 Апреля 2015, 16:59:55 »
как быть?

как быть ... как быть ...

У Страуструпа есть 2 файла хэдеров в его каталоге:
#include "Simple_window.h"    // get access to our window library
#include "Graph.h"            // get access to our graphics library facilities
А в вашем их нет.

Как быть? Искать...

Оффлайн andeykapas

  • Автор темы
  • Новичок
  • *
  • Сообщений: 24
    • Просмотр профиля
Re: fltk
« Ответ #4 : 11 Апреля 2015, 23:59:59 »
да, к стати, ответ на последнюю проблему здесь: https://forum.ubuntu.ru/index.php?topic=259908.0

 

Страница сгенерирована за 0.016 секунд. Запросов: 21.