Results 1 to 14 of 14

Thread: Compile problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Peasant
    Join Date
    Jan 2011
    Posts
    6

    Unhappy Compile problem

    I'm new in ClanLib. I wanted to try simple Console ClanLib program:
    Code:
    #include <ClanLib/core.h>
    #include <ClanLib/application.h>
     
    class ConsoleProgram {
     public:
        static int main(const std::vector<CL_String> &args);
    };
         
    // Create global application object:
    // You MUST include this line or the application start-up will fail to
    // locate your console application object.
    CL_ClanApplication app(&ConsoleProgram::main);
          
    int ConsoleProgram::main(const std::vector<CL_String> &args){
        // Setup clanCore:
        CL_SetupCore setup_core;
        	 
        // Create a console Window if one does not exist:
        CL_ConsoleWindow console_window("Console");
        		 
        // Write a line to the console:
        CL_Console::write_line("Hello World!");
        			 
        // Wait for a key so the window won't close immediately.
        CL_Console::wait_for_key();
        			             
        return 0;
    }
    But i can't compile it. I get this error:

    Code:
    $ g++ test.cpp
    test.cpp:1:26: error: ClanLib/core.h: The directory or file does not exist
    test.cpp:2:33: error: ClanLib/application.h: The directory or file does not exist
    test.cpp:6: error: expected unqualified-id before ‘<’ token
    test.cpp:6: error: expected ‘)’ before ‘<’ token
    test.cpp:6: error: expected ‘;’ before ‘<’ token
    test.cpp:12: error: ‘CL_ClanApplication’ does not name a type
    test.cpp:14: error: expected unqualified-id before ‘<’ token
    test.cpp:14: error: expected ‘)’ before ‘<’ token
    test.cpp:14: error: expected initializer before ‘<’ token
    I installed ClanLib according to this tutorial.

    When I tried use this:
    Code:
    #include "/usr/local/include/ClanLib-2.2/ClanLib/core.h"
    #include "/usr/local/include/ClanLib-2.2/ClanLib/application.h"
    #include <vector>
    I got bigger error then before.
    Code:
    $ g++ test.cpp
    test.cpp:1:45: error: /usr/local/include/ClanLib/core.h: Adresář nebo soubor neexistuje
    test.cpp:2:52: error: /usr/local/include/ClanLib/application.h: Adresář nebo soubor neexistuje
    test.cpp:7: error: ‘CL_String’ was not declared in this scope
    test.cpp:7: error: template argument 1 is invalid
    test.cpp:7: error: template argument 2 is invalid
    test.cpp: In static member function ‘static int ConsoleProgram::main(const int&)’:
    test.cpp:8: error: ‘CL_SetupCore’ was not declared in this scope
    test.cpp:8: error: expected ‘;’ before ‘setup_core’
    test.cpp:9: error: ‘CL_ConsoleWindow’ was not declared in this scope
    test.cpp:9: error: expected ‘;’ before ‘console_window’
    test.cpp:11: error: ‘CL_String’ was not declared in this scope
    test.cpp:11: error: expected ‘;’ before ‘now’
    test.cpp:12: error: ‘CL_Console’ has not been declared
    test.cpp:12: error: ‘now’ was not declared in this scope
    test.cpp:13: error: ‘CL_Console’ has not been declared
    test.cpp: At global scope:
    test.cpp:18: error: ‘CL_ClanApplication’ does not name a type
    [jan][jan@doma.net][test]$ g++ test.cpp
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../crt1.o: In function `_start':
    /home/qateam/rpm/BUILD/glibc-2.11.1/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
    /tmp//cczJKzcd.o: In function `CL_Console::write_line(CL_StringRef8 const&)':
    test.cpp:(.text._ZN10CL_Console10write_lineERK13CL_StringRef8[CL_Console::write_line(CL_StringRef8 const&)]+0xf): undefined reference to `CL_Console::write(CL_StringRef8 const&)'
    test.cpp:(.text._ZN10CL_Console10write_lineERK13CL_StringRef8[CL_Console::write_line(CL_StringRef8 const&)]+0x22): undefined reference to `CL_StringRef8::CL_StringRef8(char const*)'
    test.cpp:(.text._ZN10CL_Console10write_lineERK13CL_StringRef8[CL_Console::write_line(CL_StringRef8 const&)]+0x2d): undefined reference to `CL_Console::write(CL_StringRef8 const&)'
    test.cpp:(.text._ZN10CL_Console10write_lineERK13CL_StringRef8[CL_Console::write_line(CL_StringRef8 const&)]+0x38): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN10CL_Console10write_lineERK13CL_StringRef8[CL_Console::write_line(CL_StringRef8 const&)]+0x4e): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    /tmp//cczJKzcd.o: In function `CL_ClanApplication::CL_ClanApplication(int (*)(std::vector<CL_String8, std::allocator<CL_String8> > const&))':
    test.cpp:(.text._ZN18CL_ClanApplicationC1EPFiRKSt6vectorI10CL_String8SaIS1_EEE[CL_ClanApplication::CL_ClanApplication(int (*)(std::vector<CL_String8, std::allocator<CL_String8> > const&))]+0x7): undefined reference to `CL_ClanApplication::main'
    /tmp//cczJKzcd.o: In function `ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)':
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x15): undefined reference to `CL_SetupCore::CL_SetupCore()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x28): undefined reference to `CL_StringRef8::CL_StringRef8(char const*)'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x4d): undefined reference to `CL_ConsoleWindow::CL_ConsoleWindow(CL_StringRef8 const&, int, int)'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x58): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x69): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x7d): undefined reference to `CL_DateTime::get_current_local_time()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x95): undefined reference to `CL_DateTime::to_short_datetime_string() const'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0xa3): undefined reference to `CL_DateTime::~CL_DateTime()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0xb4): undefined reference to `CL_DateTime::~CL_DateTime()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0xd2): undefined reference to `CL_String8::CL_String8(CL_String8 const&)'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0xe5): undefined reference to `CL_StringRef8::CL_StringRef8(char const*)'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x102): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x113): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x124): undefined reference to `CL_String8::~CL_String8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x135): undefined reference to `CL_String8::~CL_String8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x140): undefined reference to `CL_Console::wait_for_key()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x153): undefined reference to `CL_String8::~CL_String8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x167): undefined reference to `CL_String8::~CL_String8()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x17b): undefined reference to `CL_ConsoleWindow::~CL_ConsoleWindow()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x18f): undefined reference to `CL_ConsoleWindow::~CL_ConsoleWindow()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x1a3): undefined reference to `CL_SetupCore::~CL_SetupCore()'
    test.cpp:(.text._ZN14ConsoleProgram4mainERKSt6vectorI10CL_String8SaIS1_EE[ConsoleProgram::main(std::vector<CL_String8, std::allocator<CL_String8> > const&)]+0x1c1): undefined reference to `CL_SetupCore::~CL_SetupCore()'
    /tmp//cczJKzcd.o: In function `void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)':
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x19): undefined reference to `CL_StringFormat::CL_StringFormat(CL_StringRef8 const&)'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x2b): undefined reference to `CL_String8::operator CL_StringRef8() const'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x48): undefined reference to `CL_StringFormat::set_arg(int, CL_StringRef8 const&)'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x53): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x64): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x75): undefined reference to `CL_StringFormat::get_result() const'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x84): undefined reference to `CL_String8::operator CL_StringRef8() const'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0x9d): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0xae): undefined reference to `CL_StringRef8::~CL_StringRef8()'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0xbf): undefined reference to `CL_StringFormat::~CL_StringFormat()'
    test.cpp:(.text._ZN10CL_Console10write_lineI10CL_String8EEvRK13CL_StringRef8T_[void CL_Console::write_line<CL_String8>(CL_StringRef8 const&, CL_String8)]+0xd8): undefined reference to `CL_StringFormat::~CL_StringFormat()'
    collect2: ld returned 1 exit status
    Must I use g++ test.cpp -l<library>? Or it is problem in bad installation of ClanLibrary?

    Can anybody help me? L.
    Last edited by lorin; 01-15-2011 at 08:01 PM.

  2. #2
    Squire
    Join Date
    Jul 2010
    Posts
    20

    Default

    Try:

    g++ -o test test.cpp `pkg-config --cflags --libs clanCore-2.2 clanDisplay-2.2 clanGL-2.2 clanApp-2.2` -lpthread -ggdb

    (There's more here than you actually need for a console only program, but you will need them if you go on to using graphics)
    Last edited by rebecca.palmer; 01-15-2011 at 09:25 PM.

  3. #3
    Peasant
    Join Date
    Jan 2011
    Posts
    6

    Default Re: Rebeca

    Thanks for your help:
    Quote Originally Posted by rebecca.palmer View Post
    Try:
    g++ -o test test.cpp `pkg-config --cflags --libs clanCore-2.2 clanDisplay-2.2 clanGL-2.2 clanApp-2.2` -lpthread -ggdb
    But when I used this ^ command, I got this error:

    Code:
    $ g++ -o test.run test.cpp `pkg-config --cflags --libs clanCore-2.2 clanDisplay-2.2 clanGL-2.2 clanApp-2.2` -lpthread -ggdb
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22Display.so: undefined reference to `__sync_val_compare_and_swap_4'
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22Display.so: undefined reference to `__sync_bool_compare_and_swap_4'
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22GL.so: undefined reference to `__sync_sub_and_fetch_4'
    collect2: ld returned 1 exit status
    Where is problem? L.

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    That should work perfectly.

    Personally, I do not use "--ggbd", but it should not matter

    1) Ensure gcc is not a really old version
    2) Try compiling with "-msse2"
    3) Download ClanLib source, and try compiling the examples.

  5. #5
    Peasant
    Join Date
    Jan 2011
    Posts
    6

    Default

    1. I think I have good version:
    Code:
    $ g++ --version
    g++ (GCC) 4.4.3
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    2. I got this errors:
    Code:
    $ g++ -o test.run test.cpp `pkg-config --cflags --libs clanCore-2.2 clanDisplay-2.2 clanGL-2.2 clanApp-2.2` -lpthread -msse2
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22Display.so: undefined reference to `__sync_val_compare_and_swap_4'
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22Display.so: undefined reference to `__sync_bool_compare_and_swap_4'
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22GL.so: undefined reference to `__sync_sub_and_fetch_4'
    collect2: ld returned 1 exit status
    3. I got this error, when I tried compile GUI basic example (Examples/GUI/GUIBasic/)
    Code:
    $ make
    g++ `pkg-config --cflags clanApp-2.2 clanDisplay-2.2 clanCore-2.2 clanSWRender-2.2 clanGUI-2.2` -pthread Sources/program.o Sources/gui.o Sources/precomp.o -o guibasic `pkg-config --libs clanApp-2.2 clanDisplay-2.2 clanCore-2.2 clanSWRender-2.2 clanGUI-2.2` 
    Sources/gui.o: In function `CL_InterlockedVariable::increment()':
    gui.cpp:(.text._ZN22CL_InterlockedVariable9incrementEv[CL_InterlockedVariable::increment()]+0x17): undefined reference to `__sync_add_and_fetch_4'
    Sources/gui.o: In function `CL_InterlockedVariable::decrement()':
    gui.cpp:(.text._ZN22CL_InterlockedVariable9decrementEv[CL_InterlockedVariable::decrement()]+0x17): undefined reference to `__sync_sub_and_fetch_4'
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22SWRender.so: undefined reference to `__sync_val_compare_and_swap_4'
    /usr/lib/gcc/i586-manbo-linux-gnu/4.4.3/../../../libclan22GUI.so: undefined reference to `__sync_bool_compare_and_swap_4'
    collect2: ld returned 1 exit status
    make: *** [guibasic] Error 1
    I think, problem is in bad installation. Can you send me link to install tutorial/guide for linux? L.

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    http://clanlib.org/wiki/MainDocs:GNU_C%2B%2B_on_Linux

    `__sync_add_and_fetch_4' etc is an internal compiler function, that "should" have been converted to SSE2 instructions.

    Strange

Similar Threads

  1. Failure to compile on GNU
    By speeder in forum Official ClanLib SDK Forums
    Replies: 6
    Last Post: 07-29-2010, 10:53 PM
  2. After i compile it and run it on another computer
    By jerry in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 03-30-2010, 07:37 AM
  3. Can't compile clanGL on Mac
    By Tael_ in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 07-18-2008, 01:19 AM
  4. Can't compile application
    By Magus in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 02-26-2008, 07:51 AM
  5. how to compile static
    By andreaszdw in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 05-07-2007, 05:03 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •