Author Topic: [Solved] Unable to build Code::Blocks under Kubuntu 17.04  (Read 5807 times)

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
[Solved] Unable to build Code::Blocks under Kubuntu 17.04
« on: September 12, 2017, 07:37:12 pm »
With reference to http://forums.codeblocks.org/index.php/topic,22122.msg150567.html#msg150567

I have been trying to build Code::Blocks from https://github.com/obfuscated/codeblocks_sf
Under Kubuntu 17.04 but the build fails:

Following the BUILD instructions, I did

$ git clone https://github.com/obfuscated/codeblocks_sf
$ cd codeblocks_sf/
$ ./bootstrap
$ ./configure --with-contrib-plugins=all
$ make


After a while, the linking fails

../../src/sdk/scripting/sqstdlib/libsqstdlib.la -lpthread -ldl

*** Warning: Linking the shared library libcodeblocks.la against the
*** static library /usr/local/lib/libwx_gtk2u_aui-3.0.a is not portable!

*** Warning: Linking the shared library libcodeblocks.la against the
*** static library /usr/local/lib/libwx_gtk2u_propgrid-3.0.a is not portable!


and at the end

/usr/bin/ld: /usr/local/lib/libwx_gtk2u_aui-3.0.a(auilib_framemanager.o): relocation R_X86_64_PC32 against symbol `_ZN14wxAuiRectArray5EmptyEv' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:851: recipe for target 'libcodeblocks.la' failed
make[3]: *** [libcodeblocks.la] Error 1
make[3]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src/sdk'
Makefile:1011: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src/sdk'
Makefile:541: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src'
Makefile:615: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1


I am guessing this happens because I have a static lib version of wx-3.0 that I have built and use with my own code. But if this is the problem, how can I tell the Code::Blocks build to ignore it?

Any advice appreciated.

EDIT:
I am trying a modified configure which seems to work better:

./configure --with-contrib-plugins=all  --with-wx-config=/usr/bin/wx-config
« Last Edit: September 12, 2017, 10:53:46 pm by cacb »

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #1 on: September 12, 2017, 08:11:18 pm »
Well, after changing the configure as shown, everything seems to compile. However, when I then try

$ sudo make install

This fails:

Code
/bin/mkdir -p '/usr/local/lib/codeblocks/plugins'
 /bin/bash ../../../libtool   --mode=install /usr/bin/install -c   libAstyle.la '/usr/local/lib/codeblocks/plugins'
libtool: [color=red]warning[/color]: relinking 'libAstyle.la'
libtool: install: (cd /ssd1/obfuscated/codeblocks_sf/src/plugins/astyle; /bin/bash "/ssd1/obfuscated/codeblocks_sf/libtool"  --tag CXX --mode=relink g++ -O2 -ffast-math -Winvalid-pch -fPIC -fexceptions -module -shared -version-info 0:1:0 -no-undefined -avoid-version -Wl,--no-undefined -o libAstyle.la -rpath /usr/local/lib/codeblocks/plugins asstreamiterator.lo astyleconfigdlg.lo astyleplugin.lo dlgformattersettings.lo formattersettings.lo astyle/ASBeautifier.lo astyle/ASEnhancer.lo astyle/ASFormatter.lo astyle/ASResource.lo ../../sdk/libcodeblocks.la -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_aui-3.0 -lwx_gtk2u_propgrid-3.0 -lwx_gtk2u_richtext-3.0 -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lpthread -ldl )
libtool: relink: g++  -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/6/crtbeginS.o  .libs/asstreamiterator.o .libs/astyleconfigdlg.o .libs/astyleplugin.o .libs/dlgformattersettings.o .libs/formattersettings.o astyle/.libs/ASBeautifier.o astyle/.libs/ASEnhancer.o astyle/.libs/ASFormatter.o astyle/.libs/ASResource.o   -L/usr/local/lib -lcodeblocks -L/usr/lib/x86_64-linux-gnu -lwx_gtk2u_aui-3.0 -lwx_gtk2u_propgrid-3.0 -lwx_gtk2u_richtext-3.0 -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lpthread -ldl -L/usr/lib/gcc/x86_64-linux-gnu/6 -L/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/6/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/6/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/6/crtfastmath.o /usr/lib/gcc/x86_64-linux-gnu/6/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/crtn.o  -O2 -Wl,--no-undefined -pthread   -pthread -Wl,-soname -Wl,libAstyle.so -o .libs/libAstyle.so
/usr/bin/ld: /usr/local/lib/libwx_baseu-3.0.a(baselib_threadinfo.o): relocation R_X86_64_TPOFF32 against `_ZZN12_GLOBAL__N_117GetThisThreadInfoEvE16s_thisThreadInfo' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libwx_gtk2u_xrc-3.0.a(xrclib_xmlres.o): relocation R_X86_64_PC32 against symbol `_ZN12wxFileSystemC1Ev' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
libtool:   [color=red]error[/color]: error: relink 'libAstyle.la' with the above command before installing it
Makefile:585: recipe for target 'install-pluginlibLTLIBRARIES' failed
make[5]: *** [install-pluginlibLTLIBRARIES] Error 1
make[5]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src/plugins/astyle'
Makefile:853: recipe for target 'install-am' failed
make[4]: *** [install-am] Error 2
make[4]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src/plugins/astyle'
Makefile:692: recipe for target 'install-recursive' failed
make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src/plugins/astyle'
Makefile:531: recipe for target 'install-recursive' failed
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src/plugins'
Makefile:541: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/ssd1/obfuscated/codeblocks_sf/src'
Makefile:615: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

