Author Topic: Code::Blocks not compiling .cpp files well under Ubuntu  (Read 14313 times)

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Code::Blocks not compiling .cpp files well under Ubuntu
« on: June 17, 2008, 01:49:39 pm »
Hi all, I've installed code::blocks on my Ubuntu Desktop at work :), But for some reason, it gives me all kinds of weird errors when I try to compile a c++ file. C files on the other hand compile just fine.

My feeling is that I must be making a very stupid mistake, which is why I am not including the verbose, unless you think you need it.

Best Regards,

Srepuac :

 :?

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #1 on: June 17, 2008, 02:21:28 pm »
Umm, after experimenting a bit, it seems to happen only if I use the curses library, ansi c++ seems to compile fine.

The following simple program doesn't compile:

#include <ncurses.h>

int main()
{

    initscr();

    printw("%s", "hello world");
    refresh();

    endwin();


}


Codeblocks verboses the following:

/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x833)||undefined reference to `dlopen'|
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x84d)||undefined reference to `dlsym'|
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x866)||undefined reference to `dlsym'|
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x87f)||undefined reference to `dlsym'|
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x898)||undefined reference to `dlsym'|
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x8b5)||undefined reference to `dlclose'|
||=== Build finished: 6 errors, 0 warnings ===|

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #2 on: June 17, 2008, 03:04:31 pm »
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x833)||undefined reference to `dlopen'|
/usr/lib/libcurses.a(lib_mouse.o)||In function `_nc_mouse_init':|
(.text+0x84d)||undefined reference to `dlsym'|
[...]
http://www.google.com/search?q=undefined%20reference%20to%20%60dlopen'%7C
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #3 on: June 17, 2008, 04:39:29 pm »
Umm, nice, but i can compile well with ubuntu's command line, my problem seems to be related to library linking in code::blocks or something. Anyone?

Offline Barking_Mad

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #4 on: June 17, 2008, 07:34:06 pm »
Post your project & build settings pls :)

EDIT: Also the successful command line build string may help.
WooF! WooF! - Ubuntu 8.10 & CB 5432 & GCC 4.3.2
To see the world in a grain of sand and heaven in a wild flower
To hold infinity in the palm of your hand and eternity in an hour - W.B

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #5 on: June 17, 2008, 09:15:56 pm »
srepuac, what problem, linking library to the project :)

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #6 on: June 18, 2008, 01:10:37 pm »
Umm, project and build settings huh?

I'm not sure exactly how to check that, but I don't make projects, I just make File-New-File-C++ Source.

As for build settings, I just added the following libraries and search directories to my compiler:

Libraries:
libncurses++.a
libcurses.a
libncurses.a
libdl.a
libglib.a

Directories:
/usr/lib

Hope you can help me solve the problem, I love code::blocks  :(

Oops, had forgotten the command line:

g++ file.cpp -o file -lncurses

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #7 on: June 18, 2008, 02:07:40 pm »
Umm, project and build settings huh?

no :) Settings->Compiler and Debugger(Linker settings)

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #8 on: June 18, 2008, 02:13:42 pm »
Well, McZim, on linker settings, I just have those extra libraries listed above

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #9 on: June 18, 2008, 03:26:35 pm »
you need include this library /lib/libncurses.so.5

P.S.: path /lib, not /usr/lib. And shall be install this packages libncurses5, libncurses5-dev
« Last Edit: June 18, 2008, 03:41:52 pm by McZim »

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #10 on: June 18, 2008, 05:33:23 pm »
I didn't find libncurses.so.5, just libncurses.so, which I added to the list.

libncurses5, libncurses5-dev are installed to the latest version :(

I also added the /lib dir, but still the same errors...
« Last Edit: June 18, 2008, 05:35:45 pm by srepuac »

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #11 on: June 18, 2008, 07:36:46 pm »
ok, if not find libncurses.so.5, include libncurses.so to the project, but path shall be /lib.

show me place result two command:

1. sudo aptitude search ncurses
2. sudo find / -name libncurses*

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #12 on: June 19, 2008, 12:46:47 pm »
Hello McZim, thanks for the assistance :)

Here's the results of the two commands :

sudo aptitude search ncurses

p   evms-ncurses                    - Enterprise Volume Management System (ncurs
p   irmp3-ncurses                   - irmp3 control frontend                   
p   lib64ncurses5                   - Shared libraries for terminal handling (64
p   lib64ncurses5-dev               - Developer's libraries for ncurses (64-bit)
v   libncurses-dev                  -                                           
p   libncurses-ruby                 - ruby Extension for the ncurses C library 
p   libncurses-ruby1.8              - ruby Extension for the ncurses C library 
p   libncurses-ruby1.9              - ruby Extension for the ncurses C library 
p   libncurses4                     - Shared libraries for terminal handling   
i   libncurses5                     - Shared libraries for terminal handling   
p   libncurses5-dbg                 - Debugging/profiling libraries for ncurses
i   libncurses5-dev                 - Developer's libraries and docs for ncurses
i   libncursesw5                    - Shared libraries for terminal handling (wi
p   libncursesw5-dbg                - Debugging/profiling libraries for ncurses
p   libncursesw5-dev                - Developer's libraries for ncursesw       
i   ncurses-base                    - Descriptions of common terminal types     
i   ncurses-bin                     - Terminal-related programs and man pages   
v   ncurses-dev                     -                                           
p   ncurses-hexedit                 - Edit files/disks in hex, ASCII and EBCDIC
v   ncurses-runtime                 -                                           
p   ncurses-term                    - Additional terminal type definitions     




 

sudo find / -name libncurses*

/lib/libncursesw.so.5
/lib/libncurses.so.5
/lib/libncursesw.so.5.5
/lib/libncurses.so.5.5
/usr/lib/libncurses.so.5 /* I've now included them in the linker settings but I still get the same errors :( */
/usr/lib/libncurses.a
/usr/lib/vlc/gui/libncurses_plugin.so
/usr/lib/libncurses.so
/usr/lib/libncurses++.a
/usr/share/doc/libncurses5-dev
/usr/share/doc/libncurses5
/usr/share/doc/libncursesw5
/var/cache/apt/archives/libncurses5-dev_5.5-5ubuntu2_i386.deb
/var/cache/apt/archives/libncurses5_5.5-5ubuntu2_i386.deb
/var/lib/dpkg/info/libncursesw5.list
/var/lib/dpkg/info/libncursesw5.postrm
/var/lib/dpkg/info/libncurses5.shlibs
/var/lib/dpkg/info/libncurses5-dev.list
/var/lib/dpkg/info/libncurses5.list
/var/lib/dpkg/info/libncursesw5.shlibs
/var/lib/dpkg/info/libncurses5.postrm
/var/lib/dpkg/info/libncursesw5.postinst
/var/lib/dpkg/info/libncurses5.postinst

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #13 on: June 20, 2008, 11:20:29 am »
sudo aptitude search ncurses

i   libncurses5                     - Shared libraries for terminal handling   
i   libncurses5-dev                 - Developer's libraries and docs for ncurses


sudo find / -name libncurses*

/lib/libncurses.so.5
/usr/lib/libncurses.so.5 /* I've now included them in the linker settings but I still get the same errors :( */  << ERROR >>

Hi, thats ok, but you need include /lib/libncurses.so.5
and not /usr/lib/libncurses.so.5

Offline srepuac

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code::Blocks not compiling .cpp files well under Ubuntu
« Reply #14 on: June 20, 2008, 04:37:59 pm »
Libraries
http://tinypic.com/view.php?pic=2vht0ro&s=3

Directories:
http://tinypic.com/view.php?pic=1z4yi5l&s=3

Anything wrong?

Libraries:
usr/lib/libncurses++.a
usr/lib/libcurses.a
usr/lib/libncurses.a
usr/lib/libdl.a
usr/lib/libglib.a
usr/lib/libncurses.so
/lib/libncurses.so.5


Directories:
lib
« Last Edit: June 20, 2008, 04:40:38 pm by srepuac »