Again it seems my local wx-3.0 static build got in the way. But why does this happen under install?? And how to fix?
« Last Edit: September 12, 2017, 09:13:19 pm by cacb »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #2 on: September 12, 2017, 08:32:38 pm »
Please use code or quote tags when pasting long logs.

What wx version are you using? I'm 100% sure that using the default one coming with ubuntu works fine.
And please use --prefix=/something/not/usr/local to save yourself the trouble you're in!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #3 on: September 12, 2017, 08:41:58 pm »
Please use code or quote tags when pasting long logs.

Ok, sorry.

What wx version are you using? I'm 100% sure that using the default one coming with ubuntu works fine.
And please use --prefix=/something/not/usr/local to save yourself the trouble you're in!

I am indeed trying to build code::blocks against the default one coming with ubuntu, but it fails. I have another wx-30 installed under /usr/local/include/wx-3.0 and /usr/local/lib, but this is NOT to be used when compiling Code::Blocks, only with my own applications using wx. I thought this would be enough:

./configure --with-contrib-plugins=all  --with-wx-config=/usr/bin/wx-config

so the --prefix=/something/not/usr/local  you are mentioning, is that with make install then?
« Last Edit: September 12, 2017, 08:45:23 pm by cacb »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #4 on: September 12, 2017, 08:59:19 pm »
Putting stuff in /usr/local is not really recommended. I have no idea why the autotools guys have decided to use it as default. It has caused lots of pain all over the world.

The prefix parameter should be passed to configure. And you should do it for everything you build with autotools. If you use the default then you won't be able to clean the files when you need to (because you'll have multiple different packages in a single prefix) and you'll end up with messed up system.

I guess the problem happens because the search paths of the compiler have /usr/local/include or /usr/local/lib before the system paths or something is mixed up...

I suppose the only way to fix this is by deleting everything in /usr/local .
I don't use /usr/local except for linking paths to binaries and I don't suffer from such problems... :)

p.s. if you're not doing development of codeblocks the best option is to build deb packages. It will take you an hour to learn how to do it, but after that you'll save tons of time, because the builds done with the deb builder are way more reliable than doing it manually.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #5 on: September 12, 2017, 09:37:01 pm »
I suppose the only way to fix this is by deleting everything in /usr/local .
I don't use /usr/local except for linking paths to binaries and I don't suffer from such problems... :)

I followed your advice and did this

./configure --with-contrib-plugins=all  --with-wx-config=/usr/bin/wx-config --prefix=/ssd1/cb/

But I did NOT delete everything in /usr/local as it would cause a lot of rework, so I tried the above instead and then both the build and install succeeded  :) That must mean the --prefix is passed on to the compiler if invoked during make install. Thanks for the --prefix tip, I didn't know that defines the install dir, but now I know.

p.s. if you're not doing development of codeblocks the best option is to build deb packages. It will take you an hour to learn how to do it, but after that you'll save tons of time, because the builds done with the deb builder are way more reliable than doing it manually.

Yes indeed, deb files would be preferable. I got deb packages when building from Jens' tarballs, but then it is all built into his setup, or so it seems. What I did then was  $ sudo dpkg-buildpackage, it gave me a bunch of deb-packages to install.

Can I just replace make with dpkg-buildpackage when building from your github clone? If no, where can I read and learn?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #6 on: September 12, 2017, 09:56:48 pm »
I'm not sure if you can build deb packages from plain repo or you need to make a dist (using make dist) commands. Read a tutorial about it and you'll learn how to do it...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Unable to build Code::Blocks under Kubuntu 17.04
« Reply #7 on: September 12, 2017, 10:52:44 pm »
I'm not sure if you can build deb packages from plain repo

I tried, and it works.

For my configuration, I had to edit debian/rules and for DEB_CONFIGURE_EXTRA_FLAGS I added --with-wx-config=/usr/bin/wx-config  to the existing options to make sure i was building against the default wx for ubuntu. Then I just did:

$ ./bootstrap
$ sudo dpkg-buildpackage


And it gave me the required .deb files. Perfect